diff --git a/custom_components/versatile_thermostat/auto_start_stop_algorithm.py b/custom_components/versatile_thermostat/auto_start_stop_algorithm.py index 749c00b..7ec35ba 100644 --- a/custom_components/versatile_thermostat/auto_start_stop_algorithm.py +++ b/custom_components/versatile_thermostat/auto_start_stop_algorithm.py @@ -144,10 +144,15 @@ class AutoStartStopDetectionAlgorithm: self._last_calculation_date = now + temp_at_dt = current_temp + slope_min * self._dt + # Check to turn-off # When we hit the threshold, that mean we can turn off if hvac_mode == HVACMode.HEAT: - if self._accumulated_error <= -self._error_threshold and slope_min >= 0: + if ( + self._accumulated_error <= -self._error_threshold + and temp_at_dt >= target_temp + ): _LOGGER.info( "%s - We need to stop, there is no need for heating for a long time.", self, @@ -158,7 +163,10 @@ class AutoStartStopDetectionAlgorithm: return AUTO_START_STOP_ACTION_NOTHING if hvac_mode == HVACMode.COOL: - if self._accumulated_error >= self._error_threshold and slope_min <= 0: + if ( + self._accumulated_error >= self._error_threshold + and temp_at_dt <= target_temp + ): _LOGGER.info( "%s - We need to stop, there is no need for cooling for a long time.", self, @@ -173,7 +181,7 @@ class AutoStartStopDetectionAlgorithm: # check to turn on if hvac_mode == HVACMode.OFF and saved_hvac_mode == HVACMode.HEAT: - if current_temp + slope_min * self._dt <= target_temp: + if temp_at_dt <= target_temp: _LOGGER.info( "%s - We need to start, because it will be time to heat", self, @@ -187,7 +195,7 @@ class AutoStartStopDetectionAlgorithm: return AUTO_START_STOP_ACTION_NOTHING if hvac_mode == HVACMode.OFF and saved_hvac_mode == HVACMode.COOL: - if current_temp + slope_min * self._dt >= target_temp: + if temp_at_dt >= target_temp: _LOGGER.info( "%s - We need to start, because it will be time to cool", self, diff --git a/custom_components/versatile_thermostat/switch.py b/custom_components/versatile_thermostat/switch.py index 7b8f617..204304f 100644 --- a/custom_components/versatile_thermostat/switch.py +++ b/custom_components/versatile_thermostat/switch.py @@ -8,7 +8,6 @@ from homeassistant.core import HomeAssistant, callback from homeassistant.components.switch import SwitchEntity -from homeassistant.helpers.device_registry import DeviceInfo, DeviceEntryType from homeassistant.config_entries import ConfigEntry from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.helpers.entity_platform import AddEntitiesCallback diff --git a/custom_components/versatile_thermostat/thermostat_climate.py b/custom_components/versatile_thermostat/thermostat_climate.py index 5e5ea59..d325d3f 100644 --- a/custom_components/versatile_thermostat/thermostat_climate.py +++ b/custom_components/versatile_thermostat/thermostat_climate.py @@ -987,6 +987,7 @@ class ThermostatOverClimate(BaseThermostat[UnderlyingClimate]): def set_auto_start_stop_enable(self, is_enabled: bool): """Enable/Disable the auto-start/stop feature""" self._is_auto_start_stop_enabled = is_enabled + self.update_custom_attributes() @property def auto_regulation_mode(self) -> str | None: