nastavitelny max sollar dle stridace (ulozeno v DB)
Some checks failed
CI and deploy / migration-check (push) Failing after 13s
CI and deploy / deploy (push) Has been skipped

This commit is contained in:
Dusan Vojacek
2026-05-25 11:25:29 +02:00
parent e06f76b9ff
commit c6074e9c74
13 changed files with 101 additions and 17 deletions

View File

@@ -65,7 +65,7 @@ DEYE_REGISTER_NAMES: dict[int, str] = {
142: "limit_control (0=selling first, 1=zero export to load, 2=zero export to CT)",
143: "export_limit_w (max export do sítě)",
145: "solar_sell (0=disabled, 1=enabled)",
340: "max_solar_power_w (strop DC PV A v W; součet nominal_power_wp řiditelných polí)",
340: "max_solar_power_w (strop DC PV A v W; cap z fn_inverter_pv_a_max_w / deye_reg340_max_solar_w)",
178: "control_board_special_1 (bits0-1: MI export cutoff disable=2 enable=3; bits4-5 peak shaving 32/48)",
148: "time_point_1_time",
149: "time_point_2_time",
@@ -157,11 +157,21 @@ def next_slot_hhmm() -> int:
return next_hour * 100 + next_min
def compute_pv_a_reg340_max_solar_w(cap_w: int, forecast_w: int, curtail_w: int) -> int:
def compute_pv_a_reg340_max_solar_w(
cap_w: int,
forecast_w: int,
curtail_w: int,
*,
min_w: int = 0,
) -> int:
"""Hodnota pro Deye reg 340 (max solar power, W) z capu a plánovaného curtailmentu pole A."""
if curtail_w <= 0:
return int(cap_w)
return max(0, min(int(cap_w), int(forecast_w) - int(curtail_w)))
raw = int(cap_w)
else:
raw = max(0, min(int(cap_w), int(forecast_w) - int(curtail_w)))
if raw > 0 and int(min_w) > 0:
return max(int(min_w), raw)
return raw
def _prague_minute_start_utc() -> datetime: