[SOLVED] Placeholder in "wait for trigger"

Hello,

I have an automation that I would like to make “smarter”.
Right now it is like this :

alias: 'Notification when status failure or recovery'
description: Send a notification in case of status failure / recovery
trigger:
  - platform: state
    entity_id: sensor.first_status_data
    to: FAIL
    id: first
  - platform: state
    entity_id: sensor.second_status_data
    to: FAIL
    id: second
action:
  - service: notify.me
    data:
      message: status failure detected on {{ trigger.id }}!
  - wait_for_trigger:
      - platform: state
        entity_id: sensor.first_status_data
        to: RECOVERED
      - platform: state
        entity_id: sensor.second_status_data
        to: RECOVERED
  - service: notify.me
    data:
      message: status recovered!
mode: single

It is working, but sometimes the trigger is sensor.first_status_data and the “wait_for_trigger” is sensor.second_status_data which is not what I want.
I would like to do something like this :

alias: 'Notification when status failure or recovery'
description: Send a notification in case of status failure / recovery
trigger:
  - platform: state
    entity_id: sensor.first_status_data
    to: FAIL
    id: first
  - platform: state
    entity_id: sensor.second_status_data
    to: FAIL
    id: second
action:
  - service: notify.me
    data:
      message: status failure detected on {{ trigger.id }}!
  - wait_for_trigger:
      - platform: state
        entity_id: sensor.{{trigger.id}}_status_data
        to: RECOVERED
  - service: notify.me
    data:
      message: status recovered!
mode: parallel
max: 10

Which obviously doesn’t work :slight_smile:
How can I do in this case?

Thanks.

From Here:

I think it would be:

alias: 'Notification when status failure or recovery'
description: Send a notification in case of status failure / recovery
trigger:
  - platform: state
    entity_id: 
      - sensor.first_status_data
      - sensor.second_status_data
    to: FAIL
action:
  - service: notify.me
    data:
      message: status failure detected on {{ trigger.entity_id }}!
  - wait_for_trigger:
      - platform: state
        entity_id: "{{ trigger.entity_id }}"
        to: RECOVERED
  - service: notify.me
    data:
      message: status recovered!
mode: parallel
max: 10

@AllHailJ
Thank you for your input, but sadly it still doesn’t work ; I get the following error :

Message malformed: Entity ID {{ trigger.entity_id }} is an invalid entity ID for dictionary value @ data['entity_id']

Thanks for the tip. It allowed me to focus in the right direction.
Below the final form which is now working, for others who may have the same issue.

alias: 'Notification when status failure or recovery'
description: Send a notification in case of status failure / recovery
trigger:
  - platform: state
    entity_id: sensor.first_status_data
    to: FAIL
    id: first
  - platform: state
    entity_id: sensor.second_status_data
    to: FAIL
    id: second
action:
  - service: notify.me
    data:
      message: status failure detected on {{ trigger.id }}!
  - wait_for_trigger:
      - platform: template
        value_template: '{{ states(trigger.entity_id) == ''RECOVERED'' }}'
  - service: notify.me
    data:
      message: status recovered!
mode: parallel
max: 10

I could have indeed marked your post as solution but someone checking this thread would still have to read until my post to have an example with the working solution.
As the post with the solution is embed in the first post, I prefer for it to be the one with the exact solution. For instance, my knowledge in yaml is quite basic, so it took me a while before finding the right syntax. Someone as beginner as me, would have the solution right in the first post this way.

If you still think it is better to mark your post as the solution please let me know and I will do so.

Nevertheless I thank you for your input as it allowed me to look in the right direction.

No need; I’ve deleted it.