Skip to content

Commit

Permalink
FIX power float conversion when state unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Marc Collin committed Jan 8, 2023
1 parent 89984b3 commit 018343e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions custom_components/versatile_thermostat/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,8 +989,10 @@ async def _async_power_changed(self, event):
_LOGGER.debug(event)
new_state = event.data.get("new_state")
old_state = event.data.get("old_state")
if new_state is None or (
old_state is not None and new_state.state == old_state.state
if (
new_state is None
or new_state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN)
or (old_state is not None and new_state.state == old_state.state)
):
return

Expand All @@ -1010,8 +1012,10 @@ async def _async_max_power_changed(self, event):
_LOGGER.debug(event)
new_state = event.data.get("new_state")
old_state = event.data.get("old_state")
if new_state is None or (
old_state is not None and new_state.state == old_state.state
if (
new_state is None
or new_state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN)
or (old_state is not None and new_state.state == old_state.state)
):
return

Expand Down

0 comments on commit 018343e

Please sign in to comment.