Automatically lock the door (with a contact sensor)


#1

1) Give a description of the problem
Let me first say that I’ve done plenty of searching before reluctantly asking what may be a dumb question. I’ve tried multiple methods to accomplish this task, but nothing seems to work.

2) What is the expected behaviour?
I basically want my Yale Assure lock to automatically lock if it is left unlocked (manually unlocked from the interior, for example), but if the contact sensor is or changes to open, to wait until the contact sensor closes again before locking.

3) What is happening/not happening?
Nothing is happening in either piston. If I manually unlock the door from the inside, I can see the piston kick off, but the lock is never re-locked, even if I leave the door closed (sensor stays closed).

4) Post a Green Snapshot of the pistonimage
Piston #1:

Piston #2:

5) Attach logs after turning logging level to Full
Piston #1 Log:

5/31/2020, 8:44:03 AM +994ms
+1ms 	+Received event [Front Door Lock].lock = unlocked with a delay of 130ms
+61ms 	¦RunTime Analysis CS > 13ms > PS > 31ms > PE > 16ms > CE
+63ms 	¦Runtime (39466 bytes) successfully initialized in 31ms (v0.3.110.20191009) (62ms)
+64ms 	¦+Execution stage started
+72ms 	¦¦Comparison (enum) unlocked changes_to_any_of (string) unknown,unlocked,unlocked with timeout = true (2ms)
+73ms 	¦¦Cancelling condition #28's schedules...
+74ms 	¦¦Condition #28 evaluated true (7ms)
+81ms 	¦¦Comparison (enum) closed is (string) closed = true (1ms)
+82ms 	¦¦Condition #39 evaluated true (7ms)
+83ms 	¦¦Cancelling condition #27's schedules...
+84ms 	¦¦Condition group #27 evaluated true (state changed) (17ms)
+86ms 	¦¦Cancelling statement #29's schedules...
+91ms 	¦¦Executed virtual command [Front Door Lock].wait (1ms)
+92ms 	¦¦Requesting a wake up for Sun, May 31 2020 @ 8:44:09 AM EDT (in 5.0s)
+96ms 	¦+Execution stage complete. (33ms)
+97ms 	¦Setting up scheduled job for Sun, May 31 2020 @ 8:44:09 AM EDT (in 4.997s)
+104ms 	+Event processed successfully (104ms)
5/31/2020, 8:43:41 AM +505ms
+1ms 	+Starting piston... (v0.3.110.20191009)
+96ms 	¦+Subscribing to devices...
+113ms 	¦¦Subscribing to Front Door Sensor.contact...
+122ms 	¦¦Subscribing to Front Door Lock.lock...
+168ms 	¦+Finished subscribing (74ms)
+191ms 	¦Cancelling condition #28's schedules...
+199ms 	¦Comparison (enum) closed is (string) closed = true (1ms)
+202ms 	¦Cancelling condition #27's schedules...
+218ms 	¦Comparison (enum) closed is (string) open = false (1ms)
+236ms 	+Piston successfully started (235ms)

Piston #2 Log:

5/31/2020, 8:46:46 AM +271ms
+2ms 	+Received event [Front Door Lock].lock = unlocked with a delay of 392ms
+97ms 	¦RunTime Analysis CS > 22ms > PS > 55ms > PE > 19ms > CE
+99ms 	¦Runtime (39440 bytes) successfully initialized in 55ms (v0.3.110.20191009) (96ms)
+100ms 	¦+Execution stage started
+108ms 	¦¦Comparison (enum) unlocked changes_to_any_of (string) unlocked,unlocked with timeout = true (2ms)
+109ms 	¦¦Cancelling condition #28's schedules...
+110ms 	¦¦Condition #28 evaluated true (6ms)
+118ms 	¦¦Comparison (enum) closed is_any_of (string) closed = true (1ms)
+119ms 	¦¦Condition #29 evaluated true (8ms)
+120ms 	¦¦Cancelling condition #27's schedules...
+121ms 	¦¦Condition group #27 evaluated true (state changed) (17ms)
+123ms 	¦¦Cancelling statement #30's schedules...
+129ms 	¦¦Executed virtual command [Front Door Lock].wait (1ms)
+130ms 	¦¦Requesting a wake up for Sun, May 31 2020 @ 8:46:51 AM EDT (in 5.0s)
+134ms 	¦+Execution stage complete. (34ms)
+135ms 	¦Setting up scheduled job for Sun, May 31 2020 @ 8:46:51 AM EDT (in 4.996s)
+145ms 	+Event processed successfully (144ms)

I don’t know if it helps, but I’m basically just trying to replicate my old CoRE piston that worked up until recently (no idea what changed, other than SmartThings iOS updates). Here’s the basic workflow of it:

If Front Door Lock changes to unlocked
AND
Front Door Sensor contact is closed
THEN
Using Front Door Lock:
	-Wait 5 minutes
	-Lock
	-Cancel on condition or piston state change
BUT IF
Front Door Sensor contact changes to open
	When true:
		-using Front Door Lock:
			-Cancel all pending Local tasks
FOLLOWED BY
Front Door Sensor contact changes to closed
THEN
Using Front Door Lock:
	-Wait 5 minutes
	-Lock
	-Cancel on condition or piston state change

Any help would be immensely appreciated, as I’m trying to get the hang of webCoRE and replace other CoRE pistons with it.


#2

Instead of using the lock as a trigger, use the contact sensor as a trigger.

IF door contact sensor changes to closed
Wait 5 minutes
With door lock 
do lock.

IF door contact sensor changes to OPEN
Cancel all pending tasks

#3

One of my scenarios is my daughter randomly unlocking the door from the inside without actually opening the door. Assuming using the sensor as the trigger resolves other instances, would it be best to create a separate piston for locking the door if the door never actually opens?


#4

Sorry, also worth noting that I’d like the lock to eventually lock, even if the door opens at some point. I figured a While loop would work for that.


#5

Always.
I actually have 3 pistons guarding the locks:)
1 - Do the job
2 - Did you do the job
3 - Did the first 2 do the job.
:smile:

When it comes to security and safety, I barely rely/trust on smarthome.


#6

How would that actually look, though? I assume there’s a way to process pistons in a certain order (Lock if unlocked; lock if sensor changes to open; make sure those two actually locked?).


#7

3rd one gets triggered by the first 2 and checks the status of the lock.
a) Unlocked
b) Unkown
if it’s one of those I get an sms message…
“The door pistons have failed, door status is xyz”