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
7 changes: 5 additions & 2 deletions packages/control/bat_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class Config:
configured: bool = field(default=False, metadata={"topic": "config/configured"})
power_limit_mode: str = field(default=BatPowerLimitMode.NO_LIMIT.value,
metadata={"topic": "config/power_limit_mode"})
bat_control_permitted: bool = field(default=False, metadata={"topic": "config/bat_control_permitted"})


def config_factory() -> Config:
Expand Down Expand Up @@ -286,11 +287,13 @@ def set_power_limit_controllable(self):
self.data.get.power_limit_controllable = False

def get_power_limit(self):
if self.data.config.bat_control_permitted is False:
return
chargepoint_by_chagemodes = get_chargepoints_by_chargemodes(CONSIDERED_CHARGE_MODES_ADDITIONAL_CURRENT)
power_of_chargepoints_by_chagemodes = sum(
[cp.data.get.power for cp in chargepoint_by_chagemodes if cp.data.get.power is not None])
if (self.data.config.power_limit_mode != BatPowerLimitMode.NO_LIMIT.value
and len(chargepoint_by_chagemodes) > 0 and
if (self.data.config.power_limit_mode != BatPowerLimitMode.NO_LIMIT.value and
len(chargepoint_by_chagemodes) > 0 and
power_of_chargepoints_by_chagemodes > 0 and
self.data.get.power_limit_controllable and
# Nur wenn kein Überschuss im System ist, Speicherleistung begrenzen.
Expand Down
1 change: 1 addition & 0 deletions packages/control/bat_all_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ class PowerLimitParams:
@pytest.mark.parametrize("params", cases, ids=[c.name for c in cases])
def test_get_power_limit(params: PowerLimitParams, data_, monkeypatch):
b_all = BatAll()
b_all.data.config.bat_control_permitted = True
b_all.data.config.power_limit_mode = params.power_limit_mode
b_all.data.get.power_limit_controllable = params.power_limit_controllable
b_all.data.get.power = params.bat_power
Expand Down
3 changes: 2 additions & 1 deletion packages/helpermodules/setdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,8 @@ def process_bat_topic(self, msg: mqtt.MQTTMessage):
enthält Topic und Payload
"""
try:
if ("openWB/set/bat/config/configured" in msg.topic or
if ("openWB/set/bat/config/bat_control_permitted" in msg.topic or
"openWB/set/bat/config/configured" in msg.topic or
"openWB/set/bat/get/power_limit_controllable" in msg.topic or
"openWB/set/bat/set/regulate_up" in msg.topic):
self._validate_value(msg, bool)
Expand Down
14 changes: 13 additions & 1 deletion packages/helpermodules/update_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@

class UpdateConfig:

DATASTORE_VERSION = 86
DATASTORE_VERSION = 87

valid_topic = [
"^openWB/bat/config/bat_control_permitted$",
"^openWB/bat/config/configured$",
"^openWB/bat/config/power_limit_mode$",
"^openWB/bat/set/charging_power_left$",
Expand Down Expand Up @@ -505,6 +506,7 @@ class UpdateConfig:
"^openWB/system/version$",
]
default_topic = (
("openWB/bat/config/bat_control_permitted", False),
("openWB/bat/config/configured", False),
("openWB/bat/config/power_limit_mode", "no_limit"),
("openWB/bat/get/fault_state", 0),
Expand Down Expand Up @@ -2326,3 +2328,13 @@ def upgrade(topic: str, payload) -> None:
return {component_topic: config_payload}
self._loop_all_received_topics(upgrade)
self.__update_topic("openWB/system/datastore_version", 86)

def upgrade_datastore_86(self) -> None:
if "openWB/bat/config/bat_control_permitted" not in self.all_received_topics.keys():
self.__update_topic("openWB/bat/config/bat_control_permitted", False)
if decode_payload(self.all_received_topics["openWB/bat/get/power_limit_controllable"]) is True:
pub_system_message({}, "Bitte akzeptiere zunächst die "
"<a href=\"/openWB/web/settings/#/GeneralChargeConfig\">rechtlichen Hinweise</a> "
"für die Speichersteuerung. Die Speichersteuerung war bisher bereits verfügbar, ist"
" jedoch bis zum Akzeptieren standardmäßig deaktiviert.", MessageType.WARNING)
self.__update_topic("openWB/system/datastore_version", 87)