Change algo to take slop into account
This commit is contained in:
@@ -144,10 +144,15 @@ class AutoStartStopDetectionAlgorithm:
|
|||||||
|
|
||||||
self._last_calculation_date = now
|
self._last_calculation_date = now
|
||||||
|
|
||||||
|
temp_at_dt = current_temp + slope_min * self._dt
|
||||||
|
|
||||||
# Check to turn-off
|
# Check to turn-off
|
||||||
# When we hit the threshold, that mean we can turn off
|
# When we hit the threshold, that mean we can turn off
|
||||||
if hvac_mode == HVACMode.HEAT:
|
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(
|
_LOGGER.info(
|
||||||
"%s - We need to stop, there is no need for heating for a long time.",
|
"%s - We need to stop, there is no need for heating for a long time.",
|
||||||
self,
|
self,
|
||||||
@@ -158,7 +163,10 @@ class AutoStartStopDetectionAlgorithm:
|
|||||||
return AUTO_START_STOP_ACTION_NOTHING
|
return AUTO_START_STOP_ACTION_NOTHING
|
||||||
|
|
||||||
if hvac_mode == HVACMode.COOL:
|
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(
|
_LOGGER.info(
|
||||||
"%s - We need to stop, there is no need for cooling for a long time.",
|
"%s - We need to stop, there is no need for cooling for a long time.",
|
||||||
self,
|
self,
|
||||||
@@ -173,7 +181,7 @@ class AutoStartStopDetectionAlgorithm:
|
|||||||
|
|
||||||
# check to turn on
|
# check to turn on
|
||||||
if hvac_mode == HVACMode.OFF and saved_hvac_mode == HVACMode.HEAT:
|
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(
|
_LOGGER.info(
|
||||||
"%s - We need to start, because it will be time to heat",
|
"%s - We need to start, because it will be time to heat",
|
||||||
self,
|
self,
|
||||||
@@ -187,7 +195,7 @@ class AutoStartStopDetectionAlgorithm:
|
|||||||
return AUTO_START_STOP_ACTION_NOTHING
|
return AUTO_START_STOP_ACTION_NOTHING
|
||||||
|
|
||||||
if hvac_mode == HVACMode.OFF and saved_hvac_mode == HVACMode.COOL:
|
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(
|
_LOGGER.info(
|
||||||
"%s - We need to start, because it will be time to cool",
|
"%s - We need to start, because it will be time to cool",
|
||||||
self,
|
self,
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ from homeassistant.core import HomeAssistant, callback
|
|||||||
|
|
||||||
from homeassistant.components.switch import SwitchEntity
|
from homeassistant.components.switch import SwitchEntity
|
||||||
|
|
||||||
from homeassistant.helpers.device_registry import DeviceInfo, DeviceEntryType
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.helpers.restore_state import RestoreEntity
|
from homeassistant.helpers.restore_state import RestoreEntity
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|||||||
@@ -987,6 +987,7 @@ class ThermostatOverClimate(BaseThermostat[UnderlyingClimate]):
|
|||||||
def set_auto_start_stop_enable(self, is_enabled: bool):
|
def set_auto_start_stop_enable(self, is_enabled: bool):
|
||||||
"""Enable/Disable the auto-start/stop feature"""
|
"""Enable/Disable the auto-start/stop feature"""
|
||||||
self._is_auto_start_stop_enabled = is_enabled
|
self._is_auto_start_stop_enabled = is_enabled
|
||||||
|
self.update_custom_attributes()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def auto_regulation_mode(self) -> str | None:
|
def auto_regulation_mode(self) -> str | None:
|
||||||
|
|||||||
Reference in New Issue
Block a user