mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use hue_light reachable attribute to see if we can trust the on state.
This commit is contained in:
parent
b7811e31e3
commit
5acf372d15
@ -148,10 +148,16 @@ class HueLightControl(object):
|
|||||||
""" Returns if specified or all light are on. """
|
""" Returns if specified or all light are on. """
|
||||||
if not light_id:
|
if not light_id:
|
||||||
return any(
|
return any(
|
||||||
[True for light in self._light_map.values() if light.on])
|
True for light in self._light_map.values()
|
||||||
|
if self.is_light_on(light))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return self._bridge.get_light(self._convert_id(light_id), 'on')
|
state = self._bridge.get_light(self._convert_id(light_id))
|
||||||
|
|
||||||
|
try:
|
||||||
|
return state and state['reachable'] and state['state']['on']
|
||||||
|
except KeyError: # If reachable, state or on not exists in state.
|
||||||
|
return False
|
||||||
|
|
||||||
def turn_light_on(self, light_id=None, transition_seconds=None):
|
def turn_light_on(self, light_id=None, transition_seconds=None):
|
||||||
""" Turn the specified or all lights on. """
|
""" Turn the specified or all lights on. """
|
||||||
|
Loading…
x
Reference in New Issue
Block a user