From 018343ec5352cb4163055af02ab75cb03e1326af Mon Sep 17 00:00:00 2001 From: Jean-Marc Collin Date: Sun, 8 Jan 2023 13:15:02 +0100 Subject: [PATCH] FIX power float conversion when state unknown --- custom_components/versatile_thermostat/climate.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/custom_components/versatile_thermostat/climate.py b/custom_components/versatile_thermostat/climate.py index 7f134a98..f342f468 100644 --- a/custom_components/versatile_thermostat/climate.py +++ b/custom_components/versatile_thermostat/climate.py @@ -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 @@ -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