Piston to detect when last person leaves


#1

1) Give a description of the problem
Piston is continually firing instead of just when the last person leaves. I have SHM Armed Away so I dont want 2 notifications

2) What is the expected behaviour?
I want the Piston to check all exterior doors/windows when the last person leaves the house and send a notification if something is open so they can go back and close it

3) What is happening/not happening?
I want the piston to only fire when the last person leaves,and then not fire again until the next time.

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

5) Attach logs after turning logging level to Full

Here, the log shows the final person leaving the house:
First question is where is Condition #1? I think from the log output, condition #2 is the iPhone presence and condition #3 is the state of the devices

This operated as I hoped. Everyone left, all the devices were NOT open, so it simply exited.

11/14/2019, 8:32:39 AM +313ms
+1ms ╔Received event [sarah's iPhone].presence = not present with a delay of 60ms
+101ms ║RunTime Analysis CS > 16ms > PS > 44ms > PE > 42ms > CE
+104ms ║Runtime (40341 bytes) successfully initialized in 44ms (v0.3.110.20191009) (103ms)
+105ms ║╔Execution stage started
+121ms ║║Comparison (enum) not present is_not (string) present = true (1ms)
+124ms ║║Comparison (enum) not present is_not (string) present = true (1ms)
+126ms ║║Comparison (enum) not present is_not (string) present = true (2ms)
+127ms ║║Cancelling condition #2's schedules...
+128ms ║║Condition #2 evaluated true (19ms)
+144ms ║║Comparison (enum) closed is_any_of (string) open = false (1ms)
+146ms ║║Comparison (enum) closed is_any_of (string) open = false (2ms)
+148ms ║║Comparison (enum) closed is_any_of (string) open = false (1ms)
+154ms ║║Condition #3 evaluated false (25ms)
+155ms ║║Condition group #1 evaluated false (state did not change) (46ms)
+157ms ║╚Execution stage complete. (53ms)
+158ms ╚Event processed successfully (158ms)

Now, while all the iPhonees were not present,the front door opened, and it sent the notifications (which I really dont want as I already have that scenario coded in SmartHomeMonitor, and thus got two announcements)
For my education in debugging, I know see the entry "Condition group #1 evaluated true (state changed) " is the Condition Group the entire IF statement? (All of the iPhones and Any of the devices)

11/14/2019, 9:24:24 AM +348ms|
|+2ms|╔Received event [Front Door].contact = open with a delay of 107ms|
|+134ms|║RunTime Analysis CS > 20ms > PS > 69ms > PE > 45ms > CE|
|+137ms|║Runtime (40326 bytes) successfully initialized in 69ms (v0.3.110.20191009) (134ms)|
|+138ms|║╔Execution stage started|
|+156ms|║║Comparison (enum) not present is_not (string) present = true (2ms)|
|+158ms|║║Comparison (enum) not present is_not (string) present = true (2ms)|
|+160ms|║║Comparison (enum) not present is_not (string) present = true (1ms)|
|+161ms|║║Condition #2 evaluated true (20ms)|
|+175ms|║║Comparison (enum) open is_any_of (string) open = true (2ms)|
|+177ms|║║Comparison (enum) closed is_any_of (string) open = false (2ms)|
|+179ms|║║Comparison (enum) closed is_any_of (string) open = false (1ms)|
|+185ms|║║Cancelling condition #3's schedules...|
|+186ms|║║Condition #3 evaluated true (24ms)|
|+187ms|║║Cancelling condition #1's schedules...|
|+188ms|║║Condition group #1 evaluated true (state changed) (47ms)|
|+190ms|║║Cancelling statement #4's schedules...|
|+195ms|║║Calculating (string) "WebCore reports The following devices are open + (string) Front Door >> (string) "WebCore reports The following devices are open Front Door|
|+197ms|║║Calculating (string) "WebCore reports The following devices are open Front Door + (string) " >> (string) "WebCore reports The following devices are open Front Door "|
|+202ms|║║Executed virtual command setVariable (2ms)|
|+222ms|║║Executed virtual command sendPushNotification (18ms)|
|+225ms|║║Cancelling statement #7's schedules...|
|+938ms|║║Executed physical command [Echo - Basement Echo].playTextAndRestore(["WebCore reports The following devices are open Front Door "]) (707ms)|
|+939ms|║║Executed [Echo - Basement Echo].playTextAndRestore (708ms)|
|+1135ms|║║Executed physical command [Echo - Living room Echo].playTextAndRestore(["WebCore reports The following devices are open Front Door "]) (191ms)|
|+1135ms|║║Executed [Echo - Living room Echo].playTextAndRestore (193ms)|
|+1322ms|║║Executed physical command [Echo - Loft Echo].playTextAndRestore(["WebCore reports The following devices are open Front Door "]) (182ms)|
|+1323ms|║║Executed [Echo - Loft Echo].playTextAndRestore (184ms)|
|+1326ms|║╚Execution stage complete. (1188ms)|
|+1327ms|╚Event processed successfully (1326ms)|

I did think about creating a separate piston to flip a vswitch when the Phones all left, and use that as a trigger to run this.


#2

It helps evaluating the log if you turn on trace before snapping the green picture. Then the line numbers and group numbers are more clearly marked.

Right now because both are conditions they both become riggers so this piston will run every time a presence sensor leaves or arrive and every time any one of the doors open or close. When it runs, it will evaluate the conditions to determine if it should execute the other statements. To reduce the number of executions I suggest making the contact sensors your trigger ‘changes to open’ and put it first. Then it will only run when the doors open/close and then check if everyone is gone.


#3

Thanks, I’ll repost the Piston snap.
But i dont think your change will do what I want.
The scenario is this: I’m the last to leave the house and I dont pull the garage door all the way closed. I want to be notified as quick as possible that something is open.
Maybe my idea of having a Piston flip a vSwitch when all the sensors are gone, and use eh change of the vswitch as a trigger for this piston is the best way to go


#4


#5

OK. Your intent was unclear since you play something in the house when no one is supposed to be there and your scenario talked about someone opening the door when no one is home. If you are more concerned about a door being left open, then I suggest you wrap another if around what you have that looks for and change in presence. So then you look for any change in presence as a trigger but only act if everyone is gone and a door is left open.


#6

My approach: I have one piston that does nothing but monitor changes in presence and sets a global variable @HouseOccupied. This way I can use as a condition in other pistons without having to do something complex.

I also have a second and third piston that uses a change in the global variable as a trigger to do things when everyone leaves or the first person comes back home. Example:



#7

I haven’t seen that approach before. I’ll have to keep that one in mind. I use this seems to work pretty good so far i put all my presence sensors into a device global variable in this case its called @PresenceSensors then use it in a piston like this

The trigger, line 37 (changes to) is set to any of the sensors in the global variable and the conduction, line 39 (is) is set to all of the sensors in the global variable.