2025-06-18 07:09:10 +00:00
blueprint :
2025-08-29 14:42:06 +00:00
name : Smart Motion Light with Optional Lux and Time-Based Dimming
description : Turns on a light when motion is detected or when lux falls below a threshold (optional), and dims based on time of day. Turns off when no motion is detected.
2025-06-18 07:09:10 +00:00
domain : automation
input :
motion_entity :
name : Motion Sensor
selector :
entity :
filter :
2025-08-29 14:32:25 +00:00
- domain : binary_sensor
device_class : motion
- domain : binary_sensor
device_class : occupancy
2025-06-18 07:09:10 +00:00
light_target :
name : Light
selector :
target :
entity :
domain : light
2025-08-29 14:29:56 +00:00
lux_entity :
name : Lux Sensor (optional)
2025-08-29 14:32:25 +00:00
default : null
2025-08-29 14:29:56 +00:00
selector :
entity :
domain : sensor
device_class : illuminance
lux_threshold :
name : Lux Threshold
2025-08-29 14:42:06 +00:00
description : Only turn on the light if lux is below this value (if sensor is defined).
2025-08-29 14:29:56 +00:00
default : 50
selector :
number :
min : 0
max : 1000
unit_of_measurement : lx
2025-06-18 07:09:10 +00:00
no_motion_wait :
2025-08-29 14:32:25 +00:00
name : Wait Time After Motion Stops
2025-06-18 07:09:10 +00:00
default : 120
selector :
number :
min : 0
max : 3600
unit_of_measurement : seconds
mode : restart
max_exceeded : silent
2025-08-29 14:29:56 +00:00
trigger :
- platform : state
entity_id : !input motion_entity
from : "off"
to : "on"
2025-08-29 14:40:59 +00:00
- platform : numeric_state
entity_id : !input lux_entity
below : !input lux_threshold
2025-08-29 14:29:56 +00:00
condition :
2025-08-29 14:42:06 +00:00
- alias : "Optional lux check and recent motion"
2025-08-29 14:34:29 +00:00
condition : template
value_template : >
2025-08-29 14:42:06 +00:00
{% set last_motion = states(!input.motion_entity) %}
2025-08-29 14:40:59 +00:00
{% set recent_motion = (last_motion == 'on') or (as_timestamp(now()) - as_timestamp(last_motion)) < 300 %}
2025-08-29 14:34:29 +00:00
{% if lux_entity %}
2025-08-29 14:42:06 +00:00
{% set lux_value = states(lux_entity) | float(0) %}
{{ recent_motion and lux_value < lux_threshold }}
2025-08-29 14:34:29 +00:00
{% else %}
2025-08-29 14:40:59 +00:00
{{ recent_motion }}
2025-08-29 14:34:29 +00:00
{% endif %}
2025-06-18 07:09:10 +00:00
2025-08-29 14:29:56 +00:00
action :
- alias : "Turn on the light with calculated brightness"
service : light.turn_on
2025-08-29 14:42:06 +00:00
target : !input.light_target
2025-08-29 14:29:56 +00:00
data :
brightness : "{{ brightness }}"
2025-08-29 14:32:25 +00:00
- alias : "Wait until motion stops"
2025-06-18 07:09:10 +00:00
wait_for_trigger :
2025-08-29 14:29:56 +00:00
- platform : state
2025-08-29 14:42:06 +00:00
entity_id : !input.motion_entity
2025-08-29 14:29:56 +00:00
from : "on"
to : "off"
2025-08-29 14:32:25 +00:00
- alias : "Wait the configured delay"
2025-08-29 14:42:06 +00:00
delay : !input.no_motion_wait
2025-06-18 07:09:10 +00:00
- alias : "Turn off the light"
2025-08-29 14:29:56 +00:00
service : light.turn_off
2025-08-29 14:42:06 +00:00
target : !input.light_target