How to show entity in message

How can I show the triggering entity in the message I’m sending to Telegram?

The following does not work, the message only shows

Alarm on

I would expect it to be

Alarm on binary_sensor.fire_2

- alias: "Notify if Smoke Detected"
  initial_state: off
  trigger:
    - platform: state
      entity_id:
        - binary_sensor.fire_2
      to: "on"
  action:
    - service: telegram_bot.send_message
      data_template:
        title: Alarm!
        data: {}
        message: >
          Alarm on {{ trigger.entity_id }}

Never mind.
Apparently it does work, however my automation wasn’t refreshed properly

Leaving this here for future reference

This will give you the nice friendly name with a fallback to the entity id if there is no name:

        message: >
          Alarm on {{ trigger.to_state.name }}

If you really always want the entity id:

        message: >
          Alarm on {{ trigger.to_state.entity_id }}

Neither will work if you are testing the automation by triggering it manually with either the automation.trigger service or the button in the more info pop-up.

1 Like

Thanks @tom_l , the name is a nice perfection of what I want!