#Unlock door, then lock door again only if it hasn't been opened after 10 minutes

63 messages · Page 1 of 1 (latest)

proper patio
#

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

#

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

pine moon
proper patio
#

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

rancid walrus
#

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

proper patio
#

this is where im at currently, just trying to figure out how what exactly to enter for the template

rancid walrus
#

either {{ wait.completed }} or {{ not wait.completed }} depending on which way you want to go

proper patio
#

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?

rancid walrus
#

no quotes in the template selector

proper patio
#

done

rancid walrus
#

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)

proper patio
#

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?

rancid walrus
#

there are some scope issues I believe, like it will only exist for the rest of the current subsequence

proper patio
#

makes sense

rancid walrus
#

I think e.g. you can't define a variable inside an if sequence, it will be gone outside of it

proper patio
#

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?

rancid walrus
#

The behavior is documented in the link posted above. Otherwise just try it and see.

proper patio
#

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

rancid walrus
#

hmm, what does the trace look like?

#

doc says wait.completed should be true or false

#

maybe share the trace?

proper patio
#
  remaining: 0
  trigger: null```
#

thats the changed variable from the wait portion of the trace

rancid walrus
#

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

proper patio
#

so if it triggers it should reflect wait.completed?

rancid walrus
#

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

proper patio
#

so "wait.trigger" and swap my then and else, or "not wait.trigger" and leave them alone? or does it even matter

rancid walrus
#

I think you can write wait.trigger == none or wait.trigger != none, depending on which branch you want to take

proper patio
#

would it be null instead of none?

rancid walrus
#

maybe

#

yeah try null

proper patio
#

still didnt seem to work for some reason

#

even though the changed variable still reflects trigger: null

rancid walrus
#

I see I have some automations where I'm using == none

#

maybe try none. I'm not an expert in this nullish jinja stuff 😵

proper patio
#

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?

rancid walrus
#

depends on the mode you set

proper patio
#

im not sure what that means specifically

rancid walrus
#

Change Mode option in the dotsvertical menu

#

the dialog should explain

proper patio
#

😮

#

didnt even know that existed

#

thank you

#

okay cool, it was on "single" which is what i need