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 # Track if we should optimistic update the state
optimistic_update = False optimistic_update = False
if self._away: if preset_mode == PRESET_AWAY:
optimistic_update = optimistic_update or await self._set_away_mode(False) if not self._away:
elif preset_mode == PRESET_AWAY: optimistic_update = await self._set_away_mode(True) or optimistic_update
if self._hold: if self._hold:
await self._set_hold_mode(None) optimistic_update = await self._set_hold_mode(None) or optimistic_update
optimistic_update = optimistic_update or await self._set_away_mode(True)
else: else:
hold_mode = preset_mode hold_mode = preset_mode
if preset_mode == PRESET_NONE: if preset_mode == PRESET_NONE:
hold_mode = None hold_mode = None
optimistic_update = optimistic_update or await self._set_hold_mode( if self._hold != hold_mode:
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: if optimistic_update:
self.async_write_ha_state() self.async_write_ha_state()