Skip to content

Instantly share code, notes, and snippets.

@fearoffish
Created April 3, 2016 22:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fearoffish/9a5274ed8c1e48c75eeb67058729a087 to your computer and use it in GitHub Desktop.
Save fearoffish/9a5274ed8c1e48c75eeb67058729a087 to your computer and use it in GitHub Desktop.
Home Assistant Config Example - Motion detected lights (for 10 mins) with a 'manual mode' toggle that stops them turning off
# Input boolean for deactivating the script that turns off the lights after no movement for 10 mins
input_boolean:
living_room_light_manual_mode:
name: Living Room Lights Manual Mode
initial: off
# Automation: When there is motion in the living room, activate a script to turn on the lights (shown next)
- alias: Turn on living room lights when there is movement
trigger:
- platform: state
entity_id: binary_sensor.living_room_sensor_12
to: 'on'
action:
service: homeassistant.turn_on
entity_id: script.timed_living_room_light
# Script: Turn on the lights, and activate a timer that will fire an event after ten minutes
# The event is a custom string that we will use in the next automation
living_room_light_timer:
alias: "Turn off living room light after 10 minutes"
sequence:
- delay:
minutes: 10
- event: living_room_motion.false
# Automation: Pick up the event 'living_room_motion.false'
# Unless the input boolean for manual living room lights mode is on
# Turn off the lights
- alias: "Turn off the living room light if manual mode is not on"
trigger:
platform: event
event_type: living_room_motion.false
condition:
- platform: state
entity_id: input_boolean.living_room_light_manual_mode
state: 'off'
action:
service: homeassistant.turn_off
entity_id: light.living_room
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment