Trigger.entity_id sample

Sorry for taking so long to get back at you. I don’t seem to have that particular automation set up anymore so I can’t really help with that. Anything in particular you want to ask?

~Cheers

To get the friendly name of the trigger:
state_attr(trigger.entity_id, ‘friendly_name’)

2 Likes

Vey helpful. A note for future readers - this is using the data_template: rather than just data:, and for binary_sensors you need to specify that rather than sensors. I modified this to notify me (on my TV) when doors open or close, with their actual state.

alias: .notify door opened close on TV
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.sensor_front_door
      - binary_sensor.garage_side_door_contact_sensor
      - binary_sensor.sensor_family_room_doors
      - binary_sensor.sensor_deck_south_doors
      - binary_sensor.sensor_deck_north_doors
      - binary_sensor.sensor_parlor_sliding_doors
      - binary_sensor.garage_door_myq_contact_sensor
      - binary_sensor.workout_room_window
      - binary_sensor.lumi_lumi_sensor_magnet_aq2_on_off
      - binary_sensor.hot_tub_cover_access_control_window_door_is_open
condition:
  - condition: not
    conditions:
      - condition: state
        entity_id: media_player.tv_family_room
        state: "off"
action:
  - service: notify.family_room_tv
    data_template:
      message: >-
        {%- for state in states.binary_sensor if state.entity_id ==
        trigger.entity_id -%}
          {{ state.attributes.friendly_name | replace(" Contact Sensor","") }} is {{state.state | replace("on","open") | replace("off", "closed")}} 
        {%- endfor -%}
mode: queued
max: 10
1 Like