blueprints/automation/motion-light.yaml aktualisiert
This commit is contained in:
@@ -54,14 +54,16 @@ trigger:
|
|||||||
from: "off"
|
from: "off"
|
||||||
to: "on"
|
to: "on"
|
||||||
|
|
||||||
|
variables:
|
||||||
|
lux_entity_var: !input lux_entity
|
||||||
|
lux_threshold_var: !input lux_threshold
|
||||||
|
|
||||||
condition:
|
condition:
|
||||||
- alias: "Optional lux check"
|
- alias: "Optional lux check"
|
||||||
condition: template
|
condition: template
|
||||||
value_template: >
|
value_template: >
|
||||||
{% set lux_entity = (inputs.lux_entity or '') %}
|
{% if lux_entity_var and states(lux_entity_var) not in ['unknown','unavailable'] %}
|
||||||
{% set lux_threshold = inputs.lux_threshold | float(50) %}
|
{{ states(lux_entity_var) | float(0) < lux_threshold_var | float(0) }}
|
||||||
{% if lux_entity and states(lux_entity) not in ['unknown','unavailable'] %}
|
|
||||||
{{ states(lux_entity) | float(0) < lux_threshold }}
|
|
||||||
{% else %}
|
{% else %}
|
||||||
true
|
true
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -69,35 +71,33 @@ condition:
|
|||||||
action:
|
action:
|
||||||
- alias: "Set dynamic brightness"
|
- alias: "Set dynamic brightness"
|
||||||
variables:
|
variables:
|
||||||
# Default max brightness
|
|
||||||
max_brightness: 255
|
max_brightness: 255
|
||||||
# Current sun elevation
|
|
||||||
sun_elevation: "{{ state_attr('sun.sun','elevation') | float(0) }}"
|
sun_elevation: "{{ state_attr('sun.sun','elevation') | float(0) }}"
|
||||||
# Optional lux value
|
|
||||||
current_lux: >
|
current_lux: >
|
||||||
{% if lux_entity %}
|
{% if lux_entity_var %}
|
||||||
{{ states(lux_entity) | float(0) }}
|
{{ states(lux_entity_var) | float(0) }}
|
||||||
{% else %}
|
{% else %}
|
||||||
0
|
0
|
||||||
{% endif %}
|
{% endif %}
|
||||||
# Compute brightness dynamically
|
|
||||||
brightness: >-
|
brightness: >-
|
||||||
{% set base = 50 %}
|
{% set base = 50 %}
|
||||||
{% if sun_elevation > 10 %}
|
{% if sun_elevation > 10 %}
|
||||||
{% set base = 100 %} # sun high: moderate indoor light
|
{% set base = 100 %}
|
||||||
{% elif sun_elevation > 0 %}
|
{% elif sun_elevation > 0 %}
|
||||||
{% set base = 150 %} # sun near horizon: brighter indoor light
|
{% set base = 150 %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% set base = 200 %} # sun below horizon: max brightness
|
{% set base = 200 %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if current_lux > 50 %}
|
{% if current_lux > 50 %}
|
||||||
{% set base = base - ((current_lux / 500) * base) | int %}
|
{% set base = base - ((current_lux / 500) * base) | int %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ [base, max_brightness] | min }}
|
{{ [base, max_brightness] | min }}
|
||||||
- service: light.turn_on
|
|
||||||
|
- alias: "Turn on the light"
|
||||||
|
service: light.turn_on
|
||||||
target: !input light_target
|
target: !input light_target
|
||||||
data:
|
data:
|
||||||
brightness: "{{ brightness }}"
|
brightness: "{{ brightness }}"
|
||||||
|
|
||||||
- alias: "Wait until there is no motion from device"
|
- alias: "Wait until there is no motion from device"
|
||||||
wait_for_trigger:
|
wait_for_trigger:
|
||||||
|
|||||||
Reference in New Issue
Block a user