diff --git a/backend/services/control/setpoints.py b/backend/services/control/setpoints.py index bc5c932..5fa66ab 100644 --- a/backend/services/control/setpoints.py +++ b/backend/services/control/setpoints.py @@ -137,15 +137,10 @@ def _build_setpoints( buy_raw = pi.get("effective_buy_price") buy_f: float | None = float(buy_raw) if buy_raw is not None else None pv_b = int(pi.get("pv_b_forecast_solver_w") or 0) - # Slabý úsvit: neposílat reg 340 — forecast nepřesný, Deye řídí sám (108/109/142). + # Záporný buy i sell + pole B: pole A = 0 MÁ PŘEDNOST před úsvitovou + # výjimkou (při hluboce záporných cenách se reg 340 posílá vždy). _low_pv_no_reg340_w = 1500 if ( - forecast < _low_pv_no_reg340_w - and curtail <= 0 - and pv_b > 0 - ): - pv_a_allowed = None - elif ( buy_f is not None and sell_f is not None and float(buy_f) < 0.0 @@ -153,6 +148,13 @@ def _build_setpoints( and pv_b > 0 ): pv_a_allowed = 0 + elif ( + # Slabý úsvit: neposílat reg 340 — forecast nepřesný, Deye řídí sám (108/109/142). + forecast < _low_pv_no_reg340_w + and curtail <= 0 + and pv_b > 0 + ): + pv_a_allowed = None elif plan_skips_deye_reg340_write( battery_setpoint_w=bat_w, grid_setpoint_w=grid_sp,