Skip to content

Commit

Permalink
fix max ac out
Browse files Browse the repository at this point in the history
  • Loading branch information
LKuemmel committed May 13, 2024
1 parent a6d16f8 commit 22981a3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
5 changes: 4 additions & 1 deletion packages/control/bat_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,11 @@ def _max_bat_power_hybrid_system(self, battery: Bat) -> float:
parent_data = data.data.pv_data[f"pv{parent['id']}"].data
# Bei einem Hybrid-System darf die Summe aus Batterie-Ladeleistung, die für den Algorithmus verwendet
# werden soll und PV-Leistung nicht größer als die max Ausgangsleistung des WR sein.
# Wenn vom PV-Ertrag der Speicher geladen wird, kann diese Leistung bis zur max Ausgangsleistung des WR
# genutzt werden.
if parent_data.config.max_ac_out > 0:
max_bat_discharge_power = parent_data.config.max_ac_out + parent_data.get.power
max_bat_discharge_power = parent_data.config.max_ac_out + \
parent_data.get.power + max(battery.data.get.power, 0)
return max_bat_discharge_power, True
else:
battery.data.get.fault_state = FaultStateLevel.ERROR.value
Expand Down
17 changes: 11 additions & 6 deletions packages/control/bat_all_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,27 @@ def data_fixture() -> None:
config=Mock(spec=Config, max_ac_out=7200)))


@pytest.mark.parametrize("parent, bat_power, expected_power",
@pytest.mark.parametrize("parent, bat_power, pv_power, expected_power",
[
pytest.param({"id": 6, "type": "counter", "children": [
{"id": 2, "type": "bat", "children": []}]}, 100, (150, False),
{"id": 2, "type": "bat", "children": []}]}, 100, -6400, (150, False),
id="kein Hybrid-System, Speicher wird geladen"),
pytest.param({"id": 6, "type": "counter", "children": [
{"id": 2, "type": "bat", "children": []}]}, -100, (150, False),
{"id": 2, "type": "bat", "children": []}]}, -100, -6400, (150, False),
id="kein Hybrid-System, Speicher wird entladen"),
pytest.param({"id": 1, "type": "inverter", "children": []}, 600, (800, True),
id="maximale Entladeleistung des WR"),
pytest.param({"id": 1, "type": "inverter", "children": []}, 600, -6400, (1400, True),
id="maximale Entladeleistung des WR, Speicher lädt"),
pytest.param({"id": 1, "type": "inverter", "children": []}, 600, -7200, (600, True),
id="maximale Entladeleistung des WR, Speicher lädt"),
pytest.param({"id": 1, "type": "inverter", "children": []}, -600, -6400, (800, True),
id="maximale Entladeleistung des WR, Speicher entlädt"),
])
def test_max_bat_power_hybrid_system(parent, bat_power, expected_power, data_fixture, monkeypatch):
def test_max_bat_power_hybrid_system(parent, bat_power, pv_power, expected_power, data_fixture, monkeypatch):
# setup
# pv1-Data: max_ac_out 7200, power 6400
mock_get_entry_of_parent = Mock(return_value=parent)
monkeypatch.setattr(data.data.counter_all_data, "get_entry_of_parent", mock_get_entry_of_parent)
data.data.pv_data["pv1"].data.get.power = pv_power

b = BatAll()
bat2 = Bat(2)
Expand Down
4 changes: 2 additions & 2 deletions packages/control/counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ def _control_range_offset(self):
# 100(50 reichen auch?) W Überschuss übrig lassen, damit der Speicher bis zur max Ladeleistung hochregeln
# kann. Regelmodus ignorieren, denn mit Regelmodus Bezug kann keine Einspeisung für den Speicher erzeugt
# werden.
log.debug("Damit der Speicher hochregeln kann, muss unabhängig vom eingestellten Regelmodus Bezug erzeugt"
" werden.")
log.debug("Damit der Speicher hochregeln kann, muss unabhängig vom eingestellten Regelmodus Einspeisung"
" erzeugt werden.")
return - 100
control_range_low = data.data.general_data.data.chargemode_config.pv_charging.control_range[0]
control_range_high = data.data.general_data.data.chargemode_config.pv_charging.control_range[1]
Expand Down

0 comments on commit 22981a3

Please sign in to comment.