blueprints/automation/motion-light.yaml aktualisiert

This commit is contained in:
2025-08-29 14:44:36 +00:00
parent fe50a62093
commit 25cd1b077c

View File

@@ -1,6 +1,6 @@
blueprint: blueprint:
name: Smart Motion Light with Optional Lux and Time-Based Dimming name: Smart Motion Light with Optional Lux Trigger 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. description: Turns on a light when motion is detected or when lux drops below a threshold (if sensor is defined), dims based on time, and turns off when no motion.
domain: automation domain: automation
input: input:
motion_entity: motion_entity:
@@ -27,7 +27,6 @@ blueprint:
device_class: illuminance device_class: illuminance
lux_threshold: lux_threshold:
name: Lux Threshold name: Lux Threshold
description: Only turn on the light if lux is below this value (if sensor is defined).
default: 50 default: 50
selector: selector:
number: number:
@@ -47,27 +46,25 @@ mode: restart
max_exceeded: silent max_exceeded: silent
trigger: trigger:
# Motion trigger
- platform: state - platform: state
entity_id: !input motion_entity entity_id: !input motion_entity
from: "off" from: "off"
to: "on" to: "on"
- platform: numeric_state
entity_id: !input lux_entity # Optional lux trigger
below: !input lux_threshold - platform: template
condition:
- alias: "Optional lux check and recent motion"
condition: template
value_template: > value_template: >
{% set last_motion = states(!input.motion_entity) %}
{% set recent_motion = (last_motion == 'on') or (as_timestamp(now()) - as_timestamp(last_motion)) < 300 %}
{% if lux_entity %} {% if lux_entity %}
{% set lux_value = states(lux_entity) | float(0) %} {{ states(lux_entity) | float(0) < lux_threshold and
{{ recent_motion and lux_value < lux_threshold }} (states(motion_entity) == 'on' or
(as_timestamp(now()) - as_timestamp(states(motion_entity))) < 300) }}
{% else %} {% else %}
{{ recent_motion }} false
{% endif %} {% endif %}
condition: []
action: action:
- alias: "Turn on the light with calculated brightness" - alias: "Turn on the light with calculated brightness"
service: light.turn_on service: light.turn_on