Why google home mini read all?

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?

Can you show the full code please? Maybe you’re missing an indi ator that the message is a template.

1 Like

your data line should be data_template. Also, you should work on keeping your spacing readable and always finish your else statements.

data_template: #<--- DATA_TEMPLATE, not DATA
  message: |
    {% if is_state('person.me', 'home') %}
      Welcome home, Jose
    {% else %}
      Add something here.
    {% endif %}

1 Like

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…

Yes, it’s because it’s not parsing the template because data_template is missing. But you know better apparently.

1 Like

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