Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 343596fb39 | |||
| 7dbdcf0ee4 |
@@ -1055,6 +1055,7 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
||||
if preset_mode == self._attr_preset_mode and not force:
|
||||
# I don't think we need to call async_write_ha_state if we didn't change the state
|
||||
return
|
||||
old_preset_mode = self._attr_preset_mode
|
||||
if preset_mode == PRESET_NONE:
|
||||
self._attr_preset_mode = PRESET_NONE
|
||||
if self._saved_target_temp:
|
||||
@@ -1070,15 +1071,18 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
||||
self.find_preset_temp(preset_mode)
|
||||
)
|
||||
|
||||
self.reset_last_temperature_time()
|
||||
self.reset_last_temperature_time(old_preset_mode)
|
||||
|
||||
self.save_preset_mode()
|
||||
self.recalculate()
|
||||
self.send_event(EventType.PRESET_EVENT, {"preset": self._attr_preset_mode})
|
||||
|
||||
def reset_last_temperature_time(self):
|
||||
def reset_last_temperature_time(self, old_preset_mode=None):
|
||||
"""Reset to now the last temperature time if conditions are satisfied"""
|
||||
if self._attr_preset_mode not in HIDDEN_PRESETS:
|
||||
if (
|
||||
self._attr_preset_mode not in HIDDEN_PRESETS
|
||||
and old_preset_mode not in HIDDEN_PRESETS
|
||||
):
|
||||
self._last_temperature_mesure = (
|
||||
self._last_ext_temperature_mesure
|
||||
) = datetime.now()
|
||||
@@ -1191,7 +1195,7 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
||||
async def _async_temperature_changed(self, event):
|
||||
"""Handle temperature changes."""
|
||||
new_state = event.data.get("new_state")
|
||||
_LOGGER.info(
|
||||
_LOGGER.debug(
|
||||
"%s - Temperature changed. Event.new_state is %s",
|
||||
self,
|
||||
new_state,
|
||||
@@ -1206,7 +1210,7 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
||||
async def _async_ext_temperature_changed(self, event):
|
||||
"""Handle external temperature changes."""
|
||||
new_state = event.data.get("new_state")
|
||||
_LOGGER.info(
|
||||
_LOGGER.debug(
|
||||
"%s - external Temperature changed. Event.new_state is %s",
|
||||
self,
|
||||
new_state,
|
||||
@@ -1693,6 +1697,8 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
||||
now - self._last_ext_temperature_mesure
|
||||
).total_seconds() / 60.0
|
||||
|
||||
mode_cond = self._hvac_mode != HVACMode.OFF
|
||||
|
||||
temp_cond: bool = (
|
||||
delta_temp > self._security_delay_min
|
||||
or delta_ext_temp > self._security_delay_min
|
||||
@@ -1709,7 +1715,7 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
||||
)
|
||||
|
||||
ret = False
|
||||
if temp_cond and climate_cond:
|
||||
if mode_cond and temp_cond and climate_cond:
|
||||
if not self._security_state:
|
||||
_LOGGER.warning(
|
||||
"%s - No temperature received for more than %.1f minutes (dt=%.1f, dext=%.1f) and underlying climate is %s. Set it into security mode",
|
||||
@@ -1722,16 +1728,17 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
||||
ret = True
|
||||
|
||||
_LOGGER.debug(
|
||||
"%s - checking security delta_temp=%.1f delta_ext_temp=%.1f temp_cond=%s climate_cond=%s switch_cond=%s",
|
||||
"%s - checking security delta_temp=%.1f delta_ext_temp=%.1f mod_cond=%s temp_cond=%s climate_cond=%s switch_cond=%s",
|
||||
self,
|
||||
delta_temp,
|
||||
delta_ext_temp,
|
||||
mode_cond,
|
||||
temp_cond,
|
||||
climate_cond,
|
||||
switch_cond,
|
||||
)
|
||||
|
||||
if temp_cond and switch_cond:
|
||||
if mode_cond and temp_cond and switch_cond:
|
||||
if not self._security_state:
|
||||
_LOGGER.warning(
|
||||
"%s - No temperature received for more than %.1f minutes (dt=%.1f, dext=%.1f) and on_percent (%.2f) is over defined value (%.2f). Set it into security mode",
|
||||
@@ -1744,7 +1751,7 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
||||
)
|
||||
ret = True
|
||||
|
||||
if not self._security_state and temp_cond:
|
||||
if mode_cond and temp_cond and not self._security_state:
|
||||
self.send_event(
|
||||
EventType.TEMPERATURE_EVENT,
|
||||
{
|
||||
|
||||
@@ -228,5 +228,16 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"state_attributes": {
|
||||
"_": {
|
||||
"preset_mode": {
|
||||
"state": {
|
||||
"power": "Shedding",
|
||||
"security": "Security",
|
||||
"none": "Manual"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -228,5 +228,16 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"state_attributes": {
|
||||
"_": {
|
||||
"preset_mode": {
|
||||
"state": {
|
||||
"power": "Shedding",
|
||||
"security": "Security",
|
||||
"none": "Manual"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -228,5 +228,16 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"state_attributes": {
|
||||
"_": {
|
||||
"preset_mode": {
|
||||
"state": {
|
||||
"power": "Délestage",
|
||||
"security": "Sécurité",
|
||||
"none": "Manuel"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user