68 lines
2.1 KiB
Python
68 lines
2.1 KiB
Python
"""PASSIVE + plán chce nabíjet: 108 = plný strop z DB, 109 = max (PV špička + domácnost)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import unittest
|
|
|
|
from services.control.setpoints import deye_battery_charge_discharge_amps
|
|
|
|
|
|
class PassivePvSurplusChargeAmpsTests(unittest.TestCase):
|
|
def test_passive_charge_while_exporting_grid_negative(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=-2000,
|
|
max_charge_a=100,
|
|
max_discharge_a=100,
|
|
)
|
|
self.assertEqual(ch, 100)
|
|
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",
|
|
self_sustain_local_use=False,
|
|
bat_w=2000,
|
|
grid_w=3000,
|
|
max_charge_a=100,
|
|
max_discharge_a=100,
|
|
)
|
|
self.assertLess(ch, 100)
|
|
self.assertGreater(ch, 0)
|
|
self.assertEqual(dis, 0)
|
|
|
|
def test_passive_zero_export_still_zero_charge_when_no_battery_charge(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, 0)
|
|
self.assertEqual(dis, 100)
|
|
|
|
def test_sell_unchanged(self) -> None:
|
|
ch, dis = deye_battery_charge_discharge_amps(
|
|
lock_battery=False,
|
|
deye_mode="SELL",
|
|
self_sustain_local_use=False,
|
|
bat_w=-3000,
|
|
grid_w=-2000,
|
|
max_charge_a=100,
|
|
max_discharge_a=80,
|
|
)
|
|
self.assertEqual(ch, 0)
|
|
self.assertEqual(dis, 80)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|