Add force if target temperature is changed manually

This commit is contained in:
Jean-Marc Collin
2023-10-31 10:17:54 +00:00
parent fe85ead916
commit 3c497d24fb
2 changed files with 7 additions and 7 deletions

View File

@@ -87,9 +87,9 @@ class ThermostatOverClimate(BaseThermostat):
await super()._async_internal_set_temperature(temperature)
self._regulation_algo.set_target_temp(self.target_temperature)
await self._send_regulated_temperature()
await self._send_regulated_temperature(force=True)
async def _send_regulated_temperature(self):
async def _send_regulated_temperature(self, force=False):
""" Sends the regulated temperature to all underlying """
if not self._regulated_target_temp:
self._regulated_target_temp = self.target_temperature
@@ -99,13 +99,13 @@ class ThermostatOverClimate(BaseThermostat):
self._auto_regulation_dtemp)
dtemp = new_regulated_temp - self._regulated_target_temp
if abs(dtemp) < self._auto_regulation_dtemp:
if not force and abs(dtemp) < self._auto_regulation_dtemp:
_LOGGER.debug("%s - dtemp (%.1f) is < %.1f -> forget the regulation send", self, dtemp, self._auto_regulation_dtemp)
return
now:datetime = NowClass.get_now(self._hass)
period = float((now - self._last_regulation_change).total_seconds()) / 60.
if period < self._auto_regulation_period_min:
if not force and period < self._auto_regulation_period_min:
_LOGGER.debug("%s - period (%.1f) is < %.0f -> forget the regulation send", self, period, self._auto_regulation_period_min)
return

View File

@@ -82,7 +82,7 @@ async def test_over_climate_regulation(hass: HomeAssistant, skip_hass_states_is_
assert entity.hvac_mode is HVACMode.HEAT
assert entity.hvac_action == HVACAction.OFF
assert entity.regulated_target_temp is entity.min_temp
assert entity.regulated_target_temp == entity.min_temp
await send_temperature_change_event(entity, 15, event_timestamp)
await send_ext_temperature_change_event(entity, 10, event_timestamp)
@@ -296,8 +296,8 @@ async def test_over_climate_regulation_limitations(hass: HomeAssistant, skip_has
fake_underlying_climate.set_hvac_action(HVACAction.HEATING) # simulate under heating
assert entity.hvac_action == HVACAction.HEATING
# the regulated temperature should be unchanged
assert entity.regulated_target_temp == 15
# the regulated temperature will change because when we set temp manually it is forced
assert entity.regulated_target_temp == 20.
# set manual target temp (at now - 18) -> the regulation should be taken into account
event_timestamp = now - timedelta(minutes=18)