mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Light trigger now looks if the target light group is on to turn on lights instead of all lights.
This commit is contained in:
parent
5acf372d15
commit
478d4ad93a
@ -86,7 +86,7 @@ def setup(bus, statemachine, light_group=None):
|
||||
|
||||
def handle_device_state_change(category, old_state, new_state):
|
||||
""" Function to handle tracked device state changes. """
|
||||
lights_are_on = light.is_on(statemachine)
|
||||
lights_are_on = group.is_on(statemachine, light_group)
|
||||
|
||||
light_needed = not (lights_are_on or sun.is_up(statemachine))
|
||||
|
||||
|
@ -30,6 +30,23 @@ def _get_group_type(state):
|
||||
return None
|
||||
|
||||
|
||||
def is_on(statemachine, group):
|
||||
""" Returns if the group state is in its ON-state. """
|
||||
state = statemachine.get_state(group)
|
||||
|
||||
if state:
|
||||
group_type = _get_group_type(state['state'])
|
||||
|
||||
if group_type:
|
||||
group_on = _GROUP_TYPES[group_type][0]
|
||||
|
||||
return state['state'] == group_on
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def get_categories(statemachine, group_name):
|
||||
""" Get the categories that make up this group. """
|
||||
state = statemachine.get_state(STATE_CATEGORY_FORMAT.format(group_name))
|
||||
|
Loading…
x
Reference in New Issue
Block a user