From 6e7a8a10463ab5c106a19dda510ee508995e2548 Mon Sep 17 00:00:00 2001 From: bemobolo Date: Thu, 5 Oct 2023 11:26:49 +0200 Subject: [PATCH 1/2] check if toggle/valve device in _is_device_active --- custom_components/smart_thermostat/climate.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/custom_components/smart_thermostat/climate.py b/custom_components/smart_thermostat/climate.py index 6a93a2c..570d267 100644 --- a/custom_components/smart_thermostat/climate.py +++ b/custom_components/smart_thermostat/climate.py @@ -964,11 +964,17 @@ async def _async_control_heating(self, time_func=None, calc_pid=False): @property def _is_device_active(self): - """If the toggleable device is currently active.""" - if self._heater_polarity_invert: - return self.hass.states.is_state(self.heater_or_cooler_entity, STATE_OFF) - return self.hass.states.is_state(self.heater_or_cooler_entity, STATE_ON) - + if self._pwm: + """If the toggleable device is currently active.""" + if self._heater_polarity_invert: + return self.hass.states.is_state(self.heater_or_cooler_entity, STATE_OFF) + return self.hass.states.is_state(self.heater_or_cooler_entity, STATE_ON) + else: + """If the valve device is currently active.""" + if self._heater_polarity_invert: + return float(self.hass.states.get(self.heater_or_cooler_entity).state) == 0 + return float(self.hass.states.get(self.heater_or_cooler_entity).state) > 0 + @property def supported_features(self): """Return the list of supported features.""" From b42c9eafe3be600caa9a2e00772bfc3ba3a4f074 Mon Sep 17 00:00:00 2001 From: bemobolo Date: Thu, 5 Oct 2023 15:29:02 +0200 Subject: [PATCH 2/2] removing useless invert check when pwm==0 in _is_device_active --- custom_components/smart_thermostat/climate.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/custom_components/smart_thermostat/climate.py b/custom_components/smart_thermostat/climate.py index 570d267..9a16e7e 100644 --- a/custom_components/smart_thermostat/climate.py +++ b/custom_components/smart_thermostat/climate.py @@ -971,8 +971,6 @@ def _is_device_active(self): return self.hass.states.is_state(self.heater_or_cooler_entity, STATE_ON) else: """If the valve device is currently active.""" - if self._heater_polarity_invert: - return float(self.hass.states.get(self.heater_or_cooler_entity).state) == 0 return float(self.hass.states.get(self.heater_or_cooler_entity).state) > 0 @property