fix cutoff a grid peak shaving register
Some checks failed
CI and deploy / migration-check (push) Failing after 11s
CI and deploy / deploy (push) Has been skipped

This commit is contained in:
Dusan Vojacek
2026-04-29 13:36:38 +02:00
parent dede8d604d
commit b66b0109b9

View File

@@ -5,9 +5,11 @@ from services.control.exporter_monolith import (
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 contains extra bits; reg178 is a bit field and exporter uses RMW.
# We want to skip if the relevant bits match (bits45 and, if present, bits01).
last_verified = {178: 12030} # real-world example from home-01 (bits4-5 still == 0b11)
expected_rmw = (int(last_verified[178]) & ~0x0030) | int(REG178_PASSIVE)
registers = [(178, "control_board_special_1", int(expected_rmw))]
out, skipped = _drop_registers_matching_last_verified(registers, last_verified)
assert out == []
assert skipped == [178]