Fixed setting a hold mode when away mode is on

This commit is contained in:
Steven Roebert
2022-01-03 10:23:09 +01:00
parent ad7a0d799d
commit 3de73ea8ef

View File

@@ -792,19 +792,21 @@ class MqttClimate(MqttEntity, ClimateEntity):
# 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 preset_mode == PRESET_AWAY:
if not self._away:
optimistic_update = await self._set_away_mode(True) or optimistic_update
if self._hold:
await self._set_hold_mode(None)
optimistic_update = optimistic_update or await self._set_away_mode(True)
optimistic_update = await self._set_hold_mode(None) or optimistic_update
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
)
if self._hold != hold_mode:
optimistic_update = await self._set_hold_mode(hold_mode) or optimistic_update
if self._away:
optimistic_update = await self._set_away_mode(False) or optimistic_update
if optimistic_update:
self.async_write_ha_state()