Skip to content

Instantly share code, notes, and snippets.

@felschr
Last active December 31, 2023 13:44
Show Gist options
  • Save felschr/d9864e8f8a892ac9157942810abc8c21 to your computer and use it in GitHub Desktop.
Save felschr/d9864e8f8a892ac9157942810abc8c21 to your computer and use it in GitHub Desktop.
Home Assistant Blueprint - Presence-activated Light
blueprint:
name: Presence-activated Light
description: Turn on a light when presence is detected.
domain: automation
source_url: https://gist.github.com/felschr/d9864e8f8a892ac9157942810abc8c21
author: felschr
input:
presence_entity:
name: Presence Sensor
selector:
entity:
filter:
device_class: occupancy
domain: binary_sensor
light_target:
name: Light
selector:
target:
entity:
domain: light
no_presence_wait:
name: Wait time
description: Time to leave the light on after presence is no longer detected.
default: 0
selector:
number:
min: 0
max: 3600
unit_of_measurement: seconds
# If presence is detected within the delay,
# we restart the script.
mode: restart
max_exceeded: silent
trigger:
platform: state
entity_id: !input presence_entity
from: "off"
to: "on"
action:
- alias: "Turn on the light"
service: light.turn_on
target: !input light_target
- alias: "Wait until there is no presence from device"
wait_for_trigger:
platform: state
entity_id: !input presence_entity
from: "on"
to: "off"
- alias: "Wait the number of seconds that has been set"
delay: !input no_presence_wait
- alias: "Turn off the light"
service: light.turn_off
target: !input light_target
@felschr
Copy link
Author

felschr commented Dec 31, 2023

This is the same as Home Assistant's integrated Motion-activated Light blueprint except that it allows selecting occupancy sensors instead of motion sensors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment