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