Hi,
I am trying to define an automation to set the position of our 3 shutters of our roof-top-windows.
I successfully defined 6 scripts to set different positions : Shelly 2 roller shutter tilt - #2 by schneich (-> open, 33%, 50%, 66%, closed)
Right now, I am struggling with the trigger. Unfortunately, I do not (yet) have a temperature sensor in that room, so I wanted to base the trigger on sensor.openweathermap_uv_index.
Something like this:
- UV-idex < 4 = open
- 4 < UV-index < 4.5 = 33% closed
- …
As trigger, I tried with a numeric-state-trigger, but that did not work. So I changed to template-trigger. It seemed to work at first, but not anymore. When I check the template within the developer tools, all looks good.
Is this the right way to approach this?
alias: Dach Rollo Management
description: |-
based on UV-Index shutter will be closed step-by-step.
0-4.0 -> nothing
4.0-4.5 -> 1/3 closed
4.5-5.0 -> 50% closed
5.0-6.0 -> 2/3 closed
6.0+ -> 100% closed
trigger:
- platform: template
value_template: |-
{% if 4.5 > states('sensor.openweathermap_uv_index')|float(0) >= 4 %}
true
{% else %}
false
{% endif %}
for: '00:15:00'
- platform: template
value_template: |-
{% if 5.0 > states('sensor.openweathermap_uv_index')|float(0) >= 4.5 %}
true
{% else %}
false
{% endif %}
for: '00:15:00'
- platform: template
value_template: |-
{% if 6.0 > states('sensor.openweathermap_uv_index')|float(0) >= 5.0 %}
true
{% else %}
false
{% endif %}
for: '00:15:00'
- platform: template
value_template: |-
{% if states('sensor.openweathermap_uv_index')|float(0) >= 6.0 %}
true
{% else %}
false
{% endif %}
for: '00:15:00'
- platform: template
value_template: |-
{% if states('sensor.openweathermap_uv_index')|float(0) < 4 %}
true
{% else %}
false
{% endif %}
for: '00:00:15'
condition: []
action:
- choose:
- conditions:
- condition: template
value_template: |-
{% if not is_number(states('sensor.openweathermap_uv_index')) %}
true
{% else %}
false
{%endif%}
sequence:
- stop: UV-Index is not a number.
error: true
- conditions:
- condition: template
value_template: >-
{% if 4.5 > states('sensor.openweathermap_uv_index')|float(0) >= 4
%}
true
{% else %}
false
{% endif %}
sequence:
- service: script.dach_rollos_33_zu
data: {}
- conditions:
- condition: template
value_template: >-
{% if 5.0 > states('sensor.openweathermap_uv_index')|float(0) >=
4.5 %}
true
{% else %}
false
{% endif %}
sequence:
- service: script.dach_rollos_50_zu
data: {}
- conditions:
- condition: template
value_template: >-
{% if 6.0 > states('sensor.openweathermap_uv_index')|float(0) >=
5.0 %}
true
{% else %}
false
{% endif %}
sequence:
- service: script.dach_rollos_66_zu
data: {}
- conditions:
- condition: template
value_template: |-
{% if states('sensor.openweathermap_uv_index')|float(0) >= 6.0 %}
true
{% else %}
false
{% endif %}
sequence:
- service: script.dach_rollos_zu
data: {}
default:
- service: script.dach_rollos_auf
data: {}
mode: single
[EDIT: language translation within code]