Help on adding variables to automations

Automation in question. 2 motion detectors in same automation triggering a telegram message to be sent to me.

- id: 'xxxxxxxxxxxxxxxxxxxxxxxxxx'
  alias: Motion
  description: ''
  trigger:
  - type: motion
    platform: device
    device_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    entity_id: binary_sensor.upstairs_hallway_motion_detector_ias_zone
    domain: binary_sensor
  - type: motion
    platform: device
    device_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    entity_id: binary_sensor.stairwell_motion_detector_ias_zone
    domain: binary_sensor
  condition:
  - condition: state
    entity_id: input_boolean.motion_alarm
    state: 'on'
  action:
  - service: telegram_bot.send_message
    data:
      message: "Motion has been detected from {{ state_attr(trigger.entity_id, 'friendly_name') }}."

Is there any way to add information to each trigger? In my message sent through telegram, I want to say something

Motion has been detected from Downstairs Hallway Motion Detector

Things I have tried:

  1. If you look above, I’ve already tried grabbing the state_attr, but it did not work. My entity ID has underscores in it which I think messages up the parsing.
  2. trigger.entity_id works but still has a non-friendly name.

Is it possible to somehow add in a variable to each trigger and call upon that variable in the message?

  action:
  - service: telegram_bot.send_message
    data:
      message: "Motion has been detected from {{ trigger.to_state.name }}."

This will send the friendly name if the entity has one, otherwise the object_ id.

See: https://www.home-assistant.io/docs/automation/templating/#state

And: https://www.home-assistant.io/docs/configuration/state_object/

Thanks, I’ll give it a try! Any way to add custom variables to the trigger?