From ffd30434ffedd0226018240a25fae0b41e444b04 Mon Sep 17 00:00:00 2001 From: LKuemmel Date: Wed, 9 Sep 2026 11:44:16 +0200 Subject: [PATCH 1/2] fixes --- packages/control/consumer/consumer.py | 45 +++++++++++++--------- packages/control/consumer/consumer_test.py | 12 +++--- packages/helpermodules/setdata.py | 6 +-- 3 files changed, 35 insertions(+), 28 deletions(-) diff --git a/packages/control/consumer/consumer.py b/packages/control/consumer/consumer.py index ac49b70def..f0ceebf415 100644 --- a/packages/control/consumer/consumer.py +++ b/packages/control/consumer/consumer.py @@ -121,25 +121,28 @@ def get_parameter(self) -> Tuple[float, float, Optional[str], Optional[Chargemod submode = Chargemode.STOP mode = self.data.usage.chargemode message = None + wait_for_start_defined_chargemode = False if self.data.usage.chargemode == Chargemode.SCHEDULED_CHARGING: - required_current, tmp_message, submode = self.wait_for_start_handler(self.scheduled_charging) + required_current, tmp_message, submode, wait_for_start_defined_chargemode = self.wait_for_start_handler( + self.scheduled_charging) message = f"{tmp_message or ''}".strip() - if submode != Chargemode.INSTANT_CHARGING and self.data.usage.time_charging.active: - required_current, tmp_message, submode = self.time_charging() - # Info vom Zielladen erhalten - message = f"{message or ''} {tmp_message or ''}".strip() - if required_current == 0: - if self.data.usage.chargemode == Chargemode.INSTANT_CHARGING: - required_current, tmp_message, submode = self.instant_charging() - elif self.data.usage.chargemode == Chargemode.ECO_CHARGING: - required_current, tmp_message, submode = self.wait_for_start_handler(self.eco_charging) - elif self.data.usage.chargemode == Chargemode.PV_CHARGING: - required_current, tmp_message, submode = self.wait_for_start_handler(self.pv_charging) - else: - tmp_message = None - message = f"{message or ''} {tmp_message or ''}".strip() - if self.data.usage.chargemode == Chargemode.STOP: - required_current, message, submode = self.stop() + if wait_for_start_defined_chargemode is False: + if submode != Chargemode.INSTANT_CHARGING and self.data.usage.time_charging.active: + required_current, tmp_message, submode = self.time_charging() + # Info vom Zielladen erhalten + message = f"{message or ''} {tmp_message or ''}".strip() + if required_current == 0: + if self.data.usage.chargemode == Chargemode.INSTANT_CHARGING: + required_current, tmp_message, submode = self.instant_charging() + elif self.data.usage.chargemode == Chargemode.ECO_CHARGING: + required_current, tmp_message, submode, _ = self.wait_for_start_handler(self.eco_charging) + elif self.data.usage.chargemode == Chargemode.PV_CHARGING: + required_current, tmp_message, submode, _ = self.wait_for_start_handler(self.pv_charging) + else: + tmp_message = None + message = f"{message or ''} {tmp_message or ''}".strip() + if self.data.usage.chargemode == Chargemode.STOP: + required_current, message, submode = self.stop() return min_current, required_current, message, mode, submode def _parse_required_current_by_usage(self, required_current: float) -> float: @@ -401,7 +404,8 @@ def stop(self) -> Tuple[float, Optional[str], Chargemode]: def wait_for_start_handler( self, func: Callable[[], Tuple[float, Optional[str], Chargemode]] - ) -> Tuple[float, Optional[str], Chargemode]: + ) -> Tuple[float, Optional[str], Chargemode, bool]: + chargemode_defined_by_wait_for_start_handler = False if self.data.usage.wait_for_start_active: if self.data.set.wait_for_start_state == WaitForStartStates.WAIT_FOR_DEVICE_START: # mit Minimalstrom prüfen, damit Standby-Geräte nicht als laufend erkannt werden @@ -410,11 +414,13 @@ def wait_for_start_handler( required_current = 0 message = self.WAIT_FOR_STOPPED_DEVICE submode = Chargemode.STOP + chargemode_defined_by_wait_for_start_handler = True else: required_current = self._parse_required_current_by_usage( self._convert_power_to_current(self.data.config.max_power)) message = self.WAIT_FOR_DEVICE_START submode = Chargemode.INSTANT_CHARGING + chargemode_defined_by_wait_for_start_handler = True elif self.data.set.wait_for_start_state == WaitForStartStates.WAIT_FOR_STOPPED_DEVICE: # mit Minimalstrom prüfen, damit Standby-Geräte nicht als laufend erkannt werden if max(self.data.get.currents) < self.data.config.min_current: @@ -426,6 +432,7 @@ def wait_for_start_handler( required_current = 0 message = self.WAIT_FOR_STOPPED_DEVICE submode = Chargemode.STOP + chargemode_defined_by_wait_for_start_handler = True elif self.data.set.wait_for_start_state == WaitForStartStates.DEVICE_WAITING_FOR_START: # mit Minimalstrom prüfen, damit Standby-Geräte nicht als laufend erkannt werden if max(self.data.get.currents) > self.data.config.min_current: @@ -441,7 +448,7 @@ def wait_for_start_handler( f"Ungültiger wait_for_start_state {self.data.set.wait_for_start_state} für Verbraucher {self.num}") else: required_current, message, submode = func() - return required_current, message, submode + return required_current, message, submode, chargemode_defined_by_wait_for_start_handler def reset_wait_for_start(self): self.data.set.wait_for_start_state = WaitForStartStates.WAIT_FOR_DEVICE_START diff --git a/packages/control/consumer/consumer_test.py b/packages/control/consumer/consumer_test.py index 357ca48167..de86549ed2 100644 --- a/packages/control/consumer/consumer_test.py +++ b/packages/control/consumer/consumer_test.py @@ -61,7 +61,7 @@ def test_get_parameter_clears_previous_state_string_when_switch_interval_is_acti WaitForStartStates.WAIT_FOR_DEVICE_START, [0]*3, (11, "ok", Chargemode.PV_CHARGING), - (11, "ok", Chargemode.PV_CHARGING), + (11, "ok", Chargemode.PV_CHARGING, False), WaitForStartStates.WAIT_FOR_DEVICE_START, 1, id="wait-for-start-disabled-passthrough", @@ -71,7 +71,7 @@ def test_get_parameter_clears_previous_state_string_when_switch_interval_is_acti WaitForStartStates.WAIT_FOR_DEVICE_START, [10]*3, (9, "running", Chargemode.PV_CHARGING), - (0, Consumer.WAIT_FOR_STOPPED_DEVICE, Chargemode.STOP), + (0, Consumer.WAIT_FOR_STOPPED_DEVICE, Chargemode.STOP, True), WaitForStartStates.WAIT_FOR_STOPPED_DEVICE, 0, id="wait-for-device-start-charge-detected", @@ -81,7 +81,7 @@ def test_get_parameter_clears_previous_state_string_when_switch_interval_is_acti WaitForStartStates.WAIT_FOR_DEVICE_START, [0]*3, (9, "running", Chargemode.PV_CHARGING), - (10, Consumer.WAIT_FOR_DEVICE_START, Chargemode.INSTANT_CHARGING), + (10, Consumer.WAIT_FOR_DEVICE_START, Chargemode.INSTANT_CHARGING, True), WaitForStartStates.WAIT_FOR_DEVICE_START, 0, id="wait-for-device-start-no-charge", @@ -91,7 +91,7 @@ def test_get_parameter_clears_previous_state_string_when_switch_interval_is_acti WaitForStartStates.WAIT_FOR_STOPPED_DEVICE, [0]*3, (8, "pv ok", Chargemode.PV_CHARGING), - (8, f"{Consumer.DEVICE_WAITING_FOR_START} pv ok", Chargemode.PV_CHARGING), + (8, f"{Consumer.DEVICE_WAITING_FOR_START} pv ok", Chargemode.PV_CHARGING, False), WaitForStartStates.DEVICE_WAITING_FOR_START, 1, id="wait-for-stopped-device-started-waiting", @@ -101,7 +101,7 @@ def test_get_parameter_clears_previous_state_string_when_switch_interval_is_acti WaitForStartStates.DEVICE_WAITING_FOR_START, [10]*3, (7, "started", Chargemode.INSTANT_CHARGING), - (7, "started", Chargemode.INSTANT_CHARGING), + (7, "started", Chargemode.INSTANT_CHARGING, False), WaitForStartStates.START_SIGNAL_RECEIVED, 1, id="device-waiting-start-signal-received", @@ -111,7 +111,7 @@ def test_get_parameter_clears_previous_state_string_when_switch_interval_is_acti WaitForStartStates.START_SIGNAL_RECEIVED, [10]*3, (10, "continue", Chargemode.PV_CHARGING), - (10, "continue", Chargemode.PV_CHARGING), + (10, "continue", Chargemode.PV_CHARGING, False), WaitForStartStates.START_SIGNAL_RECEIVED, 1, id="start-signal-received-passthrough", diff --git a/packages/helpermodules/setdata.py b/packages/helpermodules/setdata.py index 88e48507f4..b1119b3ef8 100644 --- a/packages/helpermodules/setdata.py +++ b/packages/helpermodules/setdata.py @@ -781,11 +781,11 @@ def process_general_topic(self, msg: mqtt.MQTTMessage): "openWB/set/general/chargemode_config/surplus/vehicle/switch_on_threshold" in msg.topic or "openWB/set/general/chargemode_config/surplus/vehicle/switch_on_delay" in msg.topic or "openWB/set/general/chargemode_config/surplus/vehicle/switch_off_delay" in msg.topic or - "openWB/set/general/consumer/config/switch_on_delay" in msg.topic or - "openWB/set/general/consumer/config/switch_off_delay" in msg.topic): + "openWB/set/general/chargemode_config/surplus/consumer/switch_on_delay" in msg.topic or + "openWB/set/general/chargemode_config/surplus/consumer/switch_off_delay" in msg.topic): self._validate_value(msg, int, [(0, float("inf"))]) elif ("openWB/set/general/chargemode_config/surplus/vehicle/switch_off_threshold" in msg.topic or - "openWB/set/general/consumer/config/switch_off_threshold" in msg.topic): + "openWB/set/general/chargemode_config/surplus/consumer/switch_off_threshold" in msg.topic): self._validate_value(msg, float) elif "openWB/set/general/chargemode_config/surplus/vehicle/phase_switch_delay" in msg.topic: self._validate_value(msg, int, [(5, 180)]) From 30964cbc34e1fcac65dddb88535b5c24582a7be9 Mon Sep 17 00:00:00 2001 From: LKuemmel Date: Wed, 9 Sep 2026 11:49:01 +0200 Subject: [PATCH 2/2] type hint --- packages/control/consumer/consumer_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/control/consumer/consumer_test.py b/packages/control/consumer/consumer_test.py index de86549ed2..49f3a129cc 100644 --- a/packages/control/consumer/consumer_test.py +++ b/packages/control/consumer/consumer_test.py @@ -124,7 +124,7 @@ def test_wait_for_start_handler( state: WaitForStartStates, currents: List[float], func_result: Tuple[int, str, Optional[Chargemode]], - expected_result: Tuple[int, str, Optional[Chargemode]], + expected_result: Tuple[int, str, Optional[Chargemode], bool], expected_state: WaitForStartStates, func_calls: int, ):