Skip to content
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
5 changes: 3 additions & 2 deletions packages/modules/devices/fronius/fronius_http_api/bat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
from typing import Any, Dict, Optional, TypedDict

from modules.common.abstract_device import AbstractBat
from modules.common.abstract_device import AbstractBat, SetPoint
from modules.common.component_state import BatState
from modules.common.component_type import ComponentDescriptor
from modules.common.fault_state import ComponentInfo, FaultState
Expand Down Expand Up @@ -72,7 +72,8 @@ def update(self, powerflow_response: Dict) -> None:
)
self.store.set(bat_state)

def set_power_limit(self, power_limit: Optional[int]) -> None:
def set_power_limit(self, setpoint: SetPoint) -> None:
power_limit = setpoint.power_limit
username = self.component_config.configuration.username
password = self.component_config.configuration.password
if username is None or password is None:
Expand Down
7 changes: 4 additions & 3 deletions packages/modules/devices/fronius/fronius_http_api/bat_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest

from control.bat import Set
from dataclass_utils import dataclass_from_dict
from modules.common.store._api import LoggingValueStore
from modules.conftest import SAMPLE_IP
Expand Down Expand Up @@ -88,7 +89,7 @@ def test_set_power_limit_without_credentials_does_not_connect(monkeypatch):
FroniusConfiguration, device_config), device_id=0)
battery.initialize()

battery.set_power_limit(0)
battery.set_power_limit(Set(power_limit=0))

mock_fronius_wr.assert_not_called()

Expand All @@ -113,7 +114,7 @@ def test_set_power_limit_with_credentials(monkeypatch, power_limit, expected_cal
FroniusConfiguration, device_config), device_id=0)
battery.initialize()

battery.set_power_limit(power_limit)
battery.set_power_limit(Set(power_limit=power_limit))

mock_fronius_wr.assert_called_once_with({
'address': SAMPLE_IP,
Expand All @@ -127,7 +128,7 @@ def test_set_power_limit_with_credentials(monkeypatch, power_limit, expected_cal
# Self-regulation/Stop dürfen dabei nicht erneut angestoßen werden, sobald der Modus schon aktiv
# ist; Force-Charge/-Discharge werden hingegen bei jedem Aufruf erneut gesetzt, da sich die
# gewünschte Lade-/Entladeleistung geändert haben könnte.
battery.set_power_limit(power_limit)
battery.set_power_limit(Set(power_limit=power_limit))
mock_fronius_wr.assert_called_once()
expected_count = 2 if repeats_call else 1
assert getattr(mock_bat_api, expected_call).call_count == expected_count
Expand Down
5 changes: 3 additions & 2 deletions packages/modules/devices/fronius/fronius_sunspec/bat.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Any, Optional, TypedDict

from modules.common import modbus
from modules.common.abstract_device import AbstractBat
from modules.common.abstract_device import AbstractBat, SetPoint
from modules.common.component_state import BatState
from modules.common.component_type import ComponentDescriptor, ComponentType
from modules.common.fault_state import ComponentInfo, FaultState
Expand Down Expand Up @@ -66,7 +66,8 @@ def update(self) -> None:
self.peak_filter.check_values(power)
self.store.set(BatState(power=power, soc=soc))

def set_power_limit(self, power_limit: Optional[int]) -> None:
def set_power_limit(self, setpoint: SetPoint) -> None:
power_limit = setpoint.power_limit
# Nicht an echter Fronius-Hardware verifiziert -- vor Produktiveinsatz an einem realen
# Gerät testen.
unit = 1
Expand Down
Loading