narovnani spravneho rezimu - nastavenim charge A
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""PASSIVE + plán chce nabíjet: 108 = plný strop z DB, 109 = max (PV špička + domácnost)."""
|
||||
"""PASSIVE + PV_SURPLUS: 108=0 (nepoužívat baterii), 109=max; 142 zůstává zero-export (1/2)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -8,7 +8,23 @@ from services.control.setpoints import deye_battery_charge_discharge_amps
|
||||
|
||||
|
||||
class PassivePvSurplusChargeAmpsTests(unittest.TestCase):
|
||||
def test_passive_charge_while_exporting_grid_negative(self) -> None:
|
||||
def test_pv_surplus_export_zeros_charge_amps(self) -> None:
|
||||
ch, dis = deye_battery_charge_discharge_amps(
|
||||
lock_battery=False,
|
||||
deye_mode="PASSIVE",
|
||||
self_sustain_local_use=False,
|
||||
bat_w=-177,
|
||||
grid_w=-2851,
|
||||
max_charge_a=100,
|
||||
max_discharge_a=90,
|
||||
export_mode="PV_SURPLUS",
|
||||
export_ban=False,
|
||||
)
|
||||
self.assertEqual(ch, 0)
|
||||
self.assertEqual(dis, 90)
|
||||
|
||||
def test_pv_surplus_even_if_lp_shows_positive_battery_w(self) -> None:
|
||||
"""Plán může mít kladný battery_w; exportní záměr je PV_SURPLUS → 108=0."""
|
||||
ch, dis = deye_battery_charge_discharge_amps(
|
||||
lock_battery=False,
|
||||
deye_mode="PASSIVE",
|
||||
@@ -17,12 +33,43 @@ class PassivePvSurplusChargeAmpsTests(unittest.TestCase):
|
||||
grid_w=-2000,
|
||||
max_charge_a=100,
|
||||
max_discharge_a=100,
|
||||
export_mode="PV_SURPLUS",
|
||||
export_ban=False,
|
||||
)
|
||||
self.assertEqual(ch, 0)
|
||||
self.assertEqual(dis, 100)
|
||||
|
||||
def test_passive_charge_without_export_mode_uses_max_108(self) -> None:
|
||||
ch, dis = deye_battery_charge_discharge_amps(
|
||||
lock_battery=False,
|
||||
deye_mode="PASSIVE",
|
||||
self_sustain_local_use=False,
|
||||
bat_w=5000,
|
||||
grid_w=0,
|
||||
max_charge_a=100,
|
||||
max_discharge_a=100,
|
||||
export_mode="NONE",
|
||||
export_ban=False,
|
||||
)
|
||||
self.assertEqual(ch, 100)
|
||||
self.assertEqual(dis, 100)
|
||||
|
||||
def test_legacy_negative_grid_infers_pv_surplus(self) -> None:
|
||||
ch, dis = deye_battery_charge_discharge_amps(
|
||||
lock_battery=False,
|
||||
deye_mode="PASSIVE",
|
||||
self_sustain_local_use=False,
|
||||
bat_w=0,
|
||||
grid_w=-2000,
|
||||
max_charge_a=100,
|
||||
max_discharge_a=100,
|
||||
export_mode=None,
|
||||
export_ban=False,
|
||||
)
|
||||
self.assertEqual(ch, 0)
|
||||
self.assertEqual(dis, 100)
|
||||
|
||||
def test_charge_mode_still_scales_108_from_battery_w(self) -> None:
|
||||
"""CHARGE (síť + baterie): 108 podle plánu, ne vždy plný strop."""
|
||||
ch, dis = deye_battery_charge_discharge_amps(
|
||||
lock_battery=False,
|
||||
deye_mode="CHARGE",
|
||||
@@ -36,19 +83,6 @@ class PassivePvSurplusChargeAmpsTests(unittest.TestCase):
|
||||
self.assertGreater(ch, 0)
|
||||
self.assertEqual(dis, 0)
|
||||
|
||||
def test_passive_export_without_battery_charge_uses_max_108(self) -> None:
|
||||
ch, dis = deye_battery_charge_discharge_amps(
|
||||
lock_battery=False,
|
||||
deye_mode="PASSIVE",
|
||||
self_sustain_local_use=False,
|
||||
bat_w=0,
|
||||
grid_w=-2000,
|
||||
max_charge_a=100,
|
||||
max_discharge_a=100,
|
||||
)
|
||||
self.assertEqual(ch, 100)
|
||||
self.assertEqual(dis, 100)
|
||||
|
||||
def test_sell_unchanged(self) -> None:
|
||||
ch, dis = deye_battery_charge_discharge_amps(
|
||||
lock_battery=False,
|
||||
|
||||
@@ -17,7 +17,6 @@ from services.control.exporter_monolith import (
|
||||
from services.control.models import OperatingModeInfo
|
||||
from services.control.setpoints import (
|
||||
_build_setpoints,
|
||||
_deye_reg142_limit_control,
|
||||
_deye_zero_export_amps_for_passive,
|
||||
)
|
||||
|
||||
@@ -115,43 +114,6 @@ class DeyeTouParamsTests(unittest.TestCase):
|
||||
)
|
||||
self.assertEqual(get_deye_mode(sp), "PASSIVE")
|
||||
|
||||
def test_reg142_pv_surplus_on_ct_site_uses_selling_first(self) -> None:
|
||||
"""KV1/BA81: PASSIVE + plánovaný export FVE nesmí nechat reg142=2 (zero export CT)."""
|
||||
self.assertEqual(
|
||||
_deye_reg142_limit_control(
|
||||
deye_mode="PASSIVE",
|
||||
grid_w=-3000,
|
||||
export_ban=False,
|
||||
export_mode="PV_SURPLUS",
|
||||
zero_export_mode=2,
|
||||
),
|
||||
0,
|
||||
)
|
||||
|
||||
def test_reg142_no_export_when_export_ban(self) -> None:
|
||||
self.assertEqual(
|
||||
_deye_reg142_limit_control(
|
||||
deye_mode="PASSIVE",
|
||||
grid_w=-1000,
|
||||
export_ban=True,
|
||||
export_mode="PV_SURPLUS",
|
||||
zero_export_mode=2,
|
||||
),
|
||||
2,
|
||||
)
|
||||
|
||||
def test_reg142_legacy_negative_grid_without_export_mode(self) -> None:
|
||||
self.assertEqual(
|
||||
_deye_reg142_limit_control(
|
||||
deye_mode="PASSIVE",
|
||||
grid_w=-2500,
|
||||
export_ban=False,
|
||||
export_mode=None,
|
||||
zero_export_mode=2,
|
||||
),
|
||||
0,
|
||||
)
|
||||
|
||||
def test_build_setpoints_uses_explicit_export_limit(self) -> None:
|
||||
mode = OperatingModeInfo(
|
||||
mode_code="AUTO",
|
||||
|
||||
Reference in New Issue
Block a user