Branch 4: BA81 GEN cutoff audit + exekuce při sell<0
Some checks failed
CI and deploy / migration-check (push) Failing after 14s
CI and deploy / deploy (push) Has been skipped

This commit is contained in:
Dusan Vojacek
2026-06-06 22:36:27 +02:00
parent a7879f1141
commit 0f7dc6ed94
11 changed files with 99 additions and 4 deletions

View File

@@ -59,6 +59,7 @@ class ExportPlanGuardTests(unittest.TestCase):
self.assertEqual(out.grid_export_limit, 0)
self.assertGreaterEqual(out.grid_setpoint_w, 0)
self.assertEqual(out.export_mode, "NONE")
self.assertTrue(out.deye_gen_cutoff_enabled)
def test_export_mode_none_with_non_negative_grid(self) -> None:
sp = _sp(grid_setpoint_w=0, battery_w=-5000, export_mode="BATTERY_SELL")

View File

@@ -11,6 +11,7 @@ from services.control.exporter_monolith import (
_deye_reg178_verify_with_double_read,
_deye_tou_params,
_deye_tou_power_verify_match,
deye_mi_export_cutoff_want_enabled,
deye_reg_triggers_self_sustain_after_verify_exhaust,
get_deye_mode,
)
@@ -114,6 +115,36 @@ class DeyeTouParamsTests(unittest.TestCase):
)
self.assertEqual(get_deye_mode(sp), "PASSIVE")
def test_mi_export_cutoff_on_export_ban_without_plan_flag(self) -> None:
self.assertTrue(
deye_mi_export_cutoff_want_enabled(
gen_microinverter_cutoff_enabled=True,
deye_gen_cutoff_enabled=False,
export_ban=True,
deye_mode="PASSIVE",
)
)
def test_mi_export_cutoff_off_when_sell_mode(self) -> None:
self.assertFalse(
deye_mi_export_cutoff_want_enabled(
gen_microinverter_cutoff_enabled=True,
deye_gen_cutoff_enabled=True,
export_ban=True,
deye_mode="SELL",
)
)
def test_mi_export_cutoff_off_without_feature_flag(self) -> None:
self.assertFalse(
deye_mi_export_cutoff_want_enabled(
gen_microinverter_cutoff_enabled=False,
deye_gen_cutoff_enabled=True,
export_ban=True,
deye_mode="PASSIVE",
)
)
def test_build_setpoints_uses_explicit_export_limit(self) -> None:
mode = OperatingModeInfo(
mode_code="AUTO",

View File

@@ -2208,6 +2208,10 @@ class NegativeSellPvChargeTests(unittest.TestCase):
for r in results:
self.assertGreaterEqual(r.battery_setpoint_w, 0, "neg sell má nabíjet")
self.assertGreaterEqual(r.grid_setpoint_w, 0, "neg sell bez exportu do sítě")
self.assertTrue(
r.deye_gen_cutoff_enabled,
"neg sell bez exportu → GEN cut-off ON (exekuce reg 178)",
)
def test_ba81_fixed_purchase_nt_vt_buy_spread_neg_sell_no_export(self) -> None:
"""BA81: NT/VT buy v horizontu (rozptyl >0,25) — záporný sell stále bez exportu."""