Skip to content

Commit

Permalink
Check for correct enum values
Browse files Browse the repository at this point in the history
  • Loading branch information
eifinger committed Jul 8, 2023
1 parent d9e7b23 commit 8bd7967
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions homeassistant/components/broadlink/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,15 @@ async def async_added_to_hass(self) -> None:
async def _async_restore_state(self) -> None:
"""Restore latest state."""
if (old_state := await self.async_get_last_state()) is not None:
if old_state.state is not None:
self._attr_hvac_mode = old_state.state
if old_state.state in [mode.value for mode in HVACMode]:
self._attr_hvac_mode = HVACMode(old_state.state)
if old_state.attributes is not None:
if old_state.attributes.get(ATTR_HVAC_ACTION) is not None:
self._attr_hvac_action = old_state.attributes[ATTR_HVAC_ACTION]
if old_state.attributes.get(ATTR_HVAC_ACTION) in [
action.value for action in HVACAction
]:
self._attr_hvac_action = HVACAction(
old_state.attributes[ATTR_HVAC_ACTION]
)
if old_state.attributes.get(ATTR_TEMPERATURE) is not None:
self._attr_target_temperature = float(
old_state.attributes[ATTR_TEMPERATURE]
Expand Down

0 comments on commit 8bd7967

Please sign in to comment.