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

- platform: state
  id: A
    - sensor1
    - sensor2
- platform: state
  id: B
    - 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: ''
  - platform: state
    id: A
      - light.office_light
      - light.office_play
condition: []
  - service: notify.mobile_app_mike
      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: