Hi,
I wanted to streamline one of my automations by introducing variables. I have read the documentation, but I might not fully understand it - obviously.
I want to create an automation, which manages the roof top window shutters. So, I took my working Automation, changed the logic slightly and tried to introduce variables. Now, I get the error message.
Message malformed: required key not provided @ data[‘triggers’]
Can someone explain, what is wrong with my automation?
alias: Dach Rollo Management v10
description: |-
Based on sun irridiation W/m2, window shutters are opened/closed in 4 steps.
no number -> stop
0 - 150 -> fully open
150 - 300 -> 1/3-closed
300 - 450 -> 50%-closed
450 - 600 -> 2/3-closed
600+ -> 100%-closed
mode: single
max_exceeded: silent
variables:
outside_sun_irradiation: '{{ float( states("sensor.zurich_kloten_sun_irradiation"), "missing value" ) }}'
outside_temp: '{{ float( states("sensor.zurich_kloten_temperature"), "missing value" ) }}'
inside_dachzimmer_temp: '{{ float( states("sensor.esphome_dachzimmer2_temperatur"), "missing value" ) }}'
triggers:
- trigger: state
entity_id:
- sensor.zurich_kloten_sun_irradiation
- trigger: state
entity_id:
- weather.winterthur
- trigger: state
entity_id:
- sensor.esphome_dachzimmer2_temperatur
- trigger: sun
event: sunset
offset: 0
- trigger: sun
event: sunrise
offset: 0
conditions: []
actions:
- choose:
- conditions:
- condition: template
value_template: >-
{{ outside_sun_irradiation == 'missing value' or inside_dachzimmer_temp == 'missing value' or outside_temp == 'missing value' }}
sequence:
- stop: >-
Sun irradiation ( {{ outside_sun_irradiation }} ) bzw. Aussentemperatur ( { outside_temp } )bzw. Temperatur Sensor im Dach ( {{ inside_dachzimmer_temp }} ) liefert keine Zahlenwerte.
error: true
- delay:
hours: 0
minutes: 15
seconds: 0
milliseconds: 0
alias: If sensors do not provide numbers, do nothing
- conditions:
- condition: template
value_template: >-
{{
( as_timestamp(states('sensor.sun_next_setting')) + 3600 - as_timestamp(now()) ) / 3600 < 1
and ( as_timestamp(states('sensor.sun_next_rising')) + 3600 - as_timestamp(now()) ) / 3600 > 1
and now().month in [4, 5, 6, 7, 8, 9]
}}
sequence:
- metadata: {}
data: {}
action: script.dach_rollos_auf_2
- delay:
hours: 0
minutes: 15
seconds: 0
milliseconds: 0
alias: If 1h before next sunset and more then 1h before next sun rising and during summer months -> open shutters
- conditions:
- condition: template
value_template: >-
{% if states('weather.winterthur') in ['exceptional', 'hail',
'lightning', 'lightning-rainy', 'pouring', 'rainy', 'snowy',
'snowy-rainy', 'windy', 'windy-variant', 'unavailable'] %}
{{ true }}
{% else %}
{{ false }}
{% endif %}
sequence:
- data: {}
action: script.dach_rollos_auf_2
- delay:
hours: 2
minutes: 0
seconds: 0
milliseconds: 0
alias: If weather conditions are bad, open window shutters
- conditions:
- condition: template
value_template: >-
{{
( as_timestamp(states('sensor.sun_next_dusk')) + 3600 - as_timestamp(now()) ) / 3600 < 22
and ( as_timestamp(states('sensor.sun_next_rising')) + 3600 - as_timestamp(now()) ) / 3600 > 1
and outside_temp < 5
and now().month in [10, 11, 12, 1, 2, 3]
}}
sequence:
- data: {}
action: script.dach_rollos_zu_2
- delay:
hours: 0
minutes: 15
seconds: 0
milliseconds: 0
alias: >-
If Month's in Winter and during night time and outside temp below 5°C, close the shutters
- conditions:
- condition: template
value_template: >-
{{ outside_sun_irradiation >= 600 and inside_dachzimmer_temp > 24 }}
sequence:
- data: {}
action: script.dach_rollos_zu_2
- delay:
hours: 0
minutes: 30
seconds: 0
milliseconds: 0
alias: >-
If sun irradiation and indoor temperatur is high, fully close window
shutters
- conditions:
- condition: template
value_template: >-
{{ outside_sun_irradiation >= 450 and inside_dachzimmer_temp > 23.5 }}
sequence:
- data: {}
action: script.dach_rollos_66_zu_v2
- delay:
hours: 0
minutes: 15
seconds: 0
milliseconds: 0
alias: >-
If sun irradiation and indoor temperatur is above medium, close window
shutters 66%
- conditions:
- condition: template
value_template: >-
{{ outside_sun_irradiation >= 300 and inside_dachzimmer_temp > 23 }}
sequence:
- data: {}
action: script.dach_rollos_50_zu_v2
- delay:
hours: 0
minutes: 15
seconds: 0
milliseconds: 0
alias: >-
If sun irradiation and indoor temperatur is medium, close window
shutters 50%
- conditions:
- condition: template
value_template: >-
{{ outside_sun_irradiation >= 150 and inside_dachzimmer_temp > 22.5 }}
sequence:
- data: {}
action: script.dach_rollos_33_zu_2
- delay:
hours: 0
minutes: 15
seconds: 0
milliseconds: 0
alias: >-
If sun irradiation and indoor temperatur is bellow medium, close
window shutters 33%
- conditions:
- condition: template
value_template: >-
{{ 150 > outside_sun_irradiation or 22.5 > inside_dachzimmer_temp }}
sequence:
- data: {}
action: script.dach_rollos_auf_2
- delay:
hours: 0
minutes: 15
seconds: 0
milliseconds: 0
alias: >-
If sun irradiation and indoor temperatur is low, fully open window
shutters
default:
- delay:
hours: 0
minutes: 15
seconds: 0
milliseconds: 0
- stop: no significant change in state OR error in source data type