ski battery charge u sell
Some checks failed
CI and deploy / migration-check (push) Failing after 26s
CI and deploy / deploy (push) Has been skipped

This commit is contained in:
Dusan Vojacek
2026-05-28 23:22:57 +02:00
parent 4e5de5df90
commit 52e4b68789
8 changed files with 23 additions and 16 deletions

View File

@@ -331,7 +331,7 @@ def deye_battery_charge_discharge_amps(
max_discharge_a: int,
export_mode: str | None = None,
export_ban: bool = False,
) -> tuple[int, int]:
) -> tuple[int | None, int]:
"""
Proud nabíjení / vybíjení (reg 108 / 109) pro zápis Deye.
@@ -339,14 +339,17 @@ def deye_battery_charge_discharge_amps(
nabíjení neplní, přebytek jde do sítě (142 = zero-export dle instalace, 145 = 1).
PASSIVE + nabíjení bez exportního záměru (`battery_w > 0`, export_mode NONE): **108 = max**.
**CHARGE** ze sítě: 108 z `battery_w`. **SELL**: 108 = 0, 109 = max.
**CHARGE** ze sítě: 108 z `battery_w`.
**SELL** (selling first, reg 142 = 0): vrací ``(None, max_discharge)`` — reg **108 se nezapisuje**
(export řídí 142/178; nulování 108 a obnova po návratu jsou zbytečné zápisy do paměti).
"""
if lock_battery:
return 0, 0
if deye_mode == "CHARGE":
return battery_watts_to_amps(bat_w, max_charge_a), 0
if deye_mode == "SELL":
return 0, int(max_discharge_a)
return None, int(max_discharge_a)
if self_sustain_local_use:
return int(max_charge_a), int(max_discharge_a)
if _is_passive_pv_surplus_export(