Using helper attributes in notifications

First of all my installation is about 2 days old, sorry if this is obvious.

I’m trying to automate a battery level tracker for the various Zigbee sensors I have. I created 2 helpers, a sensor group with the “Min entity ID” attribute for the sensor with the lowest battery level, and a min/max value sensor to determine if any battery is below 5%. Not sure if this is the way to go but anyway. My automation looks like this:

alias: Battery monitor
description: ""
triggers:
  - trigger: state
    entity_id:
      - sensor.batterier
    attribute: min_entity_id
conditions:
  - condition: state
    entity_id: binary_sensor.batterigrans
    attribute: position
    state: Below
actions:
  - action: persistent_notification.create
    data:
      title: Low battery
      message: Swap battery for sensor {{ min_entity_id? }}
mode: single

I can’t figure out how to include the value from min_entity_id in the message?

Every trigger type has a specific set of available data stored in a variable trigger. You can use that to get the the information you want

    action: persistent_notification.create
    data:
      title: Low battery
      message: "Swap battery for sensor {{ trigger.to_state.attributes.min_entity_id }}"

Thank you. I tried running the action but get the following error:

Error rendering data template: UndefinedError: ‘trigger’ is undefined

EDIT: realized that might be because the trigger event is unavailable when I run an isolated action.

You need a real trigger event, the “Run actions” button skips the trigger (so no trigger variable is created).