Can you identity which entity inside a list inside a trigger caused the automation to run?

More of a yes or no question here, mostly looking for validation here. For triggers in automations you can use the id key to use later in your actions to denote which trigger in your list of triggers caused the automation to run

However, if you have this example

trigger:
- platform: state
  id: A
  entity_id:
    - sensor1
    - sensor2
- platform: state
  id: B
  entity_id:
    - sensor3
    - sensor4

I am assuming that while I can know if trigger A or B ran my actions I cannot know it was sensor1 inside trigger A that caused it to run, right? I would assume i would have to separate each sensor into its own trigger and that is how I can denote which trigger did what.

I think the answer to your question is you can do it, take a look at trigger.entity_id:

alias: x Test
description: ''
trigger:
  - platform: state
    id: A
    entity_id:
      - light.office_light
      - light.office_play
condition: []
action:
  - service: notify.mobile_app_mike
    data:
      message: This triggered it {{ trigger.entity_id }}
mode: single

The message will tell you, in this example, which of the two lights triggered it.

Take a look here, lots of good stuff you can use…

1 Like

Thank you for linking me to this! I did not find this at first. I found this site only: