diff --git a/homeassistant/components/device_sun_light_trigger.py b/homeassistant/components/device_sun_light_trigger.py index c2a69c5ae7e..453541080cd 100644 --- a/homeassistant/components/device_sun_light_trigger.py +++ b/homeassistant/components/device_sun_light_trigger.py @@ -30,12 +30,11 @@ def setup(bus, statemachine, light_group=None): return False - if not light_group: - light_group = light.GROUP_NAME_ALL_LIGHTS + light_group = light_group or light.GROUP_NAME_ALL_LIGHTS # Get the light IDs from the specified group light_ids = ha.filter_entity_ids( - group.get_entity_ids(statemachine, light_group), light.DOMAIN, True) + group.get_entity_ids(statemachine, light_group), light.DOMAIN) if not light_ids: logger.error("LightTrigger:No lights found to turn on ") diff --git a/homeassistant/components/light.py b/homeassistant/components/light.py index 75da3a5eb72..bcbb7f94d3d 100644 --- a/homeassistant/components/light.py +++ b/homeassistant/components/light.py @@ -23,20 +23,19 @@ ENTITY_ID_FORMAT = DOMAIN + ".{}" MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10) -def is_on(statemachine, light_id=None): +def is_on(statemachine, entity_id=None): """ Returns if the lights are on based on the statemachine. """ - entity_id = ENTITY_ID_FORMAT.format(light_id) if light_id \ - else ENTITY_ID_ALL_LIGHTS + entity_id = entity_id or ENTITY_ID_ALL_LIGHTS return statemachine.is_state(entity_id, ha.STATE_ON) -def turn_on(bus, light_id=None, transition_seconds=None): +def turn_on(bus, entity_id=None, transition_seconds=None): """ Turns all or specified light on. """ data = {} - if light_id: - data["light_id"] = light_id + if entity_id: + data["light_id"] = ha.split_entity_id(entity_id)[1] if transition_seconds: data["transition_seconds"] = transition_seconds @@ -44,12 +43,12 @@ def turn_on(bus, light_id=None, transition_seconds=None): bus.call_service(DOMAIN, ha.SERVICE_TURN_ON, data) -def turn_off(bus, light_id=None, transition_seconds=None): +def turn_off(bus, entity_id=None, transition_seconds=None): """ Turns all or specified light off. """ data = {} - if light_id: - data["light_id"] = light_id + if entity_id: + data["light_id"] = ha.split_entity_id(entity_id)[1] if transition_seconds: data["transition_seconds"] = transition_seconds