From 328f5f7cb033c4e165e22ca23f1337289865a6d3 Mon Sep 17 00:00:00 2001 From: Jean-Marc Collin Date: Sat, 18 Nov 2023 18:08:33 +0000 Subject: [PATCH] Fix ema_temp unknown and remove slope smoothing --- .../versatile_thermostat/base_thermostat.py | 2 +- .../versatile_thermostat/open_window_algorithm.py | 9 +++++---- tests/test_multiple_switch.py | 2 ++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/custom_components/versatile_thermostat/base_thermostat.py b/custom_components/versatile_thermostat/base_thermostat.py index 92ecab8..b183dc8 100644 --- a/custom_components/versatile_thermostat/base_thermostat.py +++ b/custom_components/versatile_thermostat/base_thermostat.py @@ -253,7 +253,7 @@ class BaseThermostat(ClimateEntity, RestoreEntity): self._underlyings = [] - self._smooth_temp = None + self._ema_temp = None self._ema_algo = None self.post_init(entry_infos) diff --git a/custom_components/versatile_thermostat/open_window_algorithm.py b/custom_components/versatile_thermostat/open_window_algorithm.py index 1e61f20..e9d7304 100644 --- a/custom_components/versatile_thermostat/open_window_algorithm.py +++ b/custom_components/versatile_thermostat/open_window_algorithm.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long """ This file implements the Open Window by temperature algorithm This algo works the following way: - each time a new temperature is measured @@ -71,10 +72,10 @@ class WindowOpenDetectionAlgorithm: ) return lspe - if self._last_slope is None: - self._last_slope = new_slope - else: - self._last_slope = (0.5 * self._last_slope) + (0.5 * new_slope) + # if self._last_slope is None: + self._last_slope = round(new_slope, 4) + # else: + # self._last_slope = (0.5 * self._last_slope) + (0.5 * new_slope) self._last_datetime = datetime_measure self._last_temperature = temperature diff --git a/tests/test_multiple_switch.py b/tests/test_multiple_switch.py index 97f0f67..b9ff945 100644 --- a/tests/test_multiple_switch.py +++ b/tests/test_multiple_switch.py @@ -386,6 +386,7 @@ async def test_multiple_climates( CONF_THERMOSTAT_TYPE: CONF_THERMOSTAT_CLIMATE, CONF_TEMP_SENSOR: "sensor.mock_temp_sensor", CONF_EXTERNAL_TEMP_SENSOR: "sensor.mock_ext_temp_sensor", + CONF_CYCLE_MIN: 8, CONF_TEMP_MIN: 15, CONF_TEMP_MAX: 30, "eco_temp": 17, @@ -486,6 +487,7 @@ async def test_multiple_climates_underlying_changes( CONF_THERMOSTAT_TYPE: CONF_THERMOSTAT_CLIMATE, CONF_TEMP_SENSOR: "sensor.mock_temp_sensor", CONF_EXTERNAL_TEMP_SENSOR: "sensor.mock_ext_temp_sensor", + CONF_CYCLE_MIN: 8, CONF_TEMP_MIN: 15, CONF_TEMP_MAX: 30, "eco_temp": 17,