YAML:
alias: Blind follows lux (daylight only)
mode: restart
trigger:
- platform: time_pattern
minutes: "/10"
condition:
- condition: sun
after: sunrise
before: sunset
action:
- variables:
lux: "{{ states('sensor.aqara_motion_and_light_sensor_p2_valaistusvoimakkuus') | float(0) }}"
pos: "{{ (lux * 0.1) | round(0) }}"
# move only if change >5%
- condition: template
value_template: >
{% set current = state_attr('cover.matter_window_covering_1','current_position') | int(0) %}
{% set new = pos | int %}
{{ (current - new) | abs > 5 }}
- service: cover.set_cover_position
target:
entity_id: cover.matter_window_covering_1
data:
position: >
{% set p = pos | int %}
{% if p < 1 %}
1
{% elif p > 99 %}
99
{% else %}
{{ p }}
{% endif %}