nakup ve spicce aby prodal lenvneji, ale nemam jak otestovat poac uz bude po slotu (home01)
Some checks failed
CI and deploy / migration-check (push) Failing after 34s
CI and deploy / deploy (push) Has been skipped

This commit is contained in:
Dusan Vojacek
2026-06-01 19:17:55 +02:00
parent 63eff96c5f
commit 96adbff9ea
4 changed files with 131 additions and 12 deletions

View File

@@ -1757,9 +1757,24 @@ class NegativeSellPvChargeTests(unittest.TestCase):
"min sell: nabíjení z PV",
)
def test_fixed_no_grid_charge_when_sell_below_buy(self) -> None:
"""v59: KV1 — sell < buy nesmí grid→bat (22h za 6 Kč)."""
def test_fixed_no_grid_charge_when_sell_above_horizon_min(self) -> None:
"""v59: KV1 — grid→bat jen u min sell, ne v noci za 6 Kč při sell 3,5."""
prague = ZoneInfo("Europe/Prague")
cheap = PlanningSlot(
interval_start=datetime(2026, 6, 2, 10, 15, tzinfo=prague).astimezone(
timezone.utc
),
buy_price=6.353,
sell_price=1.45,
pv_a_forecast_w=0,
pv_b_forecast_w=0,
load_baseline_w=400,
ev1_connected=False,
ev2_connected=False,
allow_charge=True,
allow_discharge_export=False,
charge_acquisition_buy_czk_kwh=6.353,
)
slot = PlanningSlot(
interval_start=datetime(2026, 6, 1, 22, 0, tzinfo=prague).astimezone(
timezone.utc
@@ -1802,7 +1817,7 @@ class NegativeSellPvChargeTests(unittest.TestCase):
]
soc0 = 0.25 * battery.usable_capacity_wh
results, _, _ = solve_dispatch(
[slot],
[cheap, slot],
battery,
hp,
grid,
@@ -1813,9 +1828,9 @@ class NegativeSellPvChargeTests(unittest.TestCase):
operating_mode="AUTO",
)
self.assertLessEqual(
results[0].battery_setpoint_w,
results[1].battery_setpoint_w,
200,
"sell < buy: žádné grid nabíjení",
"sell nad min horizontu: žádné grid nabíjení",
)
def test_fixed_evening_push_no_charge_at_peak_sell(self) -> None:
@@ -3530,6 +3545,92 @@ class Home01RegressionTests(unittest.TestCase):
)
return results, snap
def test_spot_no_grid_charge_when_buy_above_acquisition(self) -> None:
"""v61: spot grid→bat jen když buy≈acq; sell<buy ve slotu je normální (marže)."""
prague = ZoneInfo("Europe/Prague")
cheap = PlanningSlot(
interval_start=datetime(2026, 6, 1, 4, 0, tzinfo=prague).astimezone(timezone.utc),
buy_price=0.55,
sell_price=0.35,
pv_a_forecast_w=0,
pv_b_forecast_w=0,
load_baseline_w=400,
ev1_connected=False,
ev2_connected=False,
allow_charge=True,
allow_discharge_export=False,
charge_acquisition_buy_czk_kwh=0.55,
)
bad = PlanningSlot(
interval_start=datetime(2026, 6, 1, 19, 0, tzinfo=prague).astimezone(timezone.utc),
buy_price=5.54,
sell_price=3.52,
pv_a_forecast_w=0,
pv_b_forecast_w=0,
load_baseline_w=400,
ev1_connected=False,
ev2_connected=False,
allow_charge=True,
allow_discharge_export=True,
charge_acquisition_buy_czk_kwh=3.25,
)
peak = PlanningSlot(
interval_start=datetime(2026, 6, 1, 20, 30, tzinfo=prague).astimezone(timezone.utc),
buy_price=6.53,
sell_price=4.27,
pv_a_forecast_w=0,
pv_b_forecast_w=0,
load_baseline_w=400,
ev1_connected=False,
ev2_connected=False,
allow_charge=False,
allow_discharge_export=True,
charge_acquisition_buy_czk_kwh=3.25,
)
battery = _battery(uc_wh=64_000.0, min_pct=10.0, arb_pct=20.0)
battery.max_charge_power_w = 18_000
battery.max_discharge_power_w = 13_500
hp = SimpleNamespace(
rated_heating_power_w=0,
tuv_min_temp_c=45.0,
tuv_target_temp_c=55.0,
)
grid = SimpleNamespace(
max_import_power_w=17_000,
max_export_power_w=13_500,
block_export_on_negative_sell=False,
purchase_pricing_mode="spot",
)
vehicles = [
SimpleNamespace(
max_charge_power_w=0,
battery_capacity_kwh=1.0,
default_target_soc_pct=80.0,
),
SimpleNamespace(
max_charge_power_w=0,
battery_capacity_kwh=1.0,
default_target_soc_pct=80.0,
),
]
results, _, _ = solve_dispatch(
[cheap, bad, peak],
battery,
hp,
grid,
[None, None],
vehicles,
0.5 * battery.usable_capacity_wh,
50.0,
operating_mode="AUTO",
)
r_bad = results[1]
self.assertLessEqual(
r_bad.battery_setpoint_w,
500,
"19:00 sell<buy: nesmí nabíjet ze sítě kvůli falešnému acq",
)
def test_vt_nt_cycle_evening_battery_sell(self) -> None:
"""Levné NT → večerní peak: nabíjení v cheap slotech, večer BATTERY_SELL (SoC ↑ před peakem)."""
from test_planning_charge_slot_selection import (