SHM - Auto In/Out using PSensors not triggering final If statement


#1

1) Give a description of the problem
Currently have two of the three IF’s working, the last one does not trigger (when we both leave together…

2) What is the expected behavior?
When we both leave the apartment together or the last person leaves, it’s supposed to change the SHM to Away and send us a push notification.

3) What is happening/not happening?
When one of us arrives, it triggers the SHM disarm , 10mins later, it triggers the SHM “Stay” status. When one of us leaves, 10min later, it triggers the SHM “Stay”. But (line 43-49)when we are both leaving together or after the last person leaves, it doesnt trigger the SHM “Away”.

I know its not good to have multiple triggers in one piston but 2 out of 3 are working, was hoping thats not the cause of it… I also feel that it can be a lot cleaner, i’ll take any suggestions on making it cleaner, less “if” or adding variables…

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

5) Attach any logs (From ST IDE and by turning logging level to Full)
these logs are from me leaving this morning…

+1ms ╔Starting piston… (v0.3.109.20181207)
+421ms ║╔Subscribing to devices…
+491ms ║║Subscribing to Arrival Sensor CF.presence…
+512ms ║║Subscribing to Arrival Sensor PF.presence…
+647ms ║╚Finished subscribing (246ms)
+718ms ║Comparison (enum) not present stays (string) present = false (2ms)
+722ms ║Comparison (enum) present stays (string) present = true (3ms)
+740ms ║Cancelling condition #12’s schedules…
+749ms ║Cancelling condition #11’s schedules…
+796ms ║Comparison (enum) not present did_not_change = true (33ms)
+818ms ╚Piston successfully started (818ms)
1/21/2019, 6:33:55 AM +90ms
+1ms ╔Received event [Home].time = 1548070436393 with a delay of -1304ms
+217ms ║RunTime Analysis CS > 115ms > PS > 60ms > PE > 43ms > CE
+220ms ║Runtime (44715 bytes) successfully initialized in 60ms (v0.3.109.20181207) (218ms)
+222ms ║╔Execution stage started
+257ms ║╚Execution stage complete. (35ms)
+258ms ╚Event processed successfully (258ms)
1/21/2019, 6:33:26 AM +119ms
+1ms ╔Received event [Arrival Sensor CF].presence = not present with a delay of 77ms
+128ms ║RunTime Analysis CS > 21ms > PS > 61ms > PE > 47ms > CE
+131ms ║Runtime (44689 bytes) successfully initialized in 61ms (v0.3.109.20181207) (129ms)
+132ms ║╔Execution stage started
+142ms ║║Comparison (enum) not present changes_to (string) present = false (1ms)
+144ms ║║Condition #29 evaluated false (6ms)
+152ms ║║Condition #41 evaluated false (7ms)
+153ms ║║Condition group #1 evaluated false (state did not change) (15ms)
+161ms ║║Comparison (enum) not present changes_to (string) not present = true (1ms)
+163ms ║║Cancelling condition #12’s schedules…
+164ms ║║Condition #12 evaluated true (7ms)
+165ms ║║Cancelling condition #11’s schedules…
+166ms ║║Condition group #11 evaluated true (state changed) (10ms)
+198ms ║║Comparison (enum) not present did_not_change = true (22ms)
+200ms ║║Condition #35 evaluated true (30ms)
+201ms ║║Condition group #13 evaluated true (state did not change) (33ms)
+202ms ║║Cancelling statement #13’s schedules…
+222ms ║║Executed virtual command setAlarmSystemStatus (16ms)
+257ms ║║Executed virtual command sendPushNotification (30ms)
+267ms ║║Comparison (enum) not present changes_to (string) not present = true (1ms)
+269ms ║║Cancelling condition #37’s schedules…
+270ms ║║Condition #37 evaluated true (7ms)
+271ms ║║Cancelling statement #36’s schedules…
+272ms ║║Condition group #36 made progress up the ladder, currently at step 1 of 2
+278ms ║╚Execution stage complete. (147ms)
+280ms ║Setting up scheduled job for Mon, Jan 21 2019 @ 6:33:56 AM EST (in 29.995s)
+289ms ╚Event processed successfully (289ms)

this one is the two of us leaving…

1/20/2019, 8:09:49 AM +101ms
+1ms ╔Received event [Arrival Sensor CF].presence = not present with a delay of 64ms
+104ms ║RunTime Analysis CS > 17ms > PS > 49ms > PE > 38ms > CE
+107ms ║Runtime (44704 bytes) successfully initialized in 49ms (v0.3.109.20181207) (105ms)
+108ms ║╔Execution stage started
+119ms ║║Comparison (enum) not present changes_to (string) present = false (1ms)
+121ms ║║Condition #29 evaluated false (7ms)
+129ms ║║Condition #41 evaluated false (7ms)
+131ms ║║Condition group #1 evaluated false (state did not change) (16ms)
+138ms ║║Comparison (enum) not present changes_to (string) not present = true (1ms)
+140ms ║║Cancelling condition #12’s schedules…
+142ms ║║Condition #12 evaluated true (7ms)
+143ms ║║Condition group #11 evaluated true (state did not change) (10ms)
+168ms ║║Comparison (enum) not present did_not_change = true (15ms)
+170ms ║║Condition #35 evaluated true (24ms)
+172ms ║║Condition group #13 evaluated true (state did not change) (27ms)
+173ms ║║Cancelling statement #13’s schedules…
+193ms ║║Executed virtual command setAlarmSystemStatus (16ms)
+210ms ║║Executed virtual command sendPushNotification (11ms)
+218ms ║║Comparison (enum) not present changes_to (string) not present = true (1ms)
+220ms ║║Cancelling condition #37’s schedules…
+222ms ║║Condition #37 evaluated true (7ms)
+230ms ║║Condition #44 evaluated false (6ms)
+231ms ║║Condition group #36 evaluated false (state did not change) (18ms)
+234ms ║╚Execution stage complete. (125ms)
+235ms ╚Event processed successfully (235ms)
1/20/2019, 8:09:09 AM +246ms
+2ms ╔Received event [Arrival Sensor PF].presence = not present with a delay of 151ms
+140ms ║RunTime Analysis CS > 24ms > PS > 68ms > PE > 49ms > CE
+143ms ║Runtime (44701 bytes) successfully initialized in 68ms (v0.3.109.20181207) (141ms)
+144ms ║╔Execution stage started
+158ms ║║Condition #29 evaluated false (8ms)
+164ms ║║Comparison (enum) not present changes_to (string) present = false (0ms)
+165ms ║║Cancelling condition #41’s schedules…
+167ms ║║Condition #41 evaluated false (7ms)
+168ms ║║Cancelling condition #1’s schedules…
+169ms ║║Condition group #1 evaluated false (state changed) (19ms)
+179ms ║║Condition #12 evaluated false (7ms)
+184ms ║║Comparison (enum) not present changes_to (string) not present = true (1ms)
+186ms ║║Cancelling condition #42’s schedules…
+187ms ║║Condition #42 evaluated true (7ms)
+189ms ║║Cancelling condition #11’s schedules…
+190ms ║║Condition group #11 evaluated true (state changed) (17ms)
+247ms ║║Comparison (enum) present did_not_change = true (49ms)
+249ms ║║Condition #35 evaluated true (56ms)
+251ms ║║Condition group #13 evaluated true (state did not change) (58ms)
+252ms ║║Cancelling statement #13’s schedules…
+273ms ║║Executed virtual command setAlarmSystemStatus (18ms)
+300ms ║║Executed virtual command sendPushNotification (21ms)
+310ms ║║Condition #37 evaluated false (6ms)
+311ms ║║Condition group #36 evaluated false (state did not change) (8ms)
+314ms ║╚Execution stage complete. (170ms)
+316ms ╚Event processed successfully (315ms)


#2

Apologies as this isn’t really an answer to the questions you’re posting, it may be useful…
Take a look at the piston in the link below… Works well for my wife and I and is probably similar to what you’re trying to accomplish. It also sets a global “@occupancy” variable which can easily be referenced in other pistons.
Let me know if you have any questions on it, I’d be more than happy to help.


#3

Thanks for the link :slight_smile: that Occ/SHM Piston is what i’m trying to create but with one piston as you can tell… i did import both to play around with and see which gives me the better result.

Would you say having the global “@occupancy” variable works better over having it defined locally to the piston itself? My concern is the “delay” of the “@global variable” compared to the “local variable”, since I use the Arrival Sensors from Samsung; our iphone’s battery aren’t the greatest and since my wife doesnt want to install any apps (not enough space available) I have to stick to the ASensors


#4

Shouldn’t matter which presence sensor you’re using… ST presence, WC, Life360, etc…
You could do the same thing all in one piston if you wanted to, keeping “occupancy” as a local var to the piston. There shouldn’t be any delay of a local var vs. a global var.
The SHM piston is reacting immediately to changes of the @occupancy variable… the piston is basically subscribing to changes of @occupancy.
I like that variable global so I can use it in other pistons.


#5

I like the idea of keeping it as a global var compared to local for the same reasons as you do but i remember reading on another post that triggers react faster to local var compared to global.

I’m going to use the “@occupancy” piston into my SHM to see what works, since im still learning. Thanks again for the link!

Hoping someone can tell me what i did wrong on that 3rd IF statement…


#6

Quick question… on your SHM v5, I see on your overnight statement (line 79, you have it empty, how were you able to add that third column “Time happens daily at 11:30pm or…” without a trigger?


#7

nevermind, i just figured it out… its a group condition :slight_smile:


#8

The alternate solution looks great. Relative to your original question, you could simplify all your ifs using:

If Any of Presence Sensor 4, Presence Sensor 3 changes to present

If Any of Presence Sensor 4, Presence Sensor 3 changes to not present

If All of Presence Sensor 4, Presence Sensor 3 changes to present

Since Any is a subset of All, I am not sure what conflicts will be created but you might try putting the last if first. Don’t really know if it makes a difference.


#9

Hi guxdude,

I originally had the piston created the way you mentioned but I was having issues with the sub-If’s: set SHM to Stay (line 28-32) and (line39-46). But i was still having the issue of the last IF, where we would both leave and it wouldnt trigger. I’m going to test out your suggestion about moving it to the top and see how that goes this wkend.


#10

So far your occupancy piston is working like a charm! Not even noticing a delay as you mention. Thanks!!

This weekend we’ll see how the last part for my SHM will turn out since during the week one of us is home while the other is out.


#11

Glad it seems to be working. Again you might be safe putting the all first but I’m really not expert enough to tell you for sure if it will make a difference.


#12

moving the all to the top was what I needed to do, after testing it out this wkend, SHM set itself to Away mode and received the notification.

@allrak SHM Piston also has it on the top, which allowed me to trouble should by seeing which one would work.

Thank you both!!!