Files
ems/backend/tests/test_drop_registers_matching_last_verified.py
Dusan Vojacek dede8d604d
Some checks failed
CI and deploy / migration-check (push) Failing after 13s
CI and deploy / deploy (push) Has been skipped
fix cutoff a grid peak shaving register
2026-04-29 13:36:38 +02:00

23 lines
880 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from services.control.exporter_monolith import (
REG178_PASSIVE,
_drop_registers_matching_last_verified,
)
def test_drop_registers_skips_reg178_when_mask_matches():
# last_verified contains extra bits beyond 0x0030; we still want to skip if bits 45 match.
registers = [(178, "grid_peak_shaving_switch", REG178_PASSIVE)]
last_verified = {178: 12030} # real-world example from home-01 (bits4-5 still == 0b11)
out, skipped = _drop_registers_matching_last_verified(registers, last_verified)
assert out == []
assert skipped == [178]
def test_drop_registers_keeps_reg178_when_mask_differs():
registers = [(178, "grid_peak_shaving_switch", REG178_PASSIVE)]
last_verified = {178: 32} # SELL mask 0b10
out, skipped = _drop_registers_matching_last_verified(registers, last_verified)
assert out == registers
assert skipped == []