Light trigger now looks if the target light group is on to turn on lights instead of all lights.

This commit is contained in:
Paulus Schoutsen 2014-01-12 11:29:30 -08:00
parent 5acf372d15
commit 478d4ad93a
2 changed files with 18 additions and 1 deletions

View File

@ -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))

View File

@ -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))