Help with Presence Piston


#1

1) Give a description of the problem
Piston is not seeing “Nathan” present - was working until I added that phone. As you can see in the log, when “Jerry” left at 6:14, garage cam did not turn on (which is correct) and should only turn on when the last person leaves. However, it did turn on when “Tanya” left at 7:49 although “Nathan” was still present

2) What is the expected behavior?
SHM and switches respond to someone being in the house

3) What is happening/not happening?
Piston is not seeing “Nathan” has present but is instead turning on the garage cam and SHM when no one else is in the house

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)
8/27/2018, 9:32:33 AM +367ms
+3ms ╔Received event [Home].test = 1535380353357 with a delay of 3ms
+504ms ║Runtime (50552 bytes) successfully initialized in 141ms (v0.3.106.20180731) (498ms)
+508ms ║╔Execution stage started
+756ms ║║Executed virtual command setAlarmSystemStatus (38ms)
+822ms ║║Executed virtual command setLocationMode (61ms)
+848ms ║║Executed [Garage Cam].on (16ms)
+861ms ║║Executed [House Cam].on (11ms)
+943ms ║║Duration 11827328ms for is >= 43200000ms threshold = false
+967ms ║║Executed virtual command setState (3ms)
+1028ms ║╚Execution stage complete. (523ms)
+1052ms ║Setting up scheduled job for Mon, Aug 27 2018 @ 10:59:00 PM CDT (in 48385.585s), with 2 more jobs pending
+1063ms ╚Event processed successfully (1065ms)
8/27/2018, 9:32:25 AM +57ms
+7ms ╔Starting piston… (v0.3.106.20180731)
+649ms ║╔Subscribing to devices…
+773ms ║║Subscribing to Jerry.presence…
+793ms ║║Subscribing to Jerry’s iPhone.presence…
+812ms ║║Subscribing to Nathan.presence…
+833ms ║║Subscribing to Tanya.presence…
+853ms ║║Subscribing to Tanya Sawrie’s Android.presence…
+1148ms ║║Subscribing to Garage Cam…
+1149ms ║║Subscribing to House Cam…
+1150ms ║║Subscribing to Motion Sensor…
+1151ms ║║Subscribing to BR Lamp…
+1152ms ║║Subscribing to Ceiling fan…
+1153ms ║║Subscribing to Ceiling fan…
+1154ms ║║Subscribing to Ceiling fan…
+1156ms ║║Subscribing to Ceiling fan…
+1157ms ║║Subscribing to Garage Light Left…
+1158ms ║║Subscribing to Garage Light Right…
+1160ms ║║Subscribing to Jerry’s lamp…
+1160ms ║║Subscribing to Kitchen…
+1161ms ║║Subscribing to Living room lamp…
+1162ms ║║Subscribing to Tanya’s lamp…
+1163ms ║╚Finished subscribing (544ms)
+1598ms ║Duration 11819673ms for is >= 43200000ms threshold = false
+1669ms ║Setting up scheduled job for Mon, Aug 27 2018 @ 10:59:00 PM CDT (in 48393.278s), with 2 more jobs pending
+1686ms ╚Piston successfully started (1681ms)
8/27/2018, 7:59:59 AM +264ms
+1ms ╔Received event [Home].time = 1535374800000 with a delay of -736ms
+658ms ║Runtime (50553 bytes) successfully initialized in 389ms (v0.3.106.20180731) (655ms)
+659ms ║╔Execution stage started
+819ms ║║Executed virtual command setAlarmSystemStatus (29ms)
+879ms ║║Executed virtual command setLocationMode (56ms)
+890ms ║║Executed [Garage Cam].on (4ms)
+894ms ║║Executed [House Cam].on (3ms)
+1105ms ║║Duration 6273348ms for is >= 43200000ms threshold = false
+1292ms ║║Executed virtual command setState (7ms)
+1328ms ║╚Execution stage complete. (670ms)
+1348ms ║Setting up scheduled job for Mon, Aug 27 2018 @ 10:59:00 PM CDT (in 53939.4s), with 2 more jobs pending
+1356ms ╚Event processed successfully (1356ms)
8/27/2018, 7:58:59 AM +159ms
+0ms ╔Received event [Home].time = 1535374740000 with a delay of -842ms
+499ms ║Runtime (50551 bytes) successfully initialized in 289ms (v0.3.106.20180731) (498ms)
+501ms ║╔Execution stage started
+700ms ║║Duration 6212876ms for is >= 43200000ms threshold = false
+724ms ║║Executed virtual command setState (5ms)
+733ms ║╚Execution stage complete. (233ms)
+735ms ║Setting up scheduled job for Mon, Aug 27 2018 @ 8:00:00 AM CDT (in 60.106s), with 2 more jobs pending
+745ms ╚Event processed successfully (744ms)
8/27/2018, 7:49:16 AM +199ms
+0ms ╔Received event [Tanya].presence = not present with a delay of 149ms
+375ms ║Runtime (50547 bytes) successfully initialized in 112ms (v0.3.106.20180731) (357ms)
+376ms ║╔Execution stage started
+451ms ║║Executed virtual command setAlarmSystemStatus (15ms)
+490ms ║║Executed virtual command setLocationMode (35ms)
+504ms ║║Executed [Garage Cam].on (10ms)
+514ms ║║Executed [House Cam].on (8ms)
+599ms ║║Duration 5629821ms for is >= 43200000ms threshold = false
+614ms ║║Executed virtual command setState (1ms)
+618ms ║╚Execution stage complete. (242ms)
+621ms ║Setting up scheduled job for Mon, Aug 27 2018 @ 7:59:00 AM CDT (in 583.181s), with 2 more jobs pending
+632ms ╚Event processed successfully (633ms)
8/27/2018, 7:49:14 AM +141ms
+1ms ╔Received event [Tanya Sawrie’s Android].presence = not present with a delay of 159ms
+286ms ║Runtime (50562 bytes) successfully initialized in 130ms (v0.3.106.20180731) (283ms)
+287ms ║╔Execution stage started
+357ms ║║Executed virtual command setAlarmSystemStatus (15ms)
+386ms ║║Executed virtual command setLocationMode (26ms)
+395ms ║║Executed [Garage Cam].off (4ms)
+401ms ║║Executed [House Cam].off (4ms)
+476ms ║║Duration 5627640ms for is >= 43200000ms threshold = false
+490ms ║║Executed virtual command setState (1ms)
+497ms ║╚Execution stage complete. (211ms)
+500ms ║Setting up scheduled job for Mon, Aug 27 2018 @ 7:59:00 AM CDT (in 585.36s), with 2 more jobs pending
+511ms ╚Event processed successfully (512ms)
8/27/2018, 6:15:27 AM +125ms
+2ms ╔Received event [Jerry].presence = not present with a delay of 151ms
+297ms ║Runtime (50539 bytes) successfully initialized in 144ms (v0.3.106.20180731) (294ms)
+298ms ║╔Execution stage started
+361ms ║║Executed virtual command setAlarmSystemStatus (16ms)
+415ms ║║Executed virtual command setLocationMode (51ms)
+431ms ║║Executed [Garage Cam].off (12ms)
+437ms ║║Executed [House Cam].off (3ms)
+520ms ║║Executed virtual command setState (1ms)
+524ms ║╚Execution stage complete. (226ms)
+526ms ║Setting up scheduled job for Mon, Aug 27 2018 @ 7:59:00 AM CDT (in 6212.35s), with 2 more jobs pending
+538ms ╚Event processed successfully (538ms)
8/27/2018, 6:14:43 AM +474ms
+2ms ╔Received event [Jerry’s iPhone].presence = not present with a delay of 214ms
+306ms ║Runtime (50546 bytes) successfully initialized in 158ms (v0.3.106.20180731) (303ms)
+307ms ║╔Execution stage started
+375ms ║║Executed virtual command setAlarmSystemStatus (21ms)
+416ms ║║Executed virtual command setLocationMode (37ms)
+424ms ║║Executed [Garage Cam].off (3ms)
+429ms ║║Executed [House Cam].off (3ms)
+624ms ║║Executed virtual command setState (1ms)
+632ms ║╚Execution stage complete. (326ms)
+634ms ║Setting up scheduled job for Mon, Aug 27 2018 @ 7:59:00 AM CDT (in 6255.892s), with 2 more jobs pending
+646ms ╚Event processed successfully (645ms)


#2

Change you’re first IF to a restriction:
example: Only when time is between…

(^^^always avoid nesting IF statements ^^^)

Take a look at the following piston, it may help…


#3

would I do that for each of the time conditions? Change them from IF to ONLY?


#4

Yep, I would… Change from the IF statement to an “only when time is between” restriction. You can enable restrictions by clicking the “options” button in the edit piston window, and choosing “show restrictions”

So it’ll look like:
Only when time is between xxx & xxx
IF presence changes to…
Then…


#5

One small comment to add to @allrak’s suggestion…

It might not be a big deal, but the way your original piston was coded, there was 3 minutes each day unaccounted for. (5:00am, 7:59am & 10:59pm) This means if anyone arrived home at any of those precise times, the piston might not actually turn on the lights until a minute had passed.

To prevent this, you could set the start and stop times to be identical.
(webCoRE goes by milliseconds, so 7:59:59.999 is still in the 7 o’clock hour)