Skip to content

Commit

Permalink
Fix issue 1904 (#1905)
Browse files Browse the repository at this point in the history
* Fix issue 1904

* fix test cases for hybrid bat-discharge
  • Loading branch information
ChrisMuki authored Oct 11, 2024
1 parent f76bba6 commit bce129e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/control/bat_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def _max_bat_power_hybrid_system(self, battery: Bat) -> float:
# genutzt werden.
if parent_data.config.max_ac_out > 0:
max_bat_discharge_power = parent_data.config.max_ac_out + \
parent_data.get.power + min(battery.data.get.power, 0)
parent_data.get.power + battery.data.get.power
return max_bat_discharge_power, True
else:
battery.data.get.fault_state = FaultStateLevel.ERROR.value
Expand Down
24 changes: 19 additions & 5 deletions packages/control/bat_all_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,26 @@ def data_fixture() -> None:
pytest.param({"id": 6, "type": "counter", "children": [
{"id": 2, "type": "bat", "children": []}]}, -100, -6400, (150, False),
id="kein Hybrid-System, Speicher wird entladen"),
pytest.param({"id": 1, "type": "inverter", "children": []}, 600, -6400, (800, True),
id="Speicher lädt mit 600W, max 800W bis WR max"),
pytest.param({"id": 1, "type": "inverter", "children": []}, 600, -7200, (0, True),
id="maximale Entladeleistung des WR erreicht, Speicher lädt, keine Entladeleistung über"),
pytest.param({"id": 1, "type": "inverter", "children": []}, 1200, -6400, (2000, True),
id="Speicher lädt mit 1200W, max 2000W zusätzliche Entladeleistung bis WR max"),
pytest.param({"id": 1, "type": "inverter", "children": []}, 600, -6400, (1400, True),
id="Speicher lädt mit 600W, max 1400W zusätzliche Entladeleistung bis WR max"),
pytest.param({"id": 1, "type": "inverter", "children": []}, 0, -6400, (800, True),
id="Speicher neutral, max 800W Entladeleistung bis WR max"),
pytest.param({"id": 1, "type": "inverter", "children": []}, -600, -6400, (200, True),
id="Speicher entlädt mit 600W, max 200W bis WR max"),
id="Speicher entlädt mit 600W, max 200W Entladeleistung bis WR max"),
pytest.param({"id": 1, "type": "inverter", "children": []}, -800, -6400, (0, True),
id="Speicher entlädt mit 800W, maximale Entladeleistung des WR erreicht"),
pytest.param({"id": 1, "type": "inverter", "children": []}, 1200, -7200, (1200, True),
id="Speicher lädt mit 1200W, max 1200W zusätzliche Entladeleistung bis WR max"),
pytest.param({"id": 1, "type": "inverter", "children": []}, 600, -7200, (600, True),
id="Speicher lädt mit 600W, max 600W zusätzliche Entladeleistung bis WR max"),
pytest.param({"id": 1, "type": "inverter", "children": []}, 0, -7200, (0, True),
id="Speicher neutral, maximale Entladeleistung des WR erreicht"),
pytest.param({"id": 1, "type": "inverter", "children": []}, 1200, -7800, (600, True),
id="Speicher lädt mit 1200W, max 600W zusätzliche Entladeleistung bis WR max"),
pytest.param({"id": 1, "type": "inverter", "children": []}, 600, -7800, (0, True),
id="Speicher lädt mit 600W, maximale Entladeleistung des WR erreicht"),
])
def test_max_bat_power_hybrid_system(parent, bat_power, pv_power, expected_power_hybrid, data_fixture, monkeypatch):
# setup
Expand Down

0 comments on commit bce129e

Please sign in to comment.