85 lines
2.0 KiB
YAML
85 lines
2.0 KiB
YAML
blueprint:
|
|
name: Motion-activated Light with Optional Lux
|
|
description: Turn on a light when motion is detected, optionally only if lux is below a threshold.
|
|
domain: automation
|
|
author: Home Assistant
|
|
input:
|
|
motion_entity:
|
|
name: Motion Sensor
|
|
selector:
|
|
entity:
|
|
filter:
|
|
- device_class: occupancy
|
|
domain: binary_sensor
|
|
- device_class: motion
|
|
domain: binary_sensor
|
|
light_target:
|
|
name: Light
|
|
selector:
|
|
target:
|
|
entity:
|
|
domain: light
|
|
lux_entity:
|
|
name: Lux Sensor (optional)
|
|
default: null
|
|
selector:
|
|
entity:
|
|
domain: sensor
|
|
device_class: illuminance
|
|
lux_threshold:
|
|
name: Lux Threshold
|
|
description: Only turn on the light if lux is below this value.
|
|
default: 50
|
|
selector:
|
|
number:
|
|
min: 0
|
|
max: 1000
|
|
unit_of_measurement: lx
|
|
no_motion_wait:
|
|
name: Wait time
|
|
description: Time to leave the light on after last motion is detected.
|
|
default: 120
|
|
selector:
|
|
number:
|
|
min: 0
|
|
max: 3600
|
|
unit_of_measurement: seconds
|
|
|
|
mode: restart
|
|
max_exceeded: silent
|
|
|
|
trigger:
|
|
- platform: state
|
|
entity_id: !input motion_entity
|
|
from: "off"
|
|
to: "on"
|
|
|
|
condition:
|
|
- alias: "Optional lux check"
|
|
condition: template
|
|
value_template: >
|
|
{% if lux_entity %}
|
|
{{ states(lux_entity) | float(0) < lux_threshold }}
|
|
{% else %}
|
|
true
|
|
{% endif %}
|
|
|
|
action:
|
|
- alias: "Turn on the light"
|
|
service: light.turn_on
|
|
target: !input light_target
|
|
|
|
- alias: "Wait until there is no motion from device"
|
|
wait_for_trigger:
|
|
- platform: state
|
|
entity_id: !input motion_entity
|
|
from: "on"
|
|
to: "off"
|
|
|
|
- alias: "Wait the number of seconds that has been set"
|
|
delay: !input no_motion_wait
|
|
|
|
- alias: "Turn off the light"
|
|
service: light.turn_off
|
|
target: !input light_target
|