Fix MQTT climate optimistic preset modes (#63463)
* Always publish when preset_mode is set
* Revert "Fixed isort error"
This reverts commit 1a3c5e6460
.
* isort
This commit is contained in:
parent
a672dc3437
commit
aa73e5bd72
2 changed files with 117 additions and 31 deletions
|
@ -794,25 +794,12 @@ class MqttClimate(MqttEntity, ClimateEntity):
|
|||
|
||||
async def async_set_preset_mode(self, preset_mode):
|
||||
"""Set a preset mode."""
|
||||
if preset_mode == self.preset_mode:
|
||||
return
|
||||
|
||||
# Track if we should optimistic update the state
|
||||
optimistic_update = False
|
||||
|
||||
if self._away:
|
||||
optimistic_update = optimistic_update or await self._set_away_mode(False)
|
||||
elif preset_mode == PRESET_AWAY:
|
||||
if self._hold:
|
||||
await self._set_hold_mode(None)
|
||||
optimistic_update = optimistic_update or await self._set_away_mode(True)
|
||||
else:
|
||||
hold_mode = preset_mode
|
||||
if preset_mode == PRESET_NONE:
|
||||
hold_mode = None
|
||||
optimistic_update = optimistic_update or await self._set_hold_mode(
|
||||
hold_mode
|
||||
)
|
||||
optimistic_update = await self._set_away_mode(preset_mode == PRESET_AWAY)
|
||||
hold_mode = preset_mode
|
||||
if preset_mode in [PRESET_NONE, PRESET_AWAY]:
|
||||
hold_mode = None
|
||||
optimistic_update = await self._set_hold_mode(hold_mode) or optimistic_update
|
||||
|
||||
if optimistic_update:
|
||||
self.async_write_ha_state()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue