Google Translate - announce the door that was opened

I’m trying to get my Google speakers to tell me what door was opened in the event the alarm is triggered. Here is my automation code:

- id: '1635522521438'
  alias: Alarm - Announce trigger on Google Home
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.basement_garage_entry_door
    to: 'on'
    from: 'off'
  - platform: state
    entity_id: binary_sensor.basement_patio_door
    to: 'on'
    from: 'off'
  - platform: state
    entity_id: binary_sensor.basement_garage_door
    from: 'off'
    to: 'on'
  - platform: state
    entity_id: binary_sensor.garage_entry_door
    from: 'off'
    to: 'on'
  - platform: state
    entity_id: binary_sensor.garage_service_door
    from: 'off'
    to: 'on'
  - platform: state
    entity_id: binary_sensor.side_garage_door
    from: 'off'
    to: 'on'
  - platform: state
    entity_id: binary_sensor.big_garage_door
    from: 'off'
    to: 'on'
  - platform: state
    entity_id: binary_sensor.patio_door
    from: 'off'
    to: 'on'
  - platform: state
    entity_id: binary_sensor.front_door
    from: 'off'
    to: 'on'
  condition:
  - condition: or
    conditions:
    - condition: state
      entity_id: alarm_control_panel.home_alarm
      state: armed_night
    - condition: state
      entity_id: alarm_control_panel.home_alarm
      state: triggered
  action:
  - service: media_player.volume_set
    target:
      entity_id:
      - media_player.great_room_google_hub
      - media_player.master_bedroom_speaker
      - media_player.toy_room_speaker
    data:
      volume_level: 0.9
  - service: tts.google_translate_say
    data:
      entity_id: media_player.great_room_google_hub
      message: The {{trigger.entity_ID}} was opened
  - service: tts.google_translate_say
    data:
      entity_id: media_player.master_bedroom_speaker
      message: The {{trigger.entity_ID}} was opened
  - service: tts.google_translate_say
    data:
      entity_id: media_player.toy_room_speaker
      message: The {{trigger.entity_ID}} was opened
  - service: media_player.volume_set
    target:
      entity_id:
      - media_player.master_bedroom_speaker
      - media_player.toy_room_speaker
      - media_player.great_room_google_hub
    data:
      volume_level: 0.4
  mode: single

For example, If the garage entry door triggers the automation I want the system to say “The garage entry door was opened”. I currently says “The binary underscore sensor period garage underscore door was opened”. How can I get rid of extra parts of the entity ID?

I tried changing {{trigger.entity_ID}} to {{trigger.name}} and {{trigger.friendly_name}} but that didn’t work

This might help:

{{trigger.to_state.attributes.friendly_name}}

To understand why that works, review State Objects and State Trigger - Templates.

2 Likes

That did it. Thanks!

You’re welcome! Glad to hear it solved the problem for you.

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions. For more information, refer to guideline 21 in the FAQ.

I tried to mark it as the solution but I don’t have the option

You don’t have the option because you created a topic without a category. Edit the first post and select the Configuration category. After you save it, you should see the option appear in all other posts in this thread (you might have to refresh the web page first).

1 Like