From 11b9225db76dc170c41ebf56db96dcfd9da8eaf2 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Tue, 5 Apr 2022 18:55:56 +0200 Subject: [PATCH] 2022.4: Variables on trigger --- .../_posts/2022-04-06-release-20224.markdown | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/source/_posts/2022-04-06-release-20224.markdown b/source/_posts/2022-04-06-release-20224.markdown index c0d852179a1..fcd4af10d0a 100644 --- a/source/_posts/2022-04-06-release-20224.markdown +++ b/source/_posts/2022-04-06-release-20224.markdown @@ -391,11 +391,13 @@ For the latest information about all available selectors and their options, ## Variables on trigger -TODO: - - Needs content +For the more advanced uses cases, this release provides: variables on trigger. +It is exactly what it says on the can: The possibility of setting variables +on triggers that become available when that specific trigger triggers. -We now support setting variables on trigger, that become available when that -trigger triggers. +These variables can be helpful to pass down specific information based on the +trigger that fired. The automation example below shows how a message can be +passed to the notify service based on its triggering motion sensor. {% raw %} @@ -403,9 +405,15 @@ trigger triggers. automation: trigger: - platform: state - entity_id: binary_sensor.motion + entity_id: binary_sensor.motion_garage + to: "on" variables: - trigger_message: "Motion sensor got triggered!" + trigger_message: "Motion detected in the garage! 🚘" + - platform: state + entity_id: binary_sensor.motion_garden + to: "on" + variables: + trigger_message: "Motion detected in the garden! 🌷" action: - service: notify.iphone data: @@ -414,7 +422,7 @@ automation: {% endraw %} -[Updated selectors documentation](/docs/automation/trigger/#trigger-variables) +Oh! And yes: these variables can use templates too! ## Other noteworthy changes