Lock doors after leaving w/notifications


#1

Hello all-

I have been searching this forum with no luck. I figured what I was looking to do was pretty basic and common, but maybe not? I am looking to design a piston that locked the doors whenever they are left unlocked and it detects a presence sensor has left. I can reliably get it to do that, but I would also like to know which do was left unlocked. In my attempts to do this i created a dynamic notification using a system variable. However, I am not sure I understand fully how they work. I tried used {$currentEventDevice} & {$previousEventDevice}, but my results come back with the presence sensor name and the word “Home” respectively. I don’t know what would happen if both doors were left unlocked.

My guess is I need to assign the locks to a variable and then call the variable in the notification. I am not sure how to go about doing this. I am really new to coding this stuff myself and don’t have a coding background. Has anyone already done this or can someone help me create this piston?

Thanks in advance for any help (and I apologize if this was covered elsewhere, i just couldn’t find it searching).

-Jason


#2

Haven’t tried it but something like this may work?


#3

Thanks, I will load this up and give it a try. Will this execute if any of the presence sensors change to not present or does it require they all be not present? I see there is an and between the presence sensors and I am not sure if that is part of the statement or just part of the list of presence sensors.

Thanks again!


#4

Because they are all stored in a device variable it’s just listing them all at the top that’s why there’s an “and” before the last one. Obviously you will need to edit the variables at the top to your presence sensors and locks.
Leave the UnlockedDoors one empty this will set itself.

I’ve set it up so if any of them leave it will execute but it’s very easily changeable. Just click on the variable in line 24 and change the top yellow box from any to all.


#5

Ok, after I dug in a little bit i can see where it does say any. I just tested this and it does lock the doors when I leave, but the notification doesn’t send. I am a little confused as to why because that seems to be the easy straightforward part of this.

Any idea?


#6

Have you enabled contacts on your st account? If not you could just change the notification to send notification. It’s currently set to send notification to contacts and that only works if you have enabled contacts.


#7

I did enable that last year when i found out there was a way to. It seems to have fixed itself. It does now send off notifications. However, if I leave both doors unlocked, it sends me a message that says they were both left unlocked, but immediately after the lock that was not locked first sends another notification saying it was left open. Is there a way to maybe pause the piston after it sends the first notification so that if it re-checks it in 5-10 seconds it will see the second door was locked? I found the way to pause the piston for a few seconds after the notification, but I am not sure if that will fix the 2 notification issue. What do you think?


#8

Maybe this might work better?

I think because there were 2 locks open it was sending the lock command to both locks but between each locking command it was also sending the notification.
Now it “should” only send the notification once after it has locked the door/doors.


#9

Ok, thanks, I’ll give it a try and see how it works. Appreciate your help!