From a8c4b8fede887d386dfa6c1b3ebe7b5812618ce7 Mon Sep 17 00:00:00 2001 From: thomas Date: Fri, 29 Aug 2025 14:40:59 +0000 Subject: [PATCH] blueprints/automation/motion-light.yaml aktualisiert --- blueprints/automation/motion-light.yaml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/blueprints/automation/motion-light.yaml b/blueprints/automation/motion-light.yaml index 1b3113c..16afe54 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, optionally based on ambient light, and dims based on time of day. + name: Smart Motion Light with Optional Lux and Time-Based Dimming and Lux Trigger + description: Turns on a light when motion is detected or when lux falls below a threshold, optionally based on ambient light, and dims based on time of day. Turns off when no motion is detected. domain: automation input: motion_entity: @@ -51,19 +51,23 @@ trigger: entity_id: !input motion_entity from: "off" to: "on" + - platform: numeric_state + entity_id: !input lux_entity + below: !input lux_threshold condition: - - alias: "Check lux only if sensor is defined" + - alias: "Check lux (optional) and recent motion" condition: 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) %} - {{ lux_value < lux_threshold }} + {% set lux_value = states(!input lux_entity) | float(0) %} + {{ lux_value < lux_threshold and recent_motion }} {% else %} - true + {{ recent_motion }} {% endif %} - action: - alias: "Turn on the light with calculated brightness" service: light.turn_on