sequence:
- service: scene.turn_on
target:
entity_id: scene.fenster_offen_kalt
- service: script.notification_fenster_auf_kalt
data:
message: >-
{% set oid = trigger.to_state.object_id %}
{% set ausloeser = 'binary_sensor.{{ oid }}' %}
{% set zeit_offen = as_timestamp(now()) - as_timestamp(states.{{ ausloeser }}.last_changed) %}
{% set fenster_raum = 'die BalkontĆ¼r im Wohnzimmer' if 'wohnzimmer' in oid else
'das Fenster im BĆ¼ro' if 'buro' in oid %}
{% set temp_outside = states('sensor.temperature_balkon') %}
Es ist kalt (auf dem Balkon aktuell {{ temp_outside }}Ā°C) und {{ fenster_raum }} ist seit {{ zeit_offen }} Minuten auf!
Nearly everthing works fine but the one line produces errors:
{% set zeit_offen = as_timestamp(now()) - as_timestamp(states.{{ ausloeser }}.last_changed) %}
When I do it like above I get the error, that it need to be a string. But when I do
{% set zeit_offen = āas_timestamp(now()) - as_timestamp(states.{{ ausloeser }}.last_changed)ā %}
{% set oid = trigger.to_state.object_id %}
{% set ausloeser = 'binary_sensor.' ~ oid %}
{% set zeit_offen = as_timestamp(now()) - as_timestamp(states.('' ~ ausloeser ~'').last_changed) %}
{% set fenster_raum = 'die BalkontĆ¼r im Wohnzimmer' if 'wohnzimmer' in oid else 'das Fenster im BĆ¼ro' if 'buro' in oid %}
{% set temp_outside = states('sensor.temperature_balkon') %}
Es ist kalt (auf dem Balkon aktuell {{ temp_outside }}Ā°C) und {{ fenster_raum }} ist seit {{ zeit_offen }} Minuten auf!
yah, your changes should work, but they do look odd so see my last post. Either way, the phrase
ususually indicates that a string wasnāt returned for message. However scripts donāt care about variable types, so the error is coming from the notification inside that script. But this template could in theory be the cause. I just want to see the script to make sure.