Unlock on arrival with redundant presence sensors and door contact


#1

1) Give a description of the problem
Does not work
2) What is the expected behaviour?
unlock front door when smartthings presence changed to present in last 5 minutes, wifi presence present in last 2 minutes, and storm door is opened.

3) What is happening/not happening?
never triggering

4) Post a Green Snapshot of the pistonimage

5) Attach logs after turning logging level to Full*
8/6/2019, 9:37:30 PM +651ms
+2ms ╔Received event [Front Storm Door].contact = closed with a delay of 106ms
+232ms ║RunTime Analysis CS > 18ms > PS > 46ms > PE > 167ms > CE
+234ms ║Runtime (42006 bytes) successfully initialized in 46ms (v0.3.109.20181207) (232ms)
+235ms ║╔Execution stage started
+250ms ║║Condition #5 evaluated false (9ms)
+253ms ║║Comparison (enum) closed changes_to (string) open = false (0ms)
+255ms ║║Cancelling condition #6’s schedules…
+256ms ║║Condition #6 evaluated false (6ms)
+257ms ║║Cancelling condition #4’s schedules…
+258ms ║║Condition group #4 evaluated false (state changed) (17ms)
+259ms ║║Condition group #1 evaluated false (state did not change) (19ms)
+261ms ║╚Execution stage complete. (25ms)
+262ms ╚Event processed successfully (261ms)
8/6/2019, 9:37:00 PM +306ms
+1ms ╔Received event [Front Storm Door].contact = open with a delay of 161ms
+119ms ║RunTime Analysis CS > 18ms > PS > 45ms > PE > 55ms > CE
+121ms ║Runtime (42016 bytes) successfully initialized in 45ms (v0.3.109.20181207) (119ms)
+122ms ║╔Execution stage started
+137ms ║║Condition #5 evaluated false (10ms)
+141ms ║║Comparison (enum) open changes_to (string) open = true (1ms)
+143ms ║║Cancelling condition #6’s schedules…
+144ms ║║Condition #6 evaluated true (6ms)
+145ms ║║Cancelling condition #4’s schedules…
+146ms ║║Condition group #4 evaluated true (state changed) (19ms)
+169ms ║║Comparison (enum) present changed = true (15ms)
+170ms ║║Cancelling condition #9’s schedules…
+171ms ║║Condition #9 evaluated true (23ms)
+206ms ║║Comparison (enum) present changed = false (30ms)
+207ms ║║Condition #10 evaluated false (35ms)
+208ms ║║Condition group #8 evaluated false (state did not change) (60ms)
+232ms ║║Comparison (enum) not present changed = false (18ms)
+234ms ║║Condition #13 evaluated false (24ms)
+235ms ║║Condition group #12 evaluated false (state did not change) (26ms)
+236ms ║║Condition group #7 evaluated false (state did not change) (89ms)
+237ms ║║Condition group #1 evaluated false (state did not change) (111ms)
+239ms ║╚Execution stage complete. (117ms)
+241ms ╚Event processed successfully (241ms)
8/6/2019, 9:36:52 PM +621ms
+1ms ╔Received event [Josh’s iPhone WiFi].presence = present with a delay of 67ms
+204ms ║RunTime Analysis CS > 17ms > PS > 36ms > PE > 151ms > CE
+206ms ║Runtime (42022 bytes) successfully initialized in 36ms (v0.3.109.20181207) (204ms)
+207ms ║╔Execution stage started
+222ms ║║Condition #5 evaluated false (9ms)
+228ms ║║Condition #6 evaluated false (6ms)
+229ms ║║Condition group #4 evaluated false (state did not change) (17ms)
+230ms ║║Condition group #1 evaluated false (state did not change) (19ms)
+232ms ║╚Execution stage complete. (25ms)
+233ms ╚Event processed successfully (233ms)
8/6/2019, 9:35:12 PM +797ms
+1ms ╔Received event [Josh’s iPhone].presence = present with a delay of 75ms
+111ms ║RunTime Analysis CS > 18ms > PS > 44ms > PE > 48ms > CE
+113ms ║Runtime (42016 bytes) successfully initialized in 44ms (v0.3.109.20181207) (111ms)
+114ms ║╔Execution stage started
+129ms ║║Condition #5 evaluated false (9ms)
+136ms ║║Condition #6 evaluated false (7ms)
+137ms ║║Condition group #4 evaluated false (state did not change) (19ms)
+138ms ║║Condition group #1 evaluated false (state did not change) (19ms)
+139ms ║╚Execution stage complete. (25ms)
+140ms ╚Event processed successfully (140ms)


#2


Just a suggestion…change to motion changes to active


#3

Thanks for pointing that out, the motion sensors have proved to be unreliable anyhow so I changed to door contact.


#4

Hi there,
My uneducated opinion is,
A lot must happen AND must happen precisely for your piston to execute.
a couple of things to consider:

  • Presense sensors are NOT fully reliable. Sometimes I arrive home and presense changes to HOME after 40-50 seconds.
  • Motion sensors remain active for a limited amout of time. If yours has a blind spot (12 and 5) IS ACTIVE won’t help your piston.

I’m not saying your idea won’t work, i’m just saying it may fail time to time.
I’d say simplify.
ps : I always add this to security related pistons. Sorry if i’m repeating my self. I’d never trust SmartHome with UNLOCKING my door…


#5

Ditto…


#6

Absolutely!


#7

I understand the security risks, if it makes you feel any better just imagine my door lock is a lightbulb. Here is a log for when I arrived home tonight, everything happened perfectly in line, however the command was not executed:
8/6/2019, 9:37:30 PM +651ms
+2ms ╔Received event [Front Storm Door].contact = closed with a delay of 106ms
+232ms ║RunTime Analysis CS > 18ms > PS > 46ms > PE > 167ms > CE
+234ms ║Runtime (42006 bytes) successfully initialized in 46ms (v0.3.109.20181207) (232ms)
+235ms ║╔Execution stage started
+250ms ║║Condition #5 evaluated false (9ms)
+253ms ║║Comparison (enum) closed changes_to (string) open = false (0ms)
+255ms ║║Cancelling condition #6’s schedules…
+256ms ║║Condition #6 evaluated false (6ms)
+257ms ║║Cancelling condition #4’s schedules…
+258ms ║║Condition group #4 evaluated false (state changed) (17ms)
+259ms ║║Condition group #1 evaluated false (state did not change) (19ms)
+261ms ║╚Execution stage complete. (25ms)
+262ms ╚Event processed successfully (261ms)
8/6/2019, 9:37:00 PM +306ms
+1ms ╔Received event [Front Storm Door].contact = open with a delay of 161ms
+119ms ║RunTime Analysis CS > 18ms > PS > 45ms > PE > 55ms > CE
+121ms ║Runtime (42016 bytes) successfully initialized in 45ms (v0.3.109.20181207) (119ms)
+122ms ║╔Execution stage started
+137ms ║║Condition #5 evaluated false (10ms)
+141ms ║║Comparison (enum) open changes_to (string) open = true (1ms)
+143ms ║║Cancelling condition #6’s schedules…
+144ms ║║Condition #6 evaluated true (6ms)
+145ms ║║Cancelling condition #4’s schedules…
+146ms ║║Condition group #4 evaluated true (state changed) (19ms)
+169ms ║║Comparison (enum) present changed = true (15ms)
+170ms ║║Cancelling condition #9’s schedules…
+171ms ║║Condition #9 evaluated true (23ms)
+206ms ║║Comparison (enum) present changed = false (30ms)
+207ms ║║Condition #10 evaluated false (35ms)
+208ms ║║Condition group #8 evaluated false (state did not change) (60ms)
+232ms ║║Comparison (enum) not present changed = false (18ms)
+234ms ║║Condition #13 evaluated false (24ms)
+235ms ║║Condition group #12 evaluated false (state did not change) (26ms)
+236ms ║║Condition group #7 evaluated false (state did not change) (89ms)
+237ms ║║Condition group #1 evaluated false (state did not change) (111ms)
+239ms ║╚Execution stage complete. (117ms)
+241ms ╚Event processed successfully (241ms)
8/6/2019, 9:36:52 PM +621ms
+1ms ╔Received event [Josh’s iPhone WiFi].presence = present with a delay of 67ms
+204ms ║RunTime Analysis CS > 17ms > PS > 36ms > PE > 151ms > CE
+206ms ║Runtime (42022 bytes) successfully initialized in 36ms (v0.3.109.20181207) (204ms)
+207ms ║╔Execution stage started
+222ms ║║Condition #5 evaluated false (9ms)
+228ms ║║Condition #6 evaluated false (6ms)
+229ms ║║Condition group #4 evaluated false (state did not change) (17ms)
+230ms ║║Condition group #1 evaluated false (state did not change) (19ms)
+232ms ║╚Execution stage complete. (25ms)
+233ms ╚Event processed successfully (233ms)
8/6/2019, 9:35:12 PM +797ms
+1ms ╔Received event [Josh’s iPhone].presence = present with a delay of 75ms
+111ms ║RunTime Analysis CS > 18ms > PS > 44ms > PE > 48ms > CE
+113ms ║Runtime (42016 bytes) successfully initialized in 44ms (v0.3.109.20181207) (111ms)
+114ms ║╔Execution stage started
+129ms ║║Condition #5 evaluated false (9ms)
+136ms ║║Condition #6 evaluated false (7ms)
+137ms ║║Condition group #4 evaluated false (state did not change) (19ms)
+138ms ║║Condition group #1 evaluated false (state did not change) (19ms)
+139ms ║╚Execution stage complete. (25ms)
+140ms ╚Event processed successfully (140ms)


#8

looking at 8/6/2019, 9:37:00 PM it looks like wifi presence changed in the last 2 minutes evaluated false, although the event right before at 8/6/2019, 9:36:52 PM was wifi presence changing to present…


#9

Can you give us a green shot of the TRACE piston? Thanks.


#10

I’ve updated the OP with Trace screenshot. although last event is storm door closing so first group is false.


#11

I’m sorry. It has been a long day and I am just not following what you are doing in your piston. Can you please walk me through it and describe your triggers and what should be happening? Thanks.


#12

that’s fine. Your house, your life.
And we still have lots of unanswered questions about your piston…


#13

unlock front door when storm door is opened and Phone A’s smartthings presence changed to present in the last 5 minutes and Phone A connected to the home wifi in the last 2 minutes, or the same conditions for Phone B.


#14

There are several methods to detect presence. Each has its own pluses and minuses. I suggest you read through Presence Detection by JDRoberts. He addresses some of the limitations of presence sensing. JDRoberts is one of my go-to tech guys. He puts lots of time into studying the technical manuals and real life applications of lots of devices. As he mentions, presence detection can work well for some and can be quite frustrating for others. My own personal phone presence sensor testing revealed marked differences in detection times and distances.

With that caveat, first, you have 8 triggers in your piston.

You did not mention the motion sensors, so I will leave them out for now. Let’s simplify your piston and just use phone A and your storm door contact sensor. Once you get phone A working, then you can add in phone B. Or, as many here do, you can divide the two phones into two different pistons, thus making coding and debugging much easier. Understand that this is just my suggestion. Others here may have better/easier suggestions and I welcome their comments. I do not use presence to unlock any locks/doors so I cannot easily test my suggestions.

execute
IF Contact Sensor 4 changes to open
AND
Presence Sensor 2 presence changed in the last 5 minutes
AND
Presence Sensor 3 presence changed in the last 2 minutes
AND
Presence Sensor 2 and Presence Sensor 3 are present
   THEN
      WITH Lock 1
         DO
            Unlock
            Log message
      END WITH
END IF
end execute

Do you really need
Presence Sensor 2 and Presence Sensor 3 are present ?
I would presume that the previous 2 presence changes indicate that Sensor 2 and Sensor 3 are present. But maybe you have some reason.


#15

One thing to remember is that piston triggers may fire in both directions. This is from another discussion from @WCmore

So, another way you may code this is to put your presence sensors in another IF…

    IF contact Sensor 4 changes to open
       THEN
          IF presence  Sensor 2 presence changed in the last 5 mintes
             AND
             presence Sensor 3 changed in the last 2 minutes
             THEN
                 Unlock

#16

Thanks for the suggestions, I will try simplifying and dividing.

without this it would also unlock if I left within the last 2 minutes and someone else opens the storm door, as there doesn’t seem to be a Presence Sensor presence changed TO PRESENT in the last x. unless there is a simpler way to do this.

I realize that the piston fires a lot how it is written, is this something that has detrimental consequences? I will try rewriting as suggested.


#17

Probably not a problem in your case. However, some of us here have over 100 pistons running on a daily basis. So functionality could become a local problem with unnecessary executions.