From f7c46aaeacef03a478906aca75feefd53174dc4f Mon Sep 17 00:00:00 2001 From: s0170071 Date: Sun, 20 Sep 2026 14:55:18 +0200 Subject: [PATCH] fix: Ladepunkte nutzen die Abschaltschwelle der Verbraucher calc_switch_off_threshold() liest fuer alle Lasten surplus.consumer.switch_off_threshold. surplus.vehicle.switch_off_threshold ist konfigurierbar, wird migriert und in der Debug-Ausgabe angezeigt, aber im Regelalgorithmus nirgends gelesen. Die Migration verschiebt den alten pv_charging/switch_off_threshold nach surplus/vehicle/switch_off_threshold. Damit regeln bestehende Anlagen seit dem Update mit dem neu angelegten Consumer-Default 0 statt mit dem konfigurierten Wert. --- packages/control/counter.py | 8 +++++++- packages/control/counter_test.py | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/control/counter.py b/packages/control/counter.py index 8736fc0150..10ca9ecfaa 100644 --- a/packages/control/counter.py +++ b/packages/control/counter.py @@ -500,6 +500,12 @@ def switch_off_check_timer(self, load: Load) -> None: except Exception: log.exception("Fehler im allgemeinen PV-Modul") + def _get_switch_off_threshold_by_load(self, load: Load) -> int: + if isinstance(load, Chargepoint): + return data.data.general_data.data.chargemode_config.surplus.vehicle.switch_off_threshold + else: + return data.data.general_data.data.chargemode_config.surplus.consumer.switch_off_threshold + def calc_switch_off_threshold(self, load: Load) -> float: surplus_config = data.data.general_data.data.chargemode_config.surplus control_parameter = load.data.control_parameter @@ -510,7 +516,7 @@ def calc_switch_off_threshold(self, load: Load) -> float: threshold = (-surplus_config.feed_in_yield + surplus_config.vehicle.switch_on_threshold*control_parameter.phases) else: - threshold = surplus_config.consumer.switch_off_threshold + threshold = self._get_switch_off_threshold_by_load(load) return threshold def calc_switch_off(self, load: Load) -> Tuple[float, float]: diff --git a/packages/control/counter_test.py b/packages/control/counter_test.py index c1bd1ff754..640b38fb85 100644 --- a/packages/control/counter_test.py +++ b/packages/control/counter_test.py @@ -199,6 +199,24 @@ def test_control_range(control_range, evu_power, expected_range_offset, general_ assert range_offset == expected_range_offset +@pytest.mark.parametrize("load_factory, expected", + [pytest.param(lambda: Chargepoint(0, None), -200, id="Ladepunkt"), + pytest.param(lambda: Consumer(0), -50, id="Verbraucher")]) +def test_calc_switch_off_threshold_by_load(load_factory, expected: float, general_data_fixture): + # setup + surplus_config = data.data.general_data.data.chargemode_config.surplus + surplus_config.feed_in_limit = False + surplus_config.vehicle.switch_off_threshold = -200 + surplus_config.consumer.switch_off_threshold = -50 + c = Counter(0) + + # execution + threshold = c.calc_switch_off_threshold(load_factory()) + + # evaluation + assert threshold == expected + + def test_reset_switch_on_off_ignores_stale_timestamp_without_delay_state(general_data_fixture, monkeypatch): # setup evu_counter = Counter(0)