From 25cd1b077c08baec20fd90b283889b9985bff439 Mon Sep 17 00:00:00 2001 From: thomas Date: Fri, 29 Aug 2025 14:44:36 +0000 Subject: [PATCH] blueprints/automation/motion-light.yaml aktualisiert --- blueprints/automation/motion-light.yaml | 27 +++++++++++-------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/blueprints/automation/motion-light.yaml b/blueprints/automation/motion-light.yaml index e64a721..25ae2df 100644 --- a/blueprints/automation/motion-light.yaml +++ b/blueprints/automation/motion-light.yaml @@ -1,6 +1,6 @@ blueprint: - 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. + name: Smart Motion Light with Optional Lux Trigger and Time-Based Dimming + 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 input: motion_entity: @@ -27,7 +27,6 @@ blueprint: device_class: illuminance lux_threshold: name: Lux Threshold - description: Only turn on the light if lux is below this value (if sensor is defined). default: 50 selector: number: @@ -47,27 +46,25 @@ mode: restart max_exceeded: silent trigger: + # Motion trigger - platform: state entity_id: !input motion_entity from: "off" to: "on" - - platform: numeric_state - entity_id: !input lux_entity - below: !input lux_threshold - -condition: - - alias: "Optional lux check and recent motion" - condition: template + + # Optional lux trigger + - platform: 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 %} - {% set lux_value = states(lux_entity) | float(0) %} - {{ recent_motion and lux_value < lux_threshold }} + {{ states(lux_entity) | float(0) < lux_threshold and + (states(motion_entity) == 'on' or + (as_timestamp(now()) - as_timestamp(states(motion_entity))) < 300) }} {% else %} - {{ recent_motion }} + false {% endif %} +condition: [] + action: - alias: "Turn on the light with calculated brightness" service: light.turn_on