Last active
December 31, 2023 13:44
-
-
Save felschr/d9864e8f8a892ac9157942810abc8c21 to your computer and use it in GitHub Desktop.
Home Assistant Blueprint - Presence-activated Light
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is the same as Home Assistant's integrated Motion-activated Light blueprint except that it allows selecting occupancy sensors instead of motion sensors.