I have an automation that choose between two messages depending on if I leave or entry at home, with this code:
message: |
{% if is_state('person.me', 'home') %}
Jose arrived home at {{ as_timestamp (now()) | timestamp_custom('%I:%M %p') }}
{% else %}
Jose left home at {{ as_timestamp (now()) | timestamp_custom('%I:%M %p') }}.
{% endif %}
This part works fine. And then I added this code to mahe Google home mini say welcome:
message: |
{% if is_state('person.me', 'home') %}
Welcome home, Jose
{% else %}
{% endif %}
but what Google home mini do is read all the code… what am I doing wrong?
This is the full code as it is on automations.yaml. In automations gui, I can see the code I wrote before.
- id: '1578306975894'
alias: LocalizaciĂłn Jose
description: ''
trigger:
- entity_id: person.me
from: not_home
platform: state
to: home
- entity_id: person.me
from: home
platform: state
to: not_home
condition: []
action:
- data:
message: "{% if is_state('person.me', 'home') %}\n Jose arrived\
\ home at {{ as_timestamp (now()) | timestamp_custom('%I:%M %p') }}\n\
{% else %}\n Jose left home at {{ as_timestamp (now()) | timestamp_custom('%I:%M\
\ %p') }}.\n{% endif %}\n"
service: notify.telegram_jj
- data:
message: "{% if is_state('person.me', 'home') %}\n Welcome home, Jose\n\
{% else %}\n Jose left home\n{% endif %}\n"
service: tts.google_translate_say
I didn’t wrote data or data_template, it was the frontend; anyway, the first part works, I get “Jose arrived” or “Jose left” home depending on if I entry or left my home. I don’t know what is different for google home mini, because it read all the sentence after last “message” word, % symbols included…
You are right. After change data to data_template, now it is working. Data or data_template is something I didn’t wrote, it was wrote by the automations frontend on automations.yaml. I manually changed data to data_template, and works. Now I need something to write after {% else %} (or delete it), to get no accion when I levae home. THANKS for your help