Google Home text input

Hello, I am trying to do something simple but it seems I am not sure how to reference one of the variables. Basically, I would like a text input in the UI so I can define a string for a name (i.e. Guest name). When the guest opens the door, a phrase will greet them through the Google Home and reference their name at the beginning. I am not sure how to reference the guest name variable, the rest is working perfectly. Does anyone know why {{states(input_text.guest_name_state)}} is not working or what to replace it with? Thank you!

input_text:
  guest_name:
    name: Guest
    initial: guest

automation:
- alias: 'welcome'
    trigger:
      - platform: state
        entity_id: sensor.front_door
        to: 'Open'
    action:
      - service: tts.google_translate_say
        entity_id: media_player.living_room_home
        data:
          message: Welcome {{states(input_text.guest_name_state)}}
          cache: false

when using templates, you need to use the data_template field instead of data. Also, you should probably put entity_id inside data_template as well.

In most cases, templates need to be in quotes when they are single line. Your case doesn’t really need quotes around it, but you should do it to get used to it. Your case doesn’t need it because the message field is starting with letters, which makes the parser think its a string. Otherwise, if the template edges are first, you need the quotes.

- alias: 'welcome'
    trigger:
      - platform: state
        entity_id: sensor.front_door
        to: 'Open'
    action:
      - service: tts.google_translate_say
        data_template:
          entity_id: media_player.living_room_home
          message: "Welcome {{states(input_text.guest_name_state)}}"
1 Like