Skip to content

Commit 9eada58

Browse files
committed
Try to fix detection if device is active with valve and light entities.
1 parent aca5f06 commit 9eada58

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

custom_components/smart_thermostat/climate.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -934,9 +934,18 @@ def _is_device_active(self):
934934
in self.heater_or_cooler_entity])
935935
else:
936936
"""If the valve device is currently active."""
937+
is_active = False
937938
try: # do not throw an error if the state is not yet available on startup
938-
return any([float(self.hass.states.get(heater_or_cooler_entity).state) > 0 for heater_or_cooler_entity
939-
in self.heater_or_cooler_entity])
939+
for heater_or_cooler_entity in self.heater_or_cooler_entity:
940+
state = self.hass.states.get(heater_or_cooler_entity).state
941+
try:
942+
value = float(state)
943+
if value > 0:
944+
is_active = True
945+
except ValueError:
946+
if state in ['on', 'open']:
947+
is_active = True
948+
return is_active
940949
except:
941950
return False
942951

0 commit comments

Comments
 (0)