Delayed Execution Problem


#1

1) Give a description of the problem
Piston is not producing the desired result

2) What is the expected behavior?
I have a freezer that the kids love to leave open. I installed a contact sensor on it and if the contact is left open for more than 60 seconds, I want 2 lamps in the living room to turn red as a visual indicator that something is wrong. I would also like a push notification (although I didnt attempt that part).

3) What is happening/not happening?
Immediately upon opening the freezer, the lamps turn on to the last color used (usually white). When the freezer is closed then the lamps turn red. The length of time the freezer is open does not matter. Even if you just open and immediately close it then the lights turn red.

**4) Post a Green Snapshot of the piston

**5) Attach any logs
4/23/2019, 8:23:30 AM +89ms
+0ms â•”Received event [Home].time = 1556025811516 with a delay of -1428ms
+130ms â•‘RunTime Analysis CS > 36ms > PS > 65ms > PE > 29ms > CE
+133ms â•‘Runtime (37624 bytes) successfully initialized in 65ms (v0.3.10a.20190223) (131ms)
+135ms â•‘â•”Execution stage started
+136ms ║╚Execution stage complete. (2ms)
+138ms ╚Event processed successfully (138ms)
4/23/2019, 8:22:58 AM +49ms
+1ms â•”Received event [Freezer].contact = closed with a delay of 920ms
+77ms â•‘RunTime Analysis CS > 18ms > PS > 40ms > PE > 19ms > CE
+80ms â•‘Runtime (37613 bytes) successfully initialized in 40ms (v0.3.10a.20190223) (77ms)
+81ms â•‘â•”Execution stage started
+91ms â•‘â•‘Comparison (enum) closed changes_to (string) open = false (1ms)
+93ms ║║Cancelling condition #2’s schedules…
+94ms â•‘â•‘Condition #2 evaluated false (7ms)
+96ms ║║Cancelling condition #1’s schedules…
+97ms â•‘â•‘Condition group #1 evaluated false (state changed) (11ms)
+100ms ║║Cancelling statement #5’s schedules…
+126ms â•‘â•‘Executed physical command [Living Room Left Lamp].setLevel([75]) (14ms)
+134ms â•‘â•‘Executed physical command [Living Room Left Lamp].setLevel([88], [delay: 500]) (6ms)
+141ms â•‘â•‘Executed physical command [Living Room Left Lamp].setLevel([100], [delay: 1000]) (6ms)
+148ms â•‘â•‘Executed physical command [Living Room Left Lamp].setLevel([100], [delay: 1099]) (6ms)
+149ms â•‘â•‘Executed virtual command [Living Room Left Lamp].fadeLevel (42ms)
+169ms â•‘â•‘Executed physical command [Living Room Right Lamp].setLevel([100]) (14ms)
+170ms â•‘â•‘Executed virtual command [Living Room Right Lamp].fadeLevel (19ms)
+175ms â•‘â•‘Executed virtual command [Living Room Left Lamp, Living Room Right Lamp].wait (1ms)
+176ms â•‘â•‘Waiting for 1000ms
+1181ms ║║Cancelling statement #8’s schedules…
+1196ms â•‘â•‘Executed physical command [Living Room Left Lamp].setColor([[hex: #FF0000, hue:0, saturation:100, level:50]]) (8ms)
+1197ms â•‘â•‘Executed [Living Room Left Lamp].setColor (11ms)
+1207ms â•‘â•‘Executed physical command [Living Room Right Lamp].setColor([[hex: #FF0000, hue:0, saturation:100, level:50]]) (6ms)
+1208ms â•‘â•‘Executed [Living Room Right Lamp].setColor (10ms)
+1213ms ║╚Execution stage complete. (1133ms)
+1215ms ╚Event processed successfully (1214ms)
4/23/2019, 8:22:31 AM +394ms
+2ms â•”Received event [Freezer].contact = open with a delay of 945ms
+89ms â•‘RunTime Analysis CS > 21ms > PS > 48ms > PE > 19ms > CE
+91ms â•‘Runtime (37618 bytes) successfully initialized in 48ms (v0.3.10a.20190223) (88ms)
+92ms â•‘â•”Execution stage started
+103ms â•‘â•‘Comparison (enum) open changes_to (string) open = true (1ms)
+105ms ║║Cancelling condition #2’s schedules…
+106ms â•‘â•‘Condition #2 evaluated true (8ms)
+108ms ║║Cancelling condition #1’s schedules…
+109ms â•‘â•‘Condition group #1 evaluated true (state changed) (11ms)
+112ms ║║Cancelling statement #3’s schedules…
+119ms â•‘â•‘Executed virtual command [Living Room Left Lamp, Living Room Right Lamp].wait (1ms)
+121ms â•‘â•‘Requesting a wake up for Tue, Apr 23 2019 @ 8:23:31 AM CDT (in 60.0s)
+126ms ║╚Execution stage complete. (34ms)
+128ms â•‘Setting up scheduled job for Tue, Apr 23 2019 @ 8:23:31 AM CDT (in 59.995s)
+136ms ╚Event processed successfully (136ms)


#2

Here is what I am thinking:


#3

Just a suggestion. @WCmore Will This work? Not sure if this will work. But webcore allows me to write it this way.

IF Contact Sensor 2 $Status stays 'open' for 60 seconds
Then
   Turn on lights
   Set Color To Red
   Send Push
If Contact Sensor 2 Changes to Closed
Then 
   Set light color to white and turn off

I have not tested this but would love to know if this can work or not.


#4

I’m not sure. Personally, I’m not a fan of using $status


#5

I have never used $Status before either. Just curious.


#6

My quick test of an open door for 60 seconds did not work. So $Status does not seem to work this way. Ignore my post and carry on… :blush:


#7

$status if I remember correctly gets filled in with what ST thinks your device status is, ACTIVE/INACTIVE/ONLINE/OFFLINE. Not sure how often it gets updated by ST.


#8

Works like a charm. Adjusted the flashing to just a solid read for an infinite time (can change via voice once issued are cured). Thanks for everything!