Door knock piston that doesn't think any movement is a door knock


#1

1) Give a description of the problem
I’ve tried to put together a door knock piston for my screen door using a smartthings multipurpose sensor. I can’t filter out door knocks from motion you get from opening and closing a screen door.

2) What is the expected behavior?
In this piston a door knock is when acceleration changes to active and the screen door is closed. When I knock on the screen door, it should send me an sms saying “Door knocked”. If acceleration is detected but is immediately followed by the door opening, it should not send me an sms saying “Door knocked”. The act of closing the screen door should not send me an sms saying “Door Knocked”.

3) What is happening/not happening?
Knocking on the door while the screen door is closed seems to be working.

I’ve added a trigger that says the door should be closed for 2 seconds (does this mean the next 2 seconds?), so if the door is closed, and acceleration is detected followed by the door opening within 2 seconds, then it should no longer continue with the piston. I believe this is working.

When I close the door because there is obviously acceleration when closing the door and the door will be closed, it senses it as a door knock. So I added another condition that says that if the door’s contact state did not change in the last 3 seconds it should no longer continue with the piston. That is, before it was closed, it was open, so this condition should have caught that but it doesn’t. I still get a Door knocked sms.

I don’t know if there is a much simpler method of doing this but I’m completely stuck.

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach any logs (From ST IDE and by turning logging level to Full)

|+1ms|╔Received event [Front Screen Door].acceleration = active with a delay of 115ms|
|---|---|
|+124ms|║RunTime Analysis CS > 22ms > PS > 48ms > PE > 55ms > CE|
|+126ms|║Runtime (38170 bytes) successfully initialized in 48ms (v0.3.104.20180323) (125ms)|
|+127ms|║╔Execution stage started|
|+137ms|║║Comparison (enum) closed is (string) closed = true (1ms)|
|+138ms|║║Condition #62 evaluated true (7ms)|
|+141ms|║║Comparison (enum) active changes_to (string) active = true (1ms)|
|+142ms|║║Cancelling condition #32's schedules...|
|+143ms|║║Condition #32 evaluated true (4ms)|
|+149ms|║║Comparison (enum) closed stays (string) closed = true (1ms)|
|+151ms|║║Adding a timed trigger schedule for condition 63|
|+152ms|║║Cancelling condition #63's schedules...|
|+153ms|║║Condition #63 evaluated false (10ms)|
|+154ms|║║Condition group #29 evaluated false (state did not change) (22ms)|
|+156ms|║║Fast executing schedules, waiting for 1996ms to sync up|
|+2159ms|║║Cancelling condition #63's schedules...|
|+2159ms|║║Condition #63 evaluated true (1ms)|
|+2179ms|║║Comparison (enum) open did_not_change = true (15ms)|
|+2180ms|║║Cancelling condition #64's schedules...|
|+2181ms|║║Condition #64 evaluated true (21ms)|
|+2181ms|║║Cancelling condition #29's schedules...|
|+2182ms|║║Condition group #29 evaluated true (state changed) (25ms)|
|+2184ms|║║Cancelling statement #30's schedules...|
|+2201ms|║║Executed virtual command sendSMSNotification (12ms)|
|+2209ms|║╚Execution stage complete. (2082ms)|
|+2210ms|╚Event processed successfully (2210ms)|

Help troubleshooting a door knocking piston
#2

Well, without getting too complex, why not try:

IF screen door is opened
Then Set variable 'screen' = 1
End IF

If screen door is closed
Then Wait 5 seconds
Set variable 'screen' = 0
End IF

IF variable 'screen' is 0
AND
Acceleration is active
Then Wait 500 milliseconds
Send notification

#3

Thank you. I used this to build a new piston. I’m testing it now, but what I noticed immediately that now the times where acceleration is active before the screen door is opened will still send a door knocked notification.


#4

I was afraid of that.

Try changing the last block to something like this:

IF Acceleration is active
Then 
    DO Wait 800 milliseconds
        IF variable 'screen' is 0
        THEN Send Notification
        End IF
    End DO
End Then
End IF

I rarely use indented IF’s like this, but this should do it… (although that 800 ms delay may have to be tweaked a tad). The main thing is we want to give a brief moment for the variable to change if/when the door opens. Basically, this method forces the wait after the acceleration, yet before the notification is sent.

One question @leicam4, do you have a contact sensor on the screen door, wooden door or both?

Also, at the risk of stating the obvious…
Make sure you pause your other pistons connected to that sensor when testing this new piston. Otherwise the broken pistons will still send false alarms.


#5

I will try this. I didn’t really notice until now, but I see you used acceleration “is” active but I made the piston using “changes to”. Would this have affected the screen door opening immediately after the active acceleration?

When you originally wrote this:
IF variable ‘screen’ is 0
AND
Acceleration is active
Then Wait 500 milliseconds
Send notification

Was the wait 500 milliseconds to allow time in case the screen door was opened after active acceleration? I’m trying to wrap my head around when certain if statements are made false. During that wait time, if the screen door is opened, and the screen variable is set to 1, the last block if statement would reevaluate itself and change to false?

I am using the Smartthings multipurpose sensor that is both contact sensor and shock sensor on the screen door. But I also have a separate contact sensor on the normal wooden door behind it.

And also yes, I have paused the original original piston which had othere things I wanted activated after door knocks. The piston I posted on the original post was just the bare minimum version which I’ve overwritten with your code.

Thank you again!


#6

Good eye. “Changes to” is usually the approach I take on doors opening, but “Changes to” is only true for a split second, and then becomes false again. We wanted something that was true long enough for the door contact to open, and set the variable.

Yes, that was the plan. Although, now that I realize you have a door contact sensor on both doors, I have a better idea brewing… Give me a few to let the coffee kick in, and I will try to whip you up something…


#7

Real life needs me for a few hours, but I haven’t forgotten you. When you get a few minutes, will you test a modified version of my last two suggestions rolled into one like this:

IF screen door's contact changes to open
Then 
    Set variable 'screenOpen' = 1
End IF

IF Screen Door's Acceleration changes to active
Then 
    DO Wait 800 milliseconds
    Set variable 'screenActive' = 1
End IF

IF variable 'screenActive' = 1
-AND
Variable 'screenOpen' = 0
Then
    Send Notification
    Set variable 'screenActive' = 0
End IF

If screen door's contact changes to closed
Then 
    Set variable 'screenActive' = 0
    Set variable 'screenOpen' = 0
End IF

I believe this covers all scenarios. The 800 ms delay is to give your door time to open or not.


#8

I’m guessing there isn’t a direct comparison condition for checking if two sensors changed states within a set window of time. That is, door opens and acceleration active happened within 2 seconds of each other, then false. Or door closes and acceleration active happened within 2 seconds of each other, then false.


#9

Your first post attempted to do this, but you were unhappy with the results. The more things you are trying to compare simultaneously, the more likely it won’t do what you want. Notice in my code, it is only 1 or 2 things at most have to match for it to be true.

If you really want a 2 second delay (which likely means 4-5 seconds before your SMS comes thru) then you can change 800 ms to 2000 ms. I would venture to guess though that if someone was knocking on the screen, and they heard nothing in 4 seconds, they are likely to open the screen and knock on the wooden door. (at least, that’s what I would do)

I admit, my code above looks a bit complex, but it lets you control what changes, and when.


#10

I thought I just simply didn’t understand what conditions to use for what I was trying to do.

I like your method because you can set a state using a variable and when to set that state.

I’ve set up your newest piston, but it seems like nothing is working now. I’ll have to go through it again to see if I entered it incorrectly.

Thank you again!


#11

I am sorry, I don’t have extra devices laying around to set it up myself and test. Can you take a green camera and upload the picture here so I can look at it?


#12

For some reason the variables stay screenopen=1 and screenactive=1 even after the screendoor was open then closed and stays closed.


#13

Your code looks decent, although I would drop all 4 async commands. They should all be normal IF’s. In fact, async will break the 800 ms delay that is required to prevent false alarms.

Try this. I removed the asyncs and added 4 log points to help troubleshoot:


#14

I think I’m misunderstanding of the use of async ifs. I thought they were used so each of the ifs could run indpendent of the ifs that came before it.

I paused my old piston and created one based on your backup code. Unfortunately, I’m still having a problem with ScreenActive and ScreenOpen staying as 1 after the screen door has closed. I will try to use “is” instead of “changed to” for the screendoor closed block.

I’ve added the log below.

5/27/2018, 7:58:27 AM +216ms
+1ms	╔Received event [Front Screen Door].acceleration = inactive with a delay of 248ms
+104ms	║RunTime Analysis CS > 18ms > PS > 53ms > PE > 34ms > CE
+107ms	║Runtime (41975 bytes) successfully initialized in 53ms (v0.3.104.20180323) (104ms)
+108ms	║╔Execution stage started
+122ms	║║Condition #62 evaluated false (8ms)
+123ms	║║Condition group #29 evaluated false (state did not change) (10ms)
+129ms	║║Comparison (enum) inactive changes_to (string) active = false (0ms)
+131ms	║║Condition #89 evaluated false (5ms)
+132ms	║║Condition group #85 evaluated false (state did not change) (6ms)
+138ms	║║Comparison (dynamic) 1 is (integer) 1 = true (1ms)
+140ms	║║Condition #69 evaluated true (5ms)
+144ms	║║Comparison (dynamic) 1 is (integer) 0 = false (1ms)
+146ms	║║Condition #92 evaluated false (5ms)
+147ms	║║Condition group #65 evaluated false (state did not change) (13ms)
+155ms	║║Condition #84 evaluated false (5ms)
+156ms	║║Condition group #70 evaluated false (state did not change) (7ms)
+158ms	║╚Execution stage complete. (50ms)
+159ms	╚Event processed successfully (160ms)
5/27/2018, 7:58:14 AM +343ms
+1ms	╔Received event [Front Screen Door].contact = closed with a delay of 263ms
+10093ms	║RunTime Analysis CS > 24ms > PS > 10035ms > PE > 33ms > CE
+10094ms	║Piston waited at a semaphore for 9989ms
+10096ms	║Runtime (42044 bytes) successfully initialized in 10035ms (v0.3.104.20180323) (10094ms)
+10097ms	║╔Execution stage started
+10106ms	║║Comparison (enum) closed changes_to (string) open = false (1ms)
+10108ms	║║Condition #62 evaluated false (4ms)
+10109ms	║║Condition group #29 evaluated false (state did not change) (6ms)
+10119ms	║║Cancelling condition #89's schedules...
+10120ms	║║Condition #89 evaluated false (7ms)
+10121ms	║║Cancelling condition #85's schedules...
+10121ms	║║Condition group #85 evaluated false (state changed) (10ms)
+10128ms	║║Comparison (dynamic) 1 is (integer) 1 = true (2ms)
+10129ms	║║Condition #69 evaluated true (5ms)
+10134ms	║║Comparison (dynamic) 1 is (integer) 0 = false (2ms)
+10135ms	║║Condition #92 evaluated false (5ms)
+10136ms	║║Condition group #65 evaluated false (state did not change) (12ms)
+10142ms	║║Comparison (enum) closed changes_to (string) closed = false (0ms)
+10144ms	║║Condition #84 evaluated false (5ms)
+10145ms	║║Condition group #70 evaluated false (state did not change) (5ms)
+10147ms	║╚Execution stage complete. (50ms)
+10148ms	╚Event processed successfully (10148ms)
5/27/2018, 7:58:14 AM +263ms
+2ms	╔Received event [Front Screen Door].acceleration = active with a delay of 235ms
+95ms	║RunTime Analysis CS > 17ms > PS > 49ms > PE > 29ms > CE
+98ms	║Runtime (41980 bytes) successfully initialized in 49ms (v0.3.104.20180323) (96ms)
+99ms	║╔Execution stage started
+112ms	║║Cancelling condition #62's schedules...
+113ms	║║Condition #62 evaluated false (7ms)
+114ms	║║Cancelling condition #29's schedules...
+114ms	║║Condition group #29 evaluated false (state changed) (10ms)
+121ms	║║Comparison (enum) active changes_to (string) active = true (1ms)
+123ms	║║Cancelling condition #89's schedules...
+123ms	║║Condition #89 evaluated true (5ms)
+124ms	║║Cancelling condition #85's schedules...
+125ms	║║Condition group #85 evaluated true (state changed) (8ms)
+128ms	║║Cancelling statement #86's schedules...
+131ms	║║Executed virtual command wait (1ms)
+132ms	║║Waiting for 800ms
+940ms	║║Executed virtual command setVariable (3ms)
+949ms	║║Accel changed to Active
+950ms	║║Executed virtual command log (1ms)
+960ms	║║Comparison (dynamic) 1 is (integer) 1 = true (2ms)
+962ms	║║Cancelling condition #69's schedules...
+963ms	║║Condition #69 evaluated true (8ms)
+969ms	║║Comparison (dynamic) 1 is (integer) 0 = false (2ms)
+971ms	║║Condition #92 evaluated false (7ms)
+972ms	║║Condition group #65 evaluated false (state did not change) (17ms)
+984ms	║║Condition #84 evaluated false (8ms)
+985ms	║║Condition group #70 evaluated false (state did not change) (9ms)
+989ms	║╚Execution stage complete. (890ms)
+991ms	╚Event processed successfully (990ms)
5/27/2018, 7:58:11 AM +231ms
+2ms	╔Received event [Front Screen Door].contact = open with a delay of 245ms
+102ms	║RunTime Analysis CS > 18ms > PS > 56ms > PE > 27ms > CE
+104ms	║Runtime (41980 bytes) successfully initialized in 56ms (v0.3.104.20180323) (101ms)
+105ms	║╔Execution stage started
+115ms	║║Comparison (enum) open changes_to (string) open = true (1ms)
+117ms	║║Cancelling condition #62's schedules...
+118ms	║║Condition #62 evaluated true (6ms)
+119ms	║║Cancelling condition #29's schedules...
+120ms	║║Condition group #29 evaluated true (state changed) (8ms)
+122ms	║║Cancelling statement #63's schedules...
+130ms	║║Executed virtual command setVariable (4ms)
+136ms	║║Screen changed to Open
+137ms	║║Executed virtual command log (1ms)
+148ms	║║Condition #89 evaluated false (7ms)
+149ms	║║Condition group #85 evaluated false (state did not change) (9ms)
+156ms	║║Comparison (dynamic) null is (integer) 1 = false (2ms)
+157ms	║║Condition #69 evaluated false (5ms)
+158ms	║║Condition group #65 evaluated false (state did not change) (6ms)
+165ms	║║Comparison (enum) open changes_to (string) closed = false (1ms)
+166ms	║║Condition #84 evaluated false (5ms)
+167ms	║║Condition group #70 evaluated false (state did not change) (6ms)
+169ms	║╚Execution stage complete. (64ms)
+171ms	╚Event processed successfully (170ms)

#15

Good idea. This was going to be my next suggestion if the above failed.

I am studying your log now…

11.231 sec = Screen Open
11.361 sec = Variable ScreenOpen set  (Quick response)
14.263 sec = Acceleration Active  (Triggered as door close?)
14.343 sec = Screen Closed
14.394 sec = Begin 800ms Delay for ScreenActive
15.203 sec = Variable ScreenActive set  (After our 800ms delay)
27.216 sec = Acceleration Inactive  (This is your accel timing out)

From this analysis, it looks like the door was only open for 3.1 seconds. Is that really how quick you can open both doors, walk thru, and then close the screen?

I was surprised that the acceleration took over 3 seconds to trigger after the door opened. It actually seems like the acceleration only triggered when the door finally closed, not when it opened. (with the extra vibration, I guess that makes sense)

Also to note, There was a 10 second delay when the door closed before checks happened. At that time, the door is no longer “changed to”. Changing it to “is” on door close should resolve that.

I think we are on the home stretch now. Would you change the last block to “If Screen Door’s contact is closed” … Save… Clear logs… and test again?

On a side note, when posting logs in the future, please also include a green snapshot so we can see the Condition numbers. It makes troubleshooting much easier.


#16

The time should be from opening screen door, walking through and closing the screen door.

I think if it senses acceleration after the door is opened it wouldn’t trigger the notification anyway since the screen door is opened. The problem I have is the random times when trying to open the screen door that it senses acceleration first then the door open. I’ve included a situation like that in the log below.

What causes this 10 second delay? I thought it was just some latency but it happened again according to the log.

I’ve cleared the log, and went through the following situations. Screen door knock (Notification sent. OK). Acceleration active immediately followed by screen door open (Notification sent. Not OK). And screen door closing which causes screen door close and acceleration active nearly simultaneously (No notification sent. OK).

5/27/2018, 12:54:45 PM +976ms
+1ms	╔Received event [Front Screen Door].acceleration = inactive with a delay of 260ms
+105ms	║RunTime Analysis CS > 14ms > PS > 36ms > PE > 54ms > CE
+107ms	║Runtime (41965 bytes) successfully initialized in 36ms (v0.3.104.20180323) (105ms)
+108ms	║╔Execution stage started
+121ms	║║Condition #62 evaluated false (7ms)
+122ms	║║Condition group #29 evaluated false (state did not change) (8ms)
+129ms	║║Comparison (enum) inactive changes_to (string) active = false (1ms)
+131ms	║║Condition #89 evaluated false (6ms)
+132ms	║║Condition group #85 evaluated false (state did not change) (7ms)
+139ms	║║Comparison (dynamic) 0 is (integer) 1 = false (2ms)
+140ms	║║Condition #69 evaluated false (5ms)
+141ms	║║Condition group #65 evaluated false (state did not change) (6ms)
+151ms	║║Comparison (enum) closed is (string) closed = true (2ms)
+152ms	║║Condition #84 evaluated true (8ms)
+153ms	║║Condition group #70 evaluated true (state did not change) (9ms)
+156ms	║║Cancelling statement #81's schedules...
+161ms	║║Executed virtual command setVariable (2ms)
+166ms	║║Executed virtual command setVariable (2ms)
+173ms	║║Screen changed to close
+174ms	║║Executed virtual command log (1ms)
+177ms	║╚Execution stage complete. (69ms)
+178ms	╚Event processed successfully (178ms)
5/27/2018, 12:54:33 PM +130ms
+1ms	╔Received event [Front Screen Door].contact = closed with a delay of 272ms
+10248ms	║RunTime Analysis CS > 25ms > PS > 10172ms > PE > 51ms > CE
+10249ms	║Piston waited at a semaphore for 10121ms
+10252ms	║Runtime (42035 bytes) successfully initialized in 10172ms (v0.3.104.20180323) (10249ms)
+10253ms	║╔Execution stage started
+10262ms	║║Comparison (enum) closed changes_to (string) open = false (1ms)
+10264ms	║║Condition #62 evaluated false (5ms)
+10265ms	║║Condition group #29 evaluated false (state did not change) (6ms)
+10274ms	║║Cancelling condition #89's schedules...
+10275ms	║║Condition #89 evaluated false (7ms)
+10276ms	║║Cancelling condition #85's schedules...
+10277ms	║║Condition group #85 evaluated false (state changed) (10ms)
+10283ms	║║Comparison (dynamic) 0 is (integer) 1 = false (1ms)
+10285ms	║║Cancelling condition #69's schedules...
+10286ms	║║Condition #69 evaluated false (6ms)
+10287ms	║║Condition group #65 evaluated false (state did not change) (7ms)
+10294ms	║║Comparison (enum) closed is (string) closed = true (2ms)
+10295ms	║║Condition #84 evaluated true (5ms)
+10296ms	║║Condition group #70 evaluated true (state did not change) (7ms)
+10299ms	║║Cancelling statement #81's schedules...
+10306ms	║║Executed virtual command setVariable (4ms)
+10312ms	║║Executed virtual command setVariable (3ms)
+10319ms	║║Screen changed to close
+10320ms	║║Executed virtual command log (1ms)
+10323ms	║╚Execution stage complete. (71ms)
+10324ms	╚Event processed successfully (10324ms)
5/27/2018, 12:54:33 PM +35ms
+1ms	╔Received event [Front Screen Door].acceleration = active with a delay of 259ms
+98ms	║RunTime Analysis CS > 14ms > PS > 37ms > PE > 47ms > CE
+100ms	║Runtime (41966 bytes) successfully initialized in 37ms (v0.3.104.20180323) (99ms)
+101ms	║╔Execution stage started
+114ms	║║Condition #62 evaluated false (7ms)
+115ms	║║Condition group #29 evaluated false (state did not change) (8ms)
+123ms	║║Comparison (enum) active changes_to (string) active = true (0ms)
+124ms	║║Cancelling condition #89's schedules...
+125ms	║║Condition #89 evaluated true (6ms)
+126ms	║║Cancelling condition #85's schedules...
+127ms	║║Condition group #85 evaluated true (state changed) (9ms)
+130ms	║║Cancelling statement #86's schedules...
+133ms	║║Executed virtual command wait (0ms)
+134ms	║║Waiting for 800ms
+987ms	║║Executed virtual command setVariable (3ms)
+996ms	║║Accel changed to Active
+998ms	║║Executed virtual command log (1ms)
+1008ms	║║Comparison (dynamic) 1 is (integer) 1 = true (2ms)
+1011ms	║║Cancelling condition #69's schedules...
+1012ms	║║Condition #69 evaluated true (10ms)
+1018ms	║║Comparison (dynamic) 1 is (integer) 0 = false (2ms)
+1019ms	║║Cancelling condition #92's schedules...
+1020ms	║║Condition #92 evaluated false (7ms)
+1021ms	║║Condition group #65 evaluated false (state did not change) (19ms)
+1032ms	║║Comparison (enum) closed is (string) closed = true (2ms)
+1034ms	║║Cancelling condition #84's schedules...
+1034ms	║║Condition #84 evaluated true (10ms)
+1036ms	║║Cancelling condition #70's schedules...
+1036ms	║║Condition group #70 evaluated true (state changed) (12ms)
+1039ms	║║Cancelling statement #81's schedules...
+1045ms	║║Executed virtual command setVariable (3ms)
+1051ms	║║Executed virtual command setVariable (3ms)
+1058ms	║║Screen changed to close
+1059ms	║║Executed virtual command log (1ms)
+1063ms	║╚Execution stage complete. (962ms)
+1064ms	╚Event processed successfully (1064ms)
5/27/2018, 12:54:30 PM +189ms
+3ms	╔Received event [Front Screen Door].acceleration = inactive with a delay of 626ms
+93ms	║RunTime Analysis CS > 14ms > PS > 37ms > PE > 41ms > CE
+96ms	║Runtime (41964 bytes) successfully initialized in 37ms (v0.3.104.20180323) (92ms)
+97ms	║╔Execution stage started
+110ms	║║Cancelling condition #62's schedules...
+110ms	║║Condition #62 evaluated false (8ms)
+111ms	║║Cancelling condition #29's schedules...
+112ms	║║Condition group #29 evaluated false (state changed) (10ms)
+119ms	║║Comparison (enum) inactive changes_to (string) active = false (0ms)
+120ms	║║Condition #89 evaluated false (5ms)
+121ms	║║Condition group #85 evaluated false (state did not change) (6ms)
+127ms	║║Comparison (dynamic) 0 is (integer) 1 = false (1ms)
+129ms	║║Condition #69 evaluated false (5ms)
+130ms	║║Condition group #65 evaluated false (state did not change) (7ms)
+139ms	║║Comparison (enum) open is (string) closed = false (2ms)
+141ms	║║Condition #84 evaluated false (7ms)
+141ms	║║Condition group #70 evaluated false (state did not change) (9ms)
+144ms	║╚Execution stage complete. (48ms)
+145ms	╚Event processed successfully (145ms)
5/27/2018, 12:54:18 PM +18ms
+2ms	╔Received event [Front Screen Door].contact = open with a delay of 347ms
+116ms	║RunTime Analysis CS > 23ms > PS > 49ms > PE > 44ms > CE
+119ms	║Runtime (41951 bytes) successfully initialized in 49ms (v0.3.104.20180323) (117ms)
+120ms	║╔Execution stage started
+130ms	║║Comparison (enum) open changes_to (string) open = true (0ms)
+131ms	║║Cancelling condition #62's schedules...
+132ms	║║Condition #62 evaluated true (6ms)
+133ms	║║Cancelling condition #29's schedules...
+134ms	║║Condition group #29 evaluated true (state changed) (9ms)
+136ms	║║Cancelling statement #63's schedules...
+142ms	║║Executed virtual command setVariable (3ms)
+149ms	║║Screen changed to Open
+150ms	║║Executed virtual command log (1ms)
+161ms	║║Cancelling condition #89's schedules...
+162ms	║║Condition #89 evaluated false (9ms)
+163ms	║║Cancelling condition #85's schedules...
+164ms	║║Condition group #85 evaluated false (state changed) (11ms)
+170ms	║║Comparison (dynamic) 0 is (integer) 1 = false (1ms)
+172ms	║║Cancelling condition #69's schedules...
+173ms	║║Condition #69 evaluated false (5ms)
+174ms	║║Cancelling condition #65's schedules...
+175ms	║║Condition group #65 evaluated false (state changed) (8ms)
+182ms	║║Comparison (enum) open is (string) closed = false (2ms)
+183ms	║║Cancelling condition #84's schedules...
+184ms	║║Condition #84 evaluated false (7ms)
+185ms	║║Cancelling condition #70's schedules...
+186ms	║║Condition group #70 evaluated false (state changed) (9ms)
+189ms	║╚Execution stage complete. (69ms)
+190ms	╚Event processed successfully (190ms)
5/27/2018, 12:54:16 PM +874ms
+1ms	╔Received event [Front Screen Door].acceleration = active with a delay of 255ms
+86ms	║RunTime Analysis CS > 13ms > PS > 37ms > PE > 35ms > CE
+88ms	║Runtime (41963 bytes) successfully initialized in 37ms (v0.3.104.20180323) (86ms)
+89ms	║╔Execution stage started
+102ms	║║Condition #62 evaluated false (7ms)
+103ms	║║Condition group #29 evaluated false (state did not change) (8ms)
+110ms	║║Comparison (enum) active changes_to (string) active = true (0ms)
+111ms	║║Cancelling condition #89's schedules...
+112ms	║║Condition #89 evaluated true (6ms)
+113ms	║║Cancelling condition #85's schedules...
+114ms	║║Condition group #85 evaluated true (state changed) (8ms)
+116ms	║║Cancelling statement #86's schedules...
+120ms	║║Executed virtual command wait (0ms)
+120ms	║║Waiting for 800ms
+927ms	║║Executed virtual command setVariable (2ms)
+934ms	║║Accel changed to Active
+935ms	║║Executed virtual command log (2ms)
+942ms	║║Comparison (dynamic) 1 is (integer) 1 = true (2ms)
+943ms	║║Cancelling condition #69's schedules...
+944ms	║║Condition #69 evaluated true (6ms)
+949ms	║║Comparison (dynamic) 0 is (integer) 0 = true (2ms)
+950ms	║║Condition #92 evaluated true (5ms)
+951ms	║║Cancelling condition #65's schedules...
+952ms	║║Condition group #65 evaluated true (state changed) (14ms)
+955ms	║║Cancelling statement #66's schedules...
+973ms	║║Executed virtual command sendSMSNotification (12ms)
+979ms	║║Executed virtual command setVariable (3ms)
+986ms	║║SMS sent
+987ms	║║Executed virtual command log (2ms)
+998ms	║║Comparison (enum) closed is (string) closed = true (1ms)
+999ms	║║Condition #84 evaluated true (9ms)
+1000ms	║║Condition group #70 evaluated true (state did not change) (10ms)
+1002ms	║║Cancelling statement #81's schedules...
+1008ms	║║Executed virtual command setVariable (2ms)
+1014ms	║║Executed virtual command setVariable (3ms)
+1021ms	║║Screen changed to close
+1021ms	║║Executed virtual command log (1ms)
+1024ms	║╚Execution stage complete. (935ms)
+1026ms	╚Event processed successfully (1025ms)
5/27/2018, 12:54:13 PM +511ms
+1ms	╔Received event [Front Screen Door].acceleration = inactive with a delay of 436ms
+86ms	║RunTime Analysis CS > 14ms > PS > 39ms > PE > 34ms > CE
+89ms	║Runtime (41959 bytes) successfully initialized in 39ms (v0.3.104.20180323) (87ms)
+90ms	║╔Execution stage started
+103ms	║║Condition #62 evaluated false (7ms)
+104ms	║║Condition group #29 evaluated false (state did not change) (8ms)
+111ms	║║Comparison (enum) inactive changes_to (string) active = false (0ms)
+112ms	║║Cancelling condition #89's schedules...
+113ms	║║Condition #89 evaluated false (6ms)
+114ms	║║Cancelling condition #85's schedules...
+115ms	║║Condition group #85 evaluated false (state changed) (8ms)
+122ms	║║Comparison (dynamic) 0 is (integer) 1 = false (2ms)
+123ms	║║Cancelling condition #69's schedules...
+124ms	║║Condition #69 evaluated false (6ms)
+125ms	║║Cancelling condition #65's schedules...
+126ms	║║Condition group #65 evaluated false (state changed) (8ms)
+136ms	║║Comparison (enum) closed is (string) closed = true (2ms)
+138ms	║║Condition #84 evaluated true (8ms)
+139ms	║║Condition group #70 evaluated true (state did not change) (9ms)
+141ms	║║Cancelling statement #81's schedules...
+147ms	║║Executed virtual command setVariable (2ms)
+152ms	║║Executed virtual command setVariable (2ms)
+159ms	║║Screen changed to close
+160ms	║║Executed virtual command log (1ms)
+163ms	║╚Execution stage complete. (73ms)
+164ms	╚Event processed successfully (164ms)
5/27/2018, 12:54:00 PM +392ms
+2ms	╔Received event [Front Screen Door].acceleration = active with a delay of 271ms
+101ms	║RunTime Analysis CS > 18ms > PS > 51ms > PE > 31ms > CE
+103ms	║Runtime (41964 bytes) successfully initialized in 51ms (v0.3.104.20180323) (101ms)
+104ms	║╔Execution stage started
+117ms	║║Condition #62 evaluated false (7ms)
+118ms	║║Condition group #29 evaluated false (state did not change) (8ms)
+125ms	║║Comparison (enum) active changes_to (string) active = true (0ms)
+126ms	║║Cancelling condition #89's schedules...
+127ms	║║Condition #89 evaluated true (6ms)
+128ms	║║Cancelling condition #85's schedules...
+129ms	║║Condition group #85 evaluated true (state changed) (8ms)
+131ms	║║Cancelling statement #86's schedules...
+135ms	║║Executed virtual command wait (0ms)
+135ms	║║Waiting for 800ms
+942ms	║║Executed virtual command setVariable (3ms)
+949ms	║║Accel changed to Active
+950ms	║║Executed virtual command log (1ms)
+957ms	║║Comparison (dynamic) 1 is (integer) 1 = true (1ms)
+959ms	║║Cancelling condition #69's schedules...
+960ms	║║Condition #69 evaluated true (7ms)
+964ms	║║Comparison (dynamic) 0 is (integer) 0 = true (1ms)
+966ms	║║Condition #92 evaluated true (5ms)
+967ms	║║Cancelling condition #65's schedules...
+968ms	║║Condition group #65 evaluated true (state changed) (14ms)
+970ms	║║Cancelling statement #66's schedules...
+989ms	║║Executed virtual command sendSMSNotification (13ms)
+996ms	║║Executed virtual command setVariable (3ms)
+1002ms	║║SMS sent
+1003ms	║║Executed virtual command log (1ms)
+1014ms	║║Comparison (enum) closed is (string) closed = true (1ms)
+1016ms	║║Condition #84 evaluated true (9ms)
+1017ms	║║Condition group #70 evaluated true (state did not change) (10ms)
+1019ms	║║Cancelling statement #81's schedules...
+1025ms	║║Executed virtual command setVariable (3ms)
+1031ms	║║Executed virtual command setVariable (2ms)
+1037ms	║║Screen changed to close
+1038ms	║║Executed virtual command log (1ms)
+1041ms	║╚Execution stage complete. (937ms)
+1042ms	╚Event processed successfully (1042ms)

#17

I am sorry to be a pain, but would you please clear the logs, test the failed example above, and repost the log?

Acceleration active immediately followed by screen door open (Notification sent. Not OK)

This will make my analysis a bit easier to dig thru. Thanks


#18

Ooh, sorry about that! Just cleared the logs and did the test again. And thank you again, I really appreciate your help!

5/28/2018, 7:20:41 AM +736ms
+1ms	╔Received event [Front Screen Door].acceleration = inactive with a delay of 1015ms
+88ms	║RunTime Analysis CS > 15ms > PS > 36ms > PE > 38ms > CE
+91ms	║Runtime (41965 bytes) successfully initialized in 36ms (v0.3.104.20180323) (89ms)
+92ms	║╔Execution stage started
+105ms	║║Cancelling condition #62's schedules...
+106ms	║║Condition #62 evaluated false (8ms)
+108ms	║║Cancelling condition #29's schedules...
+108ms	║║Condition group #29 evaluated false (state changed) (10ms)
+115ms	║║Comparison (enum) inactive changes_to (string) active = false (1ms)
+116ms	║║Condition #89 evaluated false (5ms)
+117ms	║║Condition group #85 evaluated false (state did not change) (6ms)
+124ms	║║Comparison (dynamic) 0 is (integer) 1 = false (2ms)
+126ms	║║Condition #69 evaluated false (5ms)
+127ms	║║Condition group #65 evaluated false (state did not change) (6ms)
+136ms	║║Comparison (enum) open is (string) closed = false (1ms)
+138ms	║║Condition #84 evaluated false (8ms)
+139ms	║║Condition group #70 evaluated false (state did not change) (10ms)
+141ms	║╚Execution stage complete. (49ms)
+143ms	╚Event processed successfully (142ms)
5/28/2018, 7:20:29 AM +867ms
+1ms	╔Received event [Front Screen Door].contact = open with a delay of 871ms
+89ms	║RunTime Analysis CS > 20ms > PS > 35ms > PE > 34ms > CE
+92ms	║Runtime (41950 bytes) successfully initialized in 35ms (v0.3.104.20180323) (89ms)
+93ms	║╔Execution stage started
+102ms	║║Comparison (enum) open changes_to (string) open = true (1ms)
+104ms	║║Cancelling condition #62's schedules...
+105ms	║║Condition #62 evaluated true (6ms)
+106ms	║║Cancelling condition #29's schedules...
+106ms	║║Condition group #29 evaluated true (state changed) (8ms)
+109ms	║║Cancelling statement #63's schedules...
+115ms	║║Executed virtual command setVariable (3ms)
+122ms	║║Screen changed to Open
+122ms	║║Executed virtual command log (1ms)
+133ms	║║Cancelling condition #89's schedules...
+133ms	║║Condition #89 evaluated false (7ms)
+134ms	║║Cancelling condition #85's schedules...
+135ms	║║Condition group #85 evaluated false (state changed) (9ms)
+142ms	║║Comparison (dynamic) 0 is (integer) 1 = false (2ms)
+143ms	║║Cancelling condition #69's schedules...
+144ms	║║Condition #69 evaluated false (6ms)
+145ms	║║Cancelling condition #65's schedules...
+146ms	║║Condition group #65 evaluated false (state changed) (8ms)
+154ms	║║Comparison (enum) open is (string) closed = false (2ms)
+155ms	║║Cancelling condition #84's schedules...
+156ms	║║Condition #84 evaluated false (7ms)
+157ms	║║Cancelling condition #70's schedules...
+158ms	║║Condition group #70 evaluated false (state changed) (9ms)
+161ms	║╚Execution stage complete. (69ms)
+162ms	╚Event processed successfully (162ms)
5/28/2018, 7:20:28 AM +571ms
+1ms	╔Received event [Front Screen Door].acceleration = active with a delay of 802ms
+101ms	║RunTime Analysis CS > 17ms > PS > 51ms > PE > 33ms > CE
+103ms	║Runtime (41965 bytes) successfully initialized in 51ms (v0.3.104.20180323) (101ms)
+104ms	║╔Execution stage started
+118ms	║║Condition #62 evaluated false (8ms)
+119ms	║║Condition group #29 evaluated false (state did not change) (9ms)
+146ms	║║Comparison (enum) active changes_to (string) active = true (0ms)
+147ms	║║Cancelling condition #89's schedules...
+148ms	║║Condition #89 evaluated true (26ms)
+149ms	║║Cancelling condition #85's schedules...
+150ms	║║Condition group #85 evaluated true (state changed) (28ms)
+160ms	║║Cancelling statement #86's schedules...
+164ms	║║Executed virtual command wait (1ms)
+165ms	║║Waiting for 800ms
+972ms	║║Executed virtual command setVariable (3ms)
+979ms	║║Accel changed to Active
+980ms	║║Executed virtual command log (2ms)
+988ms	║║Comparison (dynamic) 1 is (integer) 1 = true (1ms)
+989ms	║║Cancelling condition #69's schedules...
+990ms	║║Condition #69 evaluated true (7ms)
+995ms	║║Comparison (dynamic) 0 is (integer) 0 = true (1ms)
+996ms	║║Cancelling condition #92's schedules...
+997ms	║║Condition #92 evaluated true (6ms)
+999ms	║║Cancelling condition #65's schedules...
+1000ms	║║Condition group #65 evaluated true (state changed) (17ms)
+1004ms	║║Cancelling statement #66's schedules...
+1022ms	║║Executed virtual command sendSMSNotification (10ms)
+1028ms	║║Executed virtual command setVariable (3ms)
+1037ms	║║SMS sent
+1038ms	║║Executed virtual command log (2ms)
+1049ms	║║Comparison (enum) closed is (string) closed = true (2ms)
+1051ms	║║Condition #84 evaluated true (9ms)
+1052ms	║║Condition group #70 evaluated true (state did not change) (10ms)
+1054ms	║║Cancelling statement #81's schedules...
+1060ms	║║Executed virtual command setVariable (3ms)
+1066ms	║║Executed virtual command setVariable (3ms)
+1074ms	║║Screen changed to close
+1074ms	║║Executed virtual command log (1ms)
+1078ms	║╚Execution stage complete. (973ms)
+1079ms	╚Event processed successfully (1079ms)

#19

So here are the ‘highlights’ of your last log:

28.571 sec = Acceleration is Active
28.736 sec = Begin 800 ms Wait
29.543 sec = Set variable ScreenActive
29.592 sec = SMS sent
29.622 sec = Screen is still closed
29.631 sec = Set variable ScreenOpen = 0
29.637 sec = Set variable ScreenActive = 0
29.867 sec = Screen Opened
29.982 sec = Set variable ScreenOpen = 1
41.736 sec = Acceleration is Inactive

According to this, there was a 1.4 second delay between acceleration and screen open. (almost like a knock, then a slight pause, and then the screen opened) You can increase the 800 ms Wait to 1500 or 1600 ms, which should give enough time for the screen to open, and cancel the text message. Just be aware that the longer you make this delay, the longer it will take for you to actually be notified on a legitimate screen knock.

For future testing the Accel before screen open, I would: Knock and then immediately open the screen… Although, to be honest, I typically do most of my testing as naturally as possible. (this would mean not knocking before opening the screen) I understand why you did though because we wanted to force the acceleration BEFORE the opening for testing.

All in all though, I think the piston is beautiful. The only tweaking from this point should be fine tuning the Wait delay somewhere between 800 - 1600 ms.
(Too small will give you undesired SMS, too large and there will be a delay before legit SMS)


#20

I actually did try changing the wait time to 1500ms earlier, but I noticed it always gave “piston waited at a semaphore” for around 10000ms which kept the if statement from seeing that the door was open.

I did try a knock followed by an immediate open every time. I’d say well less than a second. I think it may not be registering as quickly as I thought. I then started thinking maybe motion before opening was more rare than I was suspecting, but with casual opening and closing maybe 1 out of 3 would show a motion prior to opening the screen door.

I’ve attached the green camera and log that shows the semaphore waiting.

5/28/2018, 1:44:21 PM +636ms
+1ms	╔Received event [Front Screen Door].contact = open with a delay of 673ms
+9673ms	║RunTime Analysis CS > 26ms > PS > 9570ms > PE > 78ms > CE
+9674ms	║Piston waited at a semaphore for 9520ms
+9677ms	║Runtime (42030 bytes) successfully initialized in 9570ms (v0.3.104.20180323) (9674ms)
+9678ms	║╔Execution stage started
+9688ms	║║Comparison (enum) open changes_to (string) open = false (0ms)
+9689ms	║║Condition #62 evaluated false (5ms)
+9690ms	║║Condition group #29 evaluated false (state did not change) (7ms)
+9701ms	║║Cancelling condition #89's schedules...
+9702ms	║║Condition #89 evaluated false (9ms)
+9703ms	║║Cancelling condition #85's schedules...
+9704ms	║║Condition group #85 evaluated false (state changed) (11ms)
+9711ms	║║Comparison (dynamic) 0 is (integer) 1 = false (1ms)
+9712ms	║║Cancelling condition #69's schedules...
+9713ms	║║Condition #69 evaluated false (6ms)
+9714ms	║║Cancelling condition #65's schedules...
+9715ms	║║Condition group #65 evaluated false (state changed) (9ms)
+9723ms	║║Comparison (enum) open is (string) closed = false (1ms)
+9724ms	║║Condition #84 evaluated false (6ms)
+9725ms	║║Condition group #70 evaluated false (state did not change) (8ms)
+9728ms	║╚Execution stage complete. (50ms)
+9729ms	╚Event processed successfully (9729ms)
5/28/2018, 1:44:21 PM +28ms
+1ms	╔Received event [Front Screen Door].acceleration = active with a delay of 986ms
+128ms	║RunTime Analysis CS > 22ms > PS > 37ms > PE > 69ms > CE
+131ms	║Runtime (41966 bytes) successfully initialized in 37ms (v0.3.104.20180323) (129ms)
+132ms	║╔Execution stage started
+145ms	║║Condition #62 evaluated false (7ms)
+146ms	║║Condition group #29 evaluated false (state did not change) (9ms)
+152ms	║║Comparison (enum) active changes_to (string) active = true (1ms)
+154ms	║║Cancelling condition #89's schedules...
+155ms	║║Condition #89 evaluated true (6ms)
+156ms	║║Cancelling condition #85's schedules...
+157ms	║║Condition group #85 evaluated true (state changed) (9ms)
+159ms	║║Cancelling statement #86's schedules...
+163ms	║║Executed virtual command wait (1ms)
+164ms	║║Waiting for 1500ms
+1671ms	║║Executed virtual command setVariable (3ms)
+1678ms	║║Accel changed to Active
+1679ms	║║Executed virtual command log (2ms)
+1686ms	║║Comparison (dynamic) 1 is (integer) 1 = true (1ms)
+1688ms	║║Cancelling condition #69's schedules...
+1689ms	║║Condition #69 evaluated true (7ms)
+1694ms	║║Comparison (dynamic) 0 is (integer) 0 = true (1ms)
+1695ms	║║Condition #92 evaluated true (5ms)
+1696ms	║║Cancelling condition #65's schedules...
+1697ms	║║Condition group #65 evaluated true (state changed) (15ms)
+1699ms	║║Cancelling statement #66's schedules...
+1715ms	║║Executed virtual command sendSMSNotification (9ms)
+1721ms	║║Executed virtual command setVariable (3ms)
+1729ms	║║SMS sent
+1729ms	║║Executed virtual command log (1ms)
+1740ms	║║Comparison (enum) open is (string) closed = false (2ms)
+1742ms	║║Cancelling condition #84's schedules...
+1743ms	║║Condition #84 evaluated false (9ms)
+1744ms	║║Cancelling condition #70's schedules...
+1745ms	║║Condition group #70 evaluated false (state changed) (11ms)
+1747ms	║╚Execution stage complete. (1616ms)
+1749ms	╚Event processed successfully (1749ms)