From 4431662d24b4ff9db48608f8efe63b8ffd9f0dd1 Mon Sep 17 00:00:00 2001 From: thomas Date: Fri, 29 Aug 2025 14:57:28 +0000 Subject: [PATCH] blueprints/automation/motion-light.yaml aktualisiert --- blueprints/automation/motion-light.yaml | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/blueprints/automation/motion-light.yaml b/blueprints/automation/motion-light.yaml index ae1c55e..7916a08 100644 --- a/blueprints/automation/motion-light.yaml +++ b/blueprints/automation/motion-light.yaml @@ -65,6 +65,37 @@ condition: {% endif %} action: + - alias: "Set dynamic brightness" + variables: + # Default max brightness + max_brightness: 255 + # Current sun elevation + sun_elevation: "{{ state_attr('sun.sun','elevation') | float(0) }}" + # Optional lux value + current_lux: > + {% if lux_entity %} + {{ states(lux_entity) | float(0) }} + {% else %} + 0 + {% endif %} + # Compute brightness dynamically + brightness: >- + {% set base = 50 %} + {% if sun_elevation > 10 %} + {% set base = 100 %} # sun high: moderate indoor light + {% elif sun_elevation > 0 %} + {% set base = 150 %} # sun near horizon: brighter indoor light + {% else %} + {% set base = 200 %} # sun below horizon: max brightness + {% endif %} + {% if current_lux > 50 %} + {% set base = base - ((current_lux / 500) * base) | int %} + {% endif %} + {{ [base, max_brightness] | min }} + - service: light.turn_on + target: !input light_target + data: + brightness: "{{ brightness }}" - alias: "Turn on the light" service: light.turn_on target: !input light_target