#Some questions about "Wait for Trigger"

10 messages · Page 1 of 1 (latest)

faint salmon
#

The script documentation (https://www.home-assistant.io/docs/scripts/#wait-for-a-trigger) says Wait for Trigger "can use the same triggers that are available in an automation's triggers section.

  1. Is that documentation specific to scripts? Or does that still apply to using wait_for_trigger: in a basic automation?

  2. Does that mean I can only wait for something that already trigger's the automation? Or is that intended to mean "You can wait for all the same things that can be used to trigger scripts"?

Lastly, in the triggers section I can give each trigger a named ID and then use condition:trigger. wait_for_trigger: supports multiple triggers (with logical or), and triggers added the GUI does let me assign IDs to triggers in a wait_for_trigger: block.

  1. Is there something like condition: trigger; id: trigger_id to see which trigger was seen by the wait_for_trigger? From experimentation, it looks like condition:trigger only looks at what initially triggered the automation, not what caused the wait_for_trigger to complete.
Home Assistant

Documentation for the Home Assistant Script Syntax.

cloud pivot
#

the "action" in an automation is just a script

#

the action in an automation doesn't run until the automation trigger happens and any conditions pass

#

yes, there's a whole section about the "wait" variable

faint salmon
#

thanks!

floral cedar
#

If you want to use a trigger id from a wait_for_trigger you need to use a template condition with a template like
{{ wait.trigger.id == 'banana' }}

faint salmon
#

ok, great. That's what I was just setting up, but I won't be able to test it for a while. Now I'm more confident I did it right.

#

And just to confirm, can the triggers in the wait_for_trigger: be completely different from the original triggers up in the triggers: section?

#

it sounds like they should be completely separate (since wait_for_trigger happens in the embedded script that's running)