Skip to content

Commit

Permalink
Try to fix detection if device is active with valve and light entities.
Browse files Browse the repository at this point in the history
  • Loading branch information
ScratMan committed Nov 17, 2024
1 parent aca5f06 commit 9eada58
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions custom_components/smart_thermostat/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -934,9 +934,18 @@ def _is_device_active(self):
in self.heater_or_cooler_entity])
else:
"""If the valve device is currently active."""
is_active = False
try: # do not throw an error if the state is not yet available on startup
return any([float(self.hass.states.get(heater_or_cooler_entity).state) > 0 for heater_or_cooler_entity
in self.heater_or_cooler_entity])
for heater_or_cooler_entity in self.heater_or_cooler_entity:
state = self.hass.states.get(heater_or_cooler_entity).state
try:
value = float(state)
if value > 0:
is_active = True
except ValueError:
if state in ['on', 'open']:
is_active = True
return is_active
except:
return False

Expand Down

0 comments on commit 9eada58

Please sign in to comment.