Looking for some assistance in creating an automation for my front door. I essentially want it to unlock if i enter the zone, but only lock back up again if i dont open the door within a 10 minute timeframe. If i end up opening the door, i just want the automation to stop. ive tried a few different combinations of if/then and wait for trigger, but i cant seem to wrap my head around how to make this work. would prefer if it were possible through the UI as im not very comfortable with editing yaml yet
#Unlock door, then lock door again only if it hasn't been opened after 10 minutes
63 messages · Page 1 of 1 (latest)
the “wait for trigger” with the continue on timeout option would be perfect if it allowed two separate outputs for whether or not it was triggered during the time frame set, but this does not appear to be the case
You can with a if block and the wait variables. https://www.home-assistant.io/docs/scripts/#wait-variable
im assuming this cannot be done with the visual editor?
i dont see any way to add an if statement on the tail end of a wait for trigger action
you just add the if after it, it doesn't have to be attached to the wait
you'll need a template condition though to check the variable, but all can be done in the visual editor
this is where im at currently, just trying to figure out how what exactly to enter for the template
either {{ wait.completed }} or {{ not wait.completed }} depending on which way you want to go
this look good?
the wait for action and the if action are separate. is the template If portion smart enough to know that im referring to the previously completed wait for action?
no quotes in the template selector
done
yes the wait variable will continue to exist for all steps after the wait (I guess until you do another wait it will be overwritten)
ahh okay cool. i assume thats how all variables work? ive seen the "define variable" option, so im assuming thats something that creates a variable that persists throughout the rest of the automation?
there are some scope issues I believe, like it will only exist for the rest of the current subsequence
makes sense
I think e.g. you can't define a variable inside an if sequence, it will be gone outside of it
so in this instance, if i open the door before the timeout, the variable will reflect not wait.completed? or wait.trigger? and itll trigger the 'else' portion of the if/then/else?
The behavior is documented in the link posted above. Otherwise just try it and see.
alright
looks like trigger response is "null", so it didnt trigger the "then" portion of my if/then/else
should i switch it back to not complete and just swap my then and else around?
i dropped the time to 10 seconds btw, so that it would complete the timeout
hmm, what does the trace look like?
doc says wait.completed should be true or false
maybe share the trace?
remaining: 0
trigger: null```
thats the changed variable from the wait portion of the trace
ok. I guess maybe false just becomes nothing
or maybe doc is wrong
but it looks like completed will be true if it "triggers", or otherwise false/null if it times out
so if it triggers it should reflect wait.completed?
if your trigger fires, wait.completed will be true
ohhh wait I'm wrong
Says wait.completed only exists after wait_template
wait.trigger exists for wait_for_trigger
sorry misread that
so you need to use wait.trigger variable, not wait.completed
wait.trigger
Exists only after wait_for_trigger. Contains information about which trigger fired. (See Available-Trigger-Data.) Will be none if no trigger happened before timeout expired
so "wait.trigger" and swap my then and else, or "not wait.trigger" and leave them alone? or does it even matter
I think you can write wait.trigger == none or wait.trigger != none, depending on which branch you want to take
would it be null instead of none?
still didnt seem to work for some reason
even though the changed variable still reflects trigger: null
I see I have some automations where I'm using == none
maybe try none. I'm not an expert in this nullish jinja stuff 😵
looks like that did the trick!
thank you very much!
one last question, i have two triggers on this, one for if i enter the zone, and one if my gf enters the zone. if we enter in together, is the automation smart enough to not run a second instance if the first instance is already underway?
depends on the mode you set
im not sure what that means specifically
menu