Fix reg 340: záporný buy+sell má přednost před úsvitovou výjimkou
All checks were successful
CI and deploy / migration-check (push) Successful in 13s
CI and deploy / deploy (push) Successful in 53s

Větev 'slabý úsvit (forecast<1500 W) → reg 340 neposílat' zastínila větev
'buy<0 a sell<0 + pole B → pv_a_allowed=0' — při hluboce záporných cenách
za úsvitu by se pole A nezavřelo. Prohozeno pořadí; opravuje pre-existing
fail test_neg_buy_and_sell_with_pv_b_forces_pv_a_off (293 passed, 4 xfail).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dusan Vojacek
2026-06-12 15:19:10 +02:00
parent b66bb712e4
commit dd3bd55c0e

View File

@@ -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,