invert logic cutoff register
Some checks failed
CI and deploy / migration-check (push) Failing after 14s
CI and deploy / deploy (push) Has been skipped

This commit is contained in:
Dusan Vojacek
2026-04-29 13:24:28 +02:00
parent 9aceb628aa
commit 342483b885
6 changed files with 14 additions and 12 deletions

View File

@@ -1648,9 +1648,11 @@ async def write_inverter_setpoints(
)
if inv.deye_gen_microinverter_cutoff_enabled:
# Deye UI semantics: "MI export cutoff ENABLE" means export to grid is blocked (GEN effectively cut off).
# Therefore: want_cutoff=True -> ENABLE (3), want_cutoff=False -> DISABLE (2).
want_cutoff = bool(setpoints_now.deye_gen_cutoff_enabled) and deye_mode != "SELL"
target_bits = (
REG179_MI_EXPORT_DISABLE if want_cutoff else REG179_MI_EXPORT_ENABLE
REG179_MI_EXPORT_ENABLE if want_cutoff else REG179_MI_EXPORT_DISABLE
)
try:
mb179 = await get_modbus_client(inv.host, inv.port)
@@ -1823,7 +1825,7 @@ async def read_deye_registers_live(site_id: int, db: asyncpg.Connection) -> dict
"reg178_peak_shaving_switch": int(r178),
"reg179_control_board_special_1": int(r179),
"reg179_mi_export_cutoff_bits": int(r179) & int(REG179_MI_EXPORT_MASK),
"reg179_mi_export_cutoff_is_on": (int(r179) & int(REG179_MI_EXPORT_MASK)) == int(REG179_MI_EXPORT_DISABLE),
"reg179_mi_export_cutoff_is_on": (int(r179) & int(REG179_MI_EXPORT_MASK)) == int(REG179_MI_EXPORT_ENABLE),
"reg191_peak_shaving_w": int(r191),
"read_at": read_at.isoformat(),
}