List all available variables made available by triggers.
Automations support templating in the same way as scripts do. In addition to the Home Assistant template extensions available to scripts, the trigger and this template variables are available.
The template variable this is also available when evaluating any trigger_variables declared in the configuration.
Available this Data
The variable this is the state object of the automation at the moment of triggering the actions. State objects also contain context data which can be used to identify the user that caused a script or automation to execute. Note that this will not change while executing the actions.
Available Trigger Data
The following tables show the available trigger data per platform.
All
The following describes trigger data associated with all platforms.
Template variable
Data
trigger.id
Optional trigger id, or index of the trigger.
trigger.idx
Index of the trigger. (The first trigger idx is 0.)
Calendar
Template variable
Data
trigger.platform
Hardcoded: calendar
trigger.event
The trigger event type, either start or end
trigger.calendar_event
The calendar event object matched.
trigger.calendar_event.summary
The title or summary of the calendar event.
trigger.calendar_event.start
String representation of the start date or date time of the calendar event e.g. 2022-04-10, or 2022-04-10 11:30:00-07:00
trigger.calendar_event.end
String representation of the end time of date time the calendar event in UTC e.g. 2022-04-11, or 2022-04-10 11:45:00-07:00
trigger.calendar_event.all_day
Indicates the event spans the entire day.
trigger.calendar_event.description
A detailed description of the calendar event, if available.
trigger.calendar_event.location
Location information for the calendar event, if available.
# Example configuration.yaml entriesautomation:trigger:- platform:stateentity_id:device_tracker.paulusid:paulus_deviceaction:- service:notify.notifydata:message:> Paulus just changed from {{ trigger.from_state.state }}
to {{ trigger.to_state.state }}
This was triggered by {{ trigger.id }}automation 2:trigger:- platform:mqtttopic:"/notify/+"action:service:> notify.{{ trigger.topic.split('/')[-1] }}data:message:"{{ trigger.payload }}"automation 3:trigger:# Multiple entities for which you want to perform the same action.- platform:stateentity_id:- light.bedroom_closet- light.kiddos_closet- light.linen_closetto:"on"# Trigger when someone leaves one of those lights on for 10 minutes.for:"00:10:00"action:- service:light.turn_offtarget:# Turn off whichever entity triggered the automation.entity_id:"{{ trigger.entity_id }}"