How to re-use the entity_id caught for an automation, and use it in a notification message?

Hi,
I’ve got that automation :

- alias: Low Batteries Notifications
  trigger:
  - platform: numeric_state
    entity_id:
    - binary_sensor.door_sensor
    - binary_sensor.motion_sensor
    - binary_sensor.switch
    value_template: "{{ state.attributes.battery_level }}"
    below: '50'
  action:
  - service: notify.pushbullet
    data_template:
      title: "Low battery"
      message: 'Something got a low battery'

Would you know how could I set the message of my notification to show the name of the sensor that got the low battery ?
This would be better than “‘Something got a low battery’”

  action:
  - service: notify.pushbullet
    data_template:
      title: "Low battery"
      message: '{{ trigger.to_state.attributes.friendly_name  }} got a low battery'

Thank you that works ! :sunglasses:

1 Like