It would be awesome if a trigger variable would have access to the newly introduced trigger id.
Can you give a use case example?
When an automation triggers, only then is trigger.id
known. Therefore I agree with tom_l and wonder how you envision using it in Trigger Variable.
So here’s an example:
- id: '1626001581698'
alias: Turn off Heating debug
description: ''
trigger:
- entity_id: binary_sensor.bedroom_window
platform: state
to: 'on'
id: bedroom
- platform: state
entity_id: binary_sensor.office_window
id: office
to: 'on'
- platform: state
entity_id: group.salon_window
id: salon
to: 'on'
condition: []
action:
- data:
entity: climate.{{ trigger.trigger_id }}
temperature: 5
service: script.set_room_temperature
mode: single
So when the autotomation triggers, I am able to use trigger.trigger_id
in action part. It would be similiar to using trigger.entity_id
.
I now understand what you want and you will be happy to know it already exists. It’s called trigger.id
.
entity: 'climate.{{ trigger.id }}'
It was first introduced in version 2021.3.0 and reported the trigger’s ordinal position. The first trigger is '0'
, the second is '1'
, etc.
In 2021.7.0, it was enhanced and now permits assigning a name to each trigger’s id
. If you don’t assign a name, it defaults to using the trigger’s ordinal position.
That’s great news. I looked in the documentation but couldn’t find it. Thanks!
Its introduction in 2021.3 was not announced or documented. Only the enhanced version in 2021.7 was announced in the release notes:
Closing this as implemented.