Issue #119 - Set preset target temperature not updating in ac mode

This commit is contained in:
Jean-Marc Collin
2023-10-15 12:22:15 +02:00
parent 7ac49d7864
commit e6ecd100f6
2 changed files with 16 additions and 9 deletions

View File

@@ -114,18 +114,22 @@ climate:
name: Underlying thermostat 4-1 name: Underlying thermostat 4-1
heater: input_boolean.fake_heater_4climate1 heater: input_boolean.fake_heater_4climate1
target_sensor: input_number.fake_temperature_sensor1 target_sensor: input_number.fake_temperature_sensor1
ac_mode: true
- platform: generic_thermostat - platform: generic_thermostat
name: Underlying thermostat 4-2 name: Underlying thermostat 4-2
heater: input_boolean.fake_heater_4climate2 heater: input_boolean.fake_heater_4climate2
target_sensor: input_number.fake_temperature_sensor1 target_sensor: input_number.fake_temperature_sensor1
ac_mode: true
- platform: generic_thermostat - platform: generic_thermostat
name: Underlying thermostat 4-3 name: Underlying thermostat 4-3
heater: input_boolean.fake_heater_4climate3 heater: input_boolean.fake_heater_4climate3
target_sensor: input_number.fake_temperature_sensor1 target_sensor: input_number.fake_temperature_sensor1
ac_mode: true
- platform: generic_thermostat - platform: generic_thermostat
name: Underlying thermostat 4-4 name: Underlying thermostat 4-4
heater: input_boolean.fake_heater_4climate4 heater: input_boolean.fake_heater_4climate4
target_sensor: input_number.fake_temperature_sensor1 target_sensor: input_number.fake_temperature_sensor1
ac_mode: true
- platform: generic_thermostat - platform: generic_thermostat
name: Underlying thermostat9 name: Underlying thermostat9
heater: input_boolean.fake_heater_switch3 heater: input_boolean.fake_heater_switch3

View File

@@ -2338,14 +2338,11 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
"""A utility function to force the calculation of a the algo and """A utility function to force the calculation of a the algo and
update the custom attributes and write the state update the custom attributes and write the state
""" """
if self._is_over_climate:
self.update_custom_attributes()
return
_LOGGER.debug("%s - recalculate all", self) _LOGGER.debug("%s - recalculate all", self)
self._prop_algorithm.calculate( if not self._is_over_climate:
self._target_temp, self._cur_temp, self._cur_ext_temp self._prop_algorithm.calculate(
) self._target_temp, self._cur_temp, self._cur_ext_temp
)
self.update_custom_attributes() self.update_custom_attributes()
self.async_write_ha_state() self.async_write_ha_state()
@@ -2420,10 +2417,15 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
.astimezone(self._current_tz) .astimezone(self._current_tz)
.isoformat(), .isoformat(),
"timezone": str(self._current_tz), "timezone": str(self._current_tz),
"window_sensor_entity_id": self._window_sensor_entity_id,
"window_delay_sec": self._window_delay_sec, "window_delay_sec": self._window_delay_sec,
"window_auto_open_threshold": self._window_auto_open_threshold, "window_auto_open_threshold": self._window_auto_open_threshold,
"window_auto_close_threshold": self._window_auto_close_threshold, "window_auto_close_threshold": self._window_auto_close_threshold,
"window_auto_max_duration": self._window_auto_max_duration, "window_auto_max_duration": self._window_auto_max_duration,
"motion_sensor_entity_id": self._motion_sensor_entity_id,
"presence_sensor_entity_id": self._presence_sensor_entity_id,
"power_sensor_entity_id": self._power_sensor_entity_id,
"max_power_sensor_entity_id": self._max_power_sensor_entity_id,
} }
if self._is_over_climate: if self._is_over_climate:
self._attr_extra_state_attributes["underlying_climate_0"] = self._underlyings[ self._attr_extra_state_attributes["underlying_climate_0"] = self._underlyings[
@@ -2527,8 +2529,9 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
) )
# If the changed preset is active, change the current temperature # If the changed preset is active, change the current temperature
if self._attr_preset_mode == preset: # Issue #119 - reload new preset temperature also in ac mode
await self._async_set_preset_mode_internal(preset, force=True) if preset.startswith(self._attr_preset_mode):
await self._async_set_preset_mode_internal(preset.rstrip(PRESET_AC_SUFFIX), force=True)
await self._async_control_heating(force=True) await self._async_control_heating(force=True)
async def service_set_security(self, delay_min, min_on_percent, default_on_percent): async def service_set_security(self, delay_min, min_on_percent, default_on_percent):