device_sun_light_trigger: added option to disable turning devices off when all people gone

This commit is contained in:
Paulus Schoutsen 2014-09-27 07:18:55 -07:00
parent 8ef3009cc7
commit 8db1b74a3c
2 changed files with 7 additions and 2 deletions

View File

@ -36,6 +36,8 @@ download_dir=downloads
light_group=group.living_room
# Optional: specify which light profile to use when turning lights on
light_profile=relax
# Optional: disable lights being turned off when everybody leaves the house
# disable_turn_off=1
# A comma seperated list of states that have to be tracked as a single group
# Grouped states should share the same type of states (ON/OFF or HOME/NOT_HOME)

View File

@ -27,6 +27,8 @@ CONF_LIGHT_GROUP = 'light_group'
def setup(hass, config):
""" Triggers to turn lights on or off based on device precense. """
disable_turn_off = 'disable_turn_off' in config[DOMAIN]
light_group = config[DOMAIN].get(CONF_LIGHT_GROUP,
light.GROUP_NAME_ALL_LIGHTS)
@ -143,10 +145,11 @@ def setup(hass, config):
# Did all devices leave the house?
elif (entity == device_tracker.ENTITY_ID_ALL_DEVICES and
new_state.state == components.STATE_NOT_HOME and lights_are_on):
new_state.state == components.STATE_NOT_HOME and lights_are_on
and not disable_turn_off):
logger.info(
"Everyone has left but there are devices on. Turning them off")
"Everyone has left but there are lights on. Turning them off")
light.turn_off(hass)