Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

max ac out consideration #1608

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions packages/control/bat_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def _max_bat_power_hybrid_system(self, battery: Bat) -> float:
# werden soll und PV-Leistung nicht größer als die max Ausgangsleistung des WR sein.
if parent_data.config.max_ac_out > 0:
max_bat_discharge_power = parent_data.config.max_ac_out + parent_data.get.power
return max_bat_discharge_power - abs(battery.data.get.power), True
return max_bat_discharge_power, True
else:
battery.data.get.fault_state = FaultStateLevel.ERROR.value
battery.data.get.fault_str = self.ERROR_CONFIG_MAX_AC_OUT
Expand All @@ -158,21 +158,22 @@ def _max_bat_power_hybrid_system(self, battery: Bat) -> float:
def _limit_bat_power_discharge(self, required_power):
available_power = 0
hybrid = False
for battery in data.data.bat_data.values():
try:
available_power_bat, hybrid_bat = self._max_bat_power_hybrid_system(battery)
if hybrid_bat:
hybrid = True
available_power += available_power_bat
except Exception:
log.exception(f"Fehler im Bat-Modul {battery.num}")
if hybrid:
if required_power > available_power:
log.debug(
f"Verbleibende Speicher-Leistung durch maximale Ausgangsleistung auf {available_power}W begrenzt.")
return min(required_power, available_power)
else:
return required_power
if required_power > 0:
# Nur wenn der Speicher entladen werden soll, fließt Leistung durch den WR.
for battery in data.data.bat_data.values():
try:
available_power_bat, hybrid_bat = self._max_bat_power_hybrid_system(battery)
if hybrid_bat:
hybrid = True
available_power += available_power_bat
except Exception:
log.exception(f"Fehler im Bat-Modul {battery.num}")
if hybrid:
if required_power > available_power:
log.debug(f"Verbleibende Speicher-Leistung durch maximale Ausgangsleistung auf {available_power}W"
" begrenzt.")
return min(required_power, available_power)
return required_power

def setup_bat(self):
""" prüft, ob mind ein Speicher vorhanden ist und berechnet die Summen-Topics.
Expand Down
2 changes: 1 addition & 1 deletion packages/control/bat_all_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def data_fixture() -> None:
pytest.param({"id": 6, "type": "counter", "children": [
{"id": 2, "type": "bat", "children": []}]}, -100, (150, False),
id="kein Hybrid-System, Speicher wird entladen"),
pytest.param({"id": 1, "type": "inverter", "children": []}, 600, (200, True),
pytest.param({"id": 1, "type": "inverter", "children": []}, 600, (800, True),
id="maximale Entladeleistung des WR"),
])
def test_max_bat_power_hybrid_system(parent, bat_power, expected_power, data_fixture, monkeypatch):
Expand Down