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(),
}

View File

@@ -28,7 +28,7 @@ DEYE_REG_GRID_EXPORT_TOTAL_LO = 524
DEYE_REG_GRID_EXPORT_TOTAL_HI = 525
DEYE_REG_PV1_POWER = 672
DEYE_REG_PV2_POWER = 673
# Solar sell (0 = přebytek řiditelné FVE nesmí do sítě) a GEN/MI cut-off (bits01 == 2 → cut-off ON); viz modbus-registers.md
# Solar sell (0 = přebytek řiditelné FVE nesmí do sítě) a GEN/MI cut-off (bits01 == 3 → cut-off ON); viz modbus-registers.md
DEYE_REG_SOLAR_SELL = 145
DEYE_REG_CONTROL_BOARD_SPECIAL1 = 179
@@ -48,7 +48,7 @@ def _export_limit_flags_from_deye_regs(reg145: int | None, reg179: int | None) -
flags = 0
if reg145 is not None and int(reg145) == 0:
flags |= 1
if reg179 is not None and (int(reg179) & 3) == 2:
if reg179 is not None and (int(reg179) & 3) == 3:
flags |= 2
return (flags != 0), flags