I have set the below piston in order to get notified when my front door remains open for specific duration and continues to do so, at the same duration interval, until the door is closed. The notifications when the door is opened are generated properly. However, the one at the end to confirm the door is closed is sent twice. It seems to me per the event logs I attached below, that while the “while” task is getting cancelling, due to the change of event state, a new instance of the piston is triggered at the time for some unknown reason, causing the duplicate notifications.
For testing purpose, I swapped my door contact sensor with my door lock, so I don’t have to keep opening and closing my door. I also decreased the duration value.
Piston
Event Logs
10/22/2017, 4:03:33 PM +808ms
+1ms ╔Received event [House Door].lock = locked with a delay of 1219ms
+153ms ║RunTime Analysis CS > 17ms > PS > 24ms > PE > 112ms > CE
+163ms ║Runtime (38762 bytes) successfully initialized in 24ms (v0.2.0fa.20171011) (161ms)
+164ms ║╔Execution stage started
+172ms ║║Comparison (enum) locked is (string) unlocked = false (1ms)
+173ms ║║Condition #6 evaluated false (5ms)
+174ms ║║Condition group #1 evaluated false (state did not change) (6ms)
+186ms ║║Calculating (long) 94433 / (long) 1000 >> (long) 94.433
+189ms ║║Comparison (integer) 30 is_less_than (decimal) 94 = true (1ms)
+190ms ║║Condition #14 evaluated true (13ms)
+190ms ║║Condition group #11 evaluated true (state did not change) (14ms)
+192ms ║║Cancelling statement #12’s schedules…
+211ms ║║Executed virtual command sendPushNotification (7ms)
+213ms ║╚Execution stage complete. (50ms)
+244ms ╚Event processed successfully (244ms)
10/22/2017, 4:03:32 PM +841ms
+2ms ╔Received event [House Door].lock = locked with a delay of 87ms
+281ms ║RunTime Analysis CS > 13ms > PS > 25ms > PE > 243ms > CE
+296ms ║Runtime (38764 bytes) successfully initialized in 25ms (v0.2.0fa.20171011) (294ms)
+297ms ║╔Execution stage started
+307ms ║║Comparison (enum) locked is (string) unlocked = false (1ms)
+308ms ║║Cancelling condition #6’s schedules…
+309ms ║║Condition #6 evaluated false (6ms)
+310ms ║║Cancelling condition #1’s schedules…
+311ms ║║Condition group #1 evaluated false (state changed) (7ms)
+327ms ║║Calculating (long) 93607 / (long) 1000 >> (long) 93.607
+329ms ║║Comparison (integer) 30 is_less_than (decimal) 93 = true (1ms)
+330ms ║║Condition #14 evaluated true (17ms)
+331ms ║║Condition group #11 evaluated true (state did not change) (18ms)
+333ms ║║Cancelling statement #12’s schedules…
+344ms ║║Executed virtual command sendPushNotification (8ms)
+346ms ║╚Execution stage complete. (50ms)
+354ms ╚Event processed successfully (354ms)
10/22/2017, 4:03:26 PM +137ms
+0ms ╔Received event [Home].time = 1508702607333 with a delay of -1197ms
+254ms ║RunTime Analysis CS > 22ms > PS > 50ms > PE > 183ms > CE
+267ms ║Runtime (38779 bytes) successfully initialized in 50ms (v0.2.0fa.20171011) (265ms)
+268ms ║╔Execution stage started
+293ms ║║Calculating (string) The house door has been open for + (string) 1 minute and 26 seconds >> (string) The house door has been open for 1 minute and 26 seconds
+296ms ║║Calculating (string) The house door has been open for 1 minute and 26 seconds + (string) . >> (string) The house door has been open for 1 minute and 26 seconds.
+311ms ║║Executed virtual command sendPushNotification (10ms)
+325ms ║║Comparison (enum) unlocked is (string) unlocked = true (1ms)
+327ms ║║Condition #6 evaluated true (13ms)
+328ms ║║Condition group #1 evaluated true (state did not change) (15ms)
+331ms ║║Cancelling statement #2’s schedules…
+335ms ║║Executed virtual command wait (0ms)
+337ms ║║Requesting a wake up for Sun, Oct 22 2017 @ 4:03:56 PM EDT (in 30.0s)
+343ms ║╚Execution stage complete. (75ms)
+345ms ║Setting up scheduled job for Sun, Oct 22 2017 @ 4:03:56 PM EDT (in 29.994s)
+378ms ╚Event processed successfully (378ms)