home-assistant-blueprints/presence_lights.yaml

109 lines
2.4 KiB
YAML

blueprint:
name: Presence lights
description: Lights management using presence sensor
domain: automation
source_url: https://git.thethomaas.net/TheThomaas/home-assistant-blueprints/raw/branch/main/presence_lights.yaml
input:
presence_binary:
name: Presence trigger
description: Trigger to turn on the lights
default: []
selector:
entity:
filter:
domain:
- binary_sensor
multiple: false
additional_conditions:
name: Additional conditions
description: Extra conditions
default: []
selector:
condition:
scene_name:
name: Scene name
description: Scene name - Must be unique
default: []
selector:
text:
time_delay:
name: Turn off delay
description: Delay until the lights turn off after no presence is detected
default: 1
selector:
number:
min: 0
max: 360
step: 1
unit_of_measurement: seconds
lights:
name: Lights
description: Lights to manage
default: []
selector:
entity:
filter:
domain:
- light
multiple: true
mode: restart
max_exceeded: silent
variables:
scene_name: !input scene_name
triggers:
- trigger: state
entity_id: !input presence_binary
to: "on"
id: "presence_on"
- trigger: state
entity_id: !input presence_binary
id: "presence_off"
to: "off"
for:
hours: 0
minutes: 0
seconds: !input time_delay
conditions: !input additional_conditions
actions:
- choose:
- conditions:
- condition: trigger
id:
- presence_on
sequence:
- action: scene.turn_on
metadata: {}
data: {}
target:
entity_id: "scene.{{ scene_name }}"
- action: scene.delete
metadata: {}
data: {}
target:
entity_id: "scene.{{ scene_name }}"
- conditions:
- condition: trigger
id:
- presence_off
sequence:
- action: scene.create
metadata: {}
data:
scene_id: "{{ scene_name }}"
snapshot_entities: !input lights
- action: light.turn_off
metadata: {}
data: {}
target:
entity_id: !input lights