Allow calculation even if slope is None
This commit is contained in:
@@ -79,7 +79,7 @@ class AutoStartStopDetectionAlgorithm:
|
||||
saved_hvac_mode: HVACMode | None,
|
||||
target_temp: float,
|
||||
current_temp: float,
|
||||
slope_min: float,
|
||||
slope_min: float | None,
|
||||
now: datetime,
|
||||
) -> AUTO_START_STOP_ACTIONS:
|
||||
"""Calculate an eventual action to do depending of the value in parameter"""
|
||||
@@ -101,12 +101,7 @@ class AutoStartStopDetectionAlgorithm:
|
||||
now,
|
||||
)
|
||||
|
||||
if (
|
||||
hvac_mode is None
|
||||
or target_temp is None
|
||||
or current_temp is None
|
||||
or slope_min is None
|
||||
):
|
||||
if hvac_mode is None or target_temp is None or current_temp is None:
|
||||
_LOGGER.debug(
|
||||
"%s - No all mandatory parameters are set. Disable auto-start/stop",
|
||||
self,
|
||||
@@ -119,8 +114,8 @@ class AutoStartStopDetectionAlgorithm:
|
||||
# reduce the error considering the dt between the last measurement
|
||||
if self._last_calculation_date is not None:
|
||||
dtmin = (now - self._last_calculation_date).total_seconds() / CYCLE_SEC
|
||||
# ignore two calls too near (< 1 min)
|
||||
if dtmin <= 0.5:
|
||||
# ignore two calls too near (< 24 sec)
|
||||
if dtmin <= 0.2:
|
||||
_LOGGER.debug(
|
||||
"%s - new calculation of auto_start_stop (%s) is too near of the last one (%s). Forget it",
|
||||
self,
|
||||
|
||||
@@ -912,16 +912,16 @@ class ThermostatOverClimate(BaseThermostat[UnderlyingClimate]):
|
||||
ret = await super().async_control_heating(force, _)
|
||||
|
||||
# Check if we need to auto start/stop the Vtherm
|
||||
if (
|
||||
self.auto_start_stop_enable
|
||||
and self._window_auto_algo.last_slope is not None
|
||||
):
|
||||
if self.auto_start_stop_enable:
|
||||
slope = (
|
||||
self._window_auto_algo.last_slope or 0
|
||||
) / 60 # to have the slope in °/min
|
||||
action = self._auto_start_stop_algo.calculate_action(
|
||||
self.hvac_mode,
|
||||
self._saved_hvac_mode,
|
||||
self.target_temperature,
|
||||
self.current_temperature,
|
||||
self._window_auto_algo.last_slope / 60, # to have the slope in °/min
|
||||
slope,
|
||||
self.now,
|
||||
)
|
||||
_LOGGER.debug("%s - auto_start_stop action is %s", self, action)
|
||||
@@ -943,7 +943,7 @@ class ThermostatOverClimate(BaseThermostat[UnderlyingClimate]):
|
||||
"saved_hvac_mode": self._saved_hvac_mode,
|
||||
"target_temperature": self.target_temperature,
|
||||
"current_temperature": self.current_temperature,
|
||||
"temperature_slope": self._window_auto_algo.last_slope,
|
||||
"temperature_slope": slope,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -966,7 +966,7 @@ class ThermostatOverClimate(BaseThermostat[UnderlyingClimate]):
|
||||
"saved_hvac_mode": self._saved_hvac_mode,
|
||||
"target_temperature": self.target_temperature,
|
||||
"current_temperature": self.current_temperature,
|
||||
"temperature_slope": self._window_auto_algo.last_slope,
|
||||
"temperature_slope": slope,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user