blueprints/automation/motion-light.yaml aktualisiert
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user