Google home say hello to a person via device tracker

Hello, I am trying to get my google home to say hello to the person who gets home. So far I have to person connected via tracker. I thought I found the way to do it, but it says me “Hallo Trigger Entity Id…”, it doesn’t decode what is inside the {{ trigger.entity_id.attributes.friendly_name }}

here is my full automation right now:

- id: '1578556095089'
  alias: Welcome Home
  trigger:
  - entity_id: device_tracker.honor_10_8f45ce529244b93
    from: not_home
    platform: state
    to: home
  - entity_id: device_tracker.android_glorita
    from: not_home
    platform: state
    to: home
  condition:
  - after: '10:00:00'
    condition: time
  action:
  - entity_id: media_player.google_home_mini
    service: media_player.turn_on
  - delay: 00:00:02
  - data:
      entity_id: media_player.google_home_mini
      message: Hallo {{ trigger.entity_id.attributes.friendly_name }}
    service: tts.google_say
  - delay: 00:00:04
  - entity_id: media_player.google_home_mini
    service: media_player.turn_off

Can someone please help me with this?
Thank you!

Change data to data_template

I just tried that but then the google home doesn’t say anything (after turning on)

tts.google._say is no longer used. Use tts.google_translate_say…and data_template

service: tts.google_say
works for me.

the tts.google._say was “suggested” me by Home Assistant Automation creator after i set my configuration.yaml as in the example here: https://www.home-assistant.io/integrations/tts/
Anyway now I have removed “service_name: google_say” and the Automation creator actually says me that the service is named tts.google_translate_say.

But my problem is still the same: as soon as I replace the data with data_template my google home doesn’t say anything anymore (but it turns on), while if I set data then it says “Hallo trigger entity…”

- id: '1578556095089'
  alias: Welcome Home
  trigger:
  - entity_id: device_tracker.honor_10_8f45ce529244b93
    from: not_home
    platform: state
    to: home
  - entity_id: device_tracker.android_glorita
    from: not_home
    platform: state
    to: home
  condition: []
  action:
  - data:
      message: test
      title: test1
    service: notify.mobile_app_dario_s_col_l29
  - entity_id: media_player.google_home_mini
    service: media_player.turn_on
  - delay: 00:00:02
  - data_template:
      entity_id: media_player.google_home_mini
      message: "Hallo {{ trigger.entity_id.attributes.friendly_name }}"
    service: tts.google_translate_say
  - delay: 00:00:04
  - entity_id: media_player.google_home_mini
    service: media_player.turn_off

I tried to add the " " at the beginning and end of the message cause I read in another post that it was important but it has no effect to me… What am I doing wrong?

This works for me

      - service: tts.google_say
        entity_id: media_player.nb_home
        data_template:
          message: "{{ states('sensor.tts_test_file') }}"
          language: 'de'

I tried with your structure (diffrent indentation and order) but it also didn’t work…

- id: '1578556095089'
  alias: Welcome Home
  trigger:
  - entity_id: device_tracker.honor_10_8f45ce529244b93
    from: not_home
    platform: state
    to: home
  - entity_id: device_tracker.android_glorita
    from: not_home
    platform: state
    to: home
  condition: []
  action:
  - data:
      message: test
      title: test1
    service: notify.mobile_app_dario_s_col_l29
  - entity_id: media_player.google_home_mini
    service: media_player.turn_on
  - delay: 00:00:02
  - service: tts.google_translate_say 
    entity_id: media_player.google_home_mini 
    data_template:
      message: "Hallo {{ trigger.entity_id.attributes.friendly_name }}"
  - delay: 00:00:04
  - entity_id: media_player.google_home_mini
    service: media_player.turn_off

I tried to log the error and it turns out that the {{trigger.to_state.attributes.friendly_name}} generates the following error:

Error rendering data template: UndefinedError: ‘str object’ has no attribute ‘attributes’

and in my known_devices.yaml the following two devices are present:

android_glorita:
  hide_if_away: false
  icon:
  mac: AC:37:43:46:C2:7D
  name: Glorita
  picture: /local/gloria.jpg
  track: true

honor_10_8f45ce529244b93:
  hide_if_away: false
  icon:
  mac: B4:86:55:2F:A4:6D
  name: Dario
  picture: /local/dario.jpg
  track: true

which are the two devices connected to the device tracker. What am I doing wrong?