80 lines
2.2 KiB
YAML
80 lines
2.2 KiB
YAML
blueprint:
|
|
name: Smart Motion Light with Optional Lux and Global No-Motion Timer
|
|
description: Turns on a light when motion is detected, optionally based on lux sensor, dims based on time of day, and turns off using a global no-motion timer.
|
|
domain: automation
|
|
input:
|
|
motion_entity:
|
|
name: Motion Sensor
|
|
selector:
|
|
entity:
|
|
filter:
|
|
- domain: binary_sensor
|
|
device_class: motion
|
|
- domain: binary_sensor
|
|
device_class: occupancy
|
|
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
|
|
default: 50
|
|
selector:
|
|
number:
|
|
min: 0
|
|
max: 1000
|
|
unit_of_measurement: lx
|
|
no_motion_timer:
|
|
name: Global No-Motion Timer
|
|
description: An input_number entity representing the delay in seconds after motion stops before turning off the light.
|
|
selector:
|
|
entity:
|
|
domain: input_number
|
|
|
|
mode: restart
|
|
max_exceeded: silent
|
|
|
|
trigger:
|
|
- platform: state
|
|
entity_id: !input.motion_entity
|
|
from: "off"
|
|
to: "on"
|
|
|
|
condition: []
|
|
|
|
action:
|
|
- alias: "Check lux (if defined) before turning on"
|
|
choose:
|
|
- conditions:
|
|
- condition: template
|
|
value_template: >
|
|
{% if lux_entity %}
|
|
{{ states(lux_entity) | float(0) < lux_threshold }}
|
|
{% else %}
|
|
true
|
|
{% endif %}
|
|
sequence:
|
|
- service: light.turn_on
|
|
target: !input.light_target
|
|
data:
|
|
brightness: "{{ brightness }}"
|
|
- alias: "Wait until motion stops"
|
|
wait_for_trigger:
|
|
- platform: state
|
|
entity_id: !input.motion_entity
|
|
from: "on"
|
|
to: "off"
|
|
- delay:
|
|
seconds: "{{ states('!input.no_motion_timer') | int }}"
|
|
- service: light.turn_off
|
|
target: !input.light_target
|