Automation: Action output relative to triggering entity?

I’ve a simple automation that sends a notification to my mobile when a PIR sensor battery is low, is there a way of altering this so the message indicates which sensor / entityID triggers the automation? (There are multiple sensors I just cut a load out below to shorten the code)

Appreciate I could add a seperate automation for each device, but there has to be a more efficient way. Thanks.

alias: Alarm Device Battery Low
description: ""
triggers:
  - entity_id:
      - binary_sensor.visonic_z01
    to: "0"
    attribute: battery_level
    trigger: state
  - entity_id:
      - binary_sensor.visonic_z02
    attribute: battery_level
    to: "0"
    trigger: state
conditions: []
actions:
  - action: notify.mobile_app_s25
    data:
      message: Alarm PIR battery low
mode: single

My trigger is 30%, but I use this message line:

message: "{{ trigger.to_state.name }} low: {{ trigger.to_state.state }}%"

Which gives a notification like:

“Kitchen window contact sensor Battery low: 10%”

You still have to list all your entities in the trigger, though:

triggers:
    trigger: numeric_state
    below: 30
    entity_id:
      - sensor.bedroom_motion_sensor_battery
      - sensor.bathroom_motion_sensor_battery
      - sensor.hallway_motion_sensor_battery
      - sensor.kitchen_motion_sensor_battery
      - sensor.landing_motion_sensor_battery
      - etc. etc.
1 Like

Brilliant, many thanks.
BTW I get why you’d trigger at 30%, unfortunately the PIR’s concerned only report 100% or 0%, hence my trigger.