1) Give a description of the problem
I used to have a gentle wake up lighting piston working for a single bulb, set to trigger daily (only on weekdays) at 7:45AM, to go from 0% brightness (off) to 100% brightness over the period of 15 minutes (completing at 8:00AM).
I was under the assumption that the piston was working correctly, and well, until I decided to add piston states at various stages of the piston’s execution, just for visual feedback on the dashboard, like I have done for all my other pistons.
Since doing so, and with logging and trace enabled, I have become aware of significant delays to execution of scheduled tasks (from repeated wait commands). Sometimes, the execution is spot on the scheduled task time, other times it can be delayed up to 30 seconds (so far I have seen), which is completely unacceptable to me for the purpose of this piston.
Taking the maths into account for this:
15 minutes execution duration = 900 seconds (15 minutes X 60 seconds)
900 seconds total duration / 100 (to derive wait period for 1% brightness increments) = 9 seconds between each 1% bulb brightness increment
So, with that in mind, inside a while loop, I have a 9 second wait period, which is obviously repeated several times (once per 1% brightness increment) until the while condition becomes false (ultimately when the bulb has been brightened to the maximum 100%).
It is that multiple-repeated 9 second wait period that is giving me trouble. Sometimes the execution happens bang on the 9 seconds, other times (and mostly) there are ridiculous delays to this wait period being executed. Obviously with the maths involved in what I want to achieve with the light bulb gradually brightening over 15 minutes, it has to be fairly accurate, and with these delays I am seeing in the logs (and watching the bulb’s activity in the ST app), it just does not work properly, and is not acceptable to me.
I have tried various combinations of Task Scheduling Policy and Never Cancel Tasks, but to no avail. And I do not wish to use the built-in “fade” command for this, as I know that once a fade has started, you cannot interrupt it until it has completed, which is not workable for me as I would like the ability to manually turn the bulb off during that 15 minute execution window, if I so wish (without the piston forcing it to switch on again).
Please have a look at my attached piston and advise what I am doing incorrectly because I am really pulling my hair out on this one now.
Although I mentioned a trigger time of 7:45AM above, that is not included in this iteration of my piston as I am currently just testing it with the basic functionality of looping and gradually increasing the bulb brightness in 1% increments for the moment (my current testing involves manually triggering the piston by switching the bulb [on then] off via the ST app). Once I have that basic functionality working, I will wrap the whole thing inside the desired timer.
2) What is the expected behavior?
Covered in the above essay
3) What is happening/not happening?
Covered in the above essay too
4) Post a Green Snapshot of the piston
5) Attach any logs (From ST IDE and by turning logging level to Full)
3/25/2019, 2:36:05 PM +70ms
+0ms ╔Received event [Home].time = 1553524552189 with a delay of 12880ms
+508ms ║RunTime Analysis CS > 230ms > PS > 255ms > PE > 23ms > CE
+511ms ║Runtime (39840 bytes) successfully initialized in 255ms (v0.3.10a.20190223) (509ms)
+512ms ║╔Execution stage started
+547ms ║║Comparison (integer) 4 is_less_than (integer) 100 = true (2ms)
+549ms ║║Condition #11 evaluated true (8ms)
+551ms ║║Condition group #10 evaluated true (state did not change) (10ms)
+566ms ║║Comparison (enum) on is (string) on = true (4ms)
+569ms ║║Condition #13 evaluated true (14ms)
+571ms ║║Condition group #12 evaluated true (state did not change) (17ms)
+584ms ║║Calculating (integer) 4 + (integer) 1 >> (integer) 5
+593ms ║║Executed virtual command [Hue (Master Bedroom: Scott’s Bedside)].setVariable (4ms)
+615ms ║║Executed physical command [Hue (Master Bedroom: Scott’s Bedside)].setLevel([5]) (17ms)
+617ms ║║Executed [Hue (Master Bedroom: Scott’s Bedside)].setLevel (19ms)
+626ms ║║Calculating (string) 5 + (string) % >> (string) 5%
+640ms ║║Executed virtual command [Hue (Master Bedroom: Scott’s Bedside)].setState (9ms)
+646ms ║║Executed virtual command [Hue (Master Bedroom: Scott’s Bedside)].wait (1ms)
+648ms ║║Requesting a wake up for Mon, Mar 25 2019 @ 2:36:14 PM GMT (in 9.0s)
+656ms ║╚Execution stage complete. (144ms)
+659ms ║Setting up scheduled job for Mon, Mar 25 2019 @ 2:36:14 PM GMT (in 8.991s)
+671ms ╚Event processed successfully (671ms)
3/25/2019, 2:35:42 PM +512ms
+1ms ╔Received event [Home].time = 1553524532054 with a delay of 10458ms
+560ms ║RunTime Analysis CS > 152ms > PS > 384ms > PE > 23ms > CE
+564ms ║Runtime (39840 bytes) successfully initialized in 384ms (v0.3.10a.20190223) (561ms)
+565ms ║╔Execution stage started
+599ms ║║Comparison (integer) 3 is_less_than (integer) 100 = true (2ms)
+601ms ║║Condition #11 evaluated true (7ms)
+603ms ║║Condition group #10 evaluated true (state did not change) (8ms)
+616ms ║║Comparison (enum) on is (string) on = true (2ms)
+618ms ║║Condition #13 evaluated true (12ms)
+619ms ║║Condition group #12 evaluated true (state did not change) (13ms)
+629ms ║║Calculating (integer) 3 + (integer) 1 >> (integer) 4
+636ms ║║Executed virtual command [Hue (Master Bedroom: Scott’s Bedside)].setVariable (3ms)
+656ms ║║Executed physical command [Hue (Master Bedroom: Scott’s Bedside)].setLevel([4]) (15ms)
+658ms ║║Executed [Hue (Master Bedroom: Scott’s Bedside)].setLevel (18ms)
+666ms ║║Calculating (string) 4 + (string) % >> (string) 4%
+670ms ║║Executed virtual command [Hue (Master Bedroom: Scott’s Bedside)].setState (0ms)
+675ms ║║Executed virtual command [Hue (Master Bedroom: Scott’s Bedside)].wait (0ms)
+677ms ║║Requesting a wake up for Mon, Mar 25 2019 @ 2:35:52 PM GMT (in 9.0s)
+684ms ║╚Execution stage complete. (119ms)
+686ms ║Setting up scheduled job for Mon, Mar 25 2019 @ 2:35:52 PM GMT (in 8.992s)
+697ms ╚Event processed successfully (696ms)
3/25/2019, 2:35:22 PM +486ms
+0ms ╔Received event [Home].time = 1553524513590 with a delay of 8895ms
+428ms ║RunTime Analysis CS > 105ms > PS > 305ms > PE > 18ms > CE
+431ms ║Runtime (39839 bytes) successfully initialized in 305ms (v0.3.10a.20190223) (429ms)
+433ms ║╔Execution stage started
+478ms ║║Comparison (integer) 2 is_less_than (integer) 100 = true (3ms)
+481ms ║║Condition #11 evaluated true (11ms)
+484ms ║║Condition group #10 evaluated true (state did not change) (14ms)
+498ms ║║Comparison (enum) on is (string) on = true (2ms)
+501ms ║║Condition #13 evaluated true (12ms)
+502ms ║║Condition group #12 evaluated true (state did not change) (14ms)
+514ms ║║Calculating (integer) 2 + (integer) 1 >> (integer) 3
+521ms ║║Executed virtual command [Hue (Master Bedroom: Scott’s Bedside)].setVariable (4ms)
+543ms ║║Executed physical command [Hue (Master Bedroom: Scott’s Bedside)].setLevel([3]) (17ms)
+545ms ║║Executed [Hue (Master Bedroom: Scott’s Bedside)].setLevel (19ms)
+553ms ║║Calculating (string) 3 + (string) % >> (string) 3%
+559ms ║║Executed virtual command [Hue (Master Bedroom: Scott’s Bedside)].setState (1ms)
+565ms ║║Executed virtual command [Hue (Master Bedroom: Scott’s Bedside)].wait (1ms)
+567ms ║║Requesting a wake up for Mon, Mar 25 2019 @ 2:35:32 PM GMT (in 9.0s)
+575ms ║╚Execution stage complete. (143ms)
+578ms ║Setting up scheduled job for Mon, Mar 25 2019 @ 2:35:32 PM GMT (in 8.991s)
+588ms ╚Event processed successfully (589ms)
3/25/2019, 2:35:03 PM +982ms
+1ms ╔Received event [Home].time = 1553524497533 with a delay of 6449ms
+498ms ║RunTime Analysis CS > 239ms > PS > 245ms > PE > 14ms > CE
+501ms ║Runtime (39683 bytes) successfully initialized in 245ms (v0.3.10a.20190223) (500ms)
+502ms ║╔Execution stage started
+523ms ║║Comparison (integer) 1 is_less_than (integer) 100 = true (3ms)
+525ms ║║Cancelling condition #11’s schedules…
+526ms ║║Condition #11 evaluated true (8ms)
+528ms ║║Cancelling condition #10’s schedules…
+529ms ║║Condition group #10 evaluated true (state changed) (11ms)
+542ms ║║Comparison (enum) on is (string) on = true (2ms)
+544ms ║║Cancelling condition #13’s schedules…
+545ms ║║Condition #13 evaluated true (13ms)
+547ms ║║Cancelling condition #12’s schedules…
+548ms ║║Condition group #12 evaluated true (state changed) (17ms)
+558ms ║║Calculating (integer) 1 + (integer) 1 >> (integer) 2
+564ms ║║Executed virtual command [Hue (Master Bedroom: Scott’s Bedside)].setVariable (3ms)
+587ms ║║Executed physical command [Hue (Master Bedroom: Scott’s Bedside)].setLevel([2]) (18ms)
+588ms ║║Executed [Hue (Master Bedroom: Scott’s Bedside)].setLevel (20ms)
+596ms ║║Calculating (string) 2 + (string) % >> (string) 2%
+601ms ║║Executed virtual command [Hue (Master Bedroom: Scott’s Bedside)].setState (1ms)
+606ms ║║Executed virtual command [Hue (Master Bedroom: Scott’s Bedside)].wait (1ms)
+607ms ║║Requesting a wake up for Mon, Mar 25 2019 @ 2:35:13 PM GMT (in 9.0s)
+616ms ║╚Execution stage complete. (113ms)
+618ms ║Setting up scheduled job for Mon, Mar 25 2019 @ 2:35:13 PM GMT (in 8.991s)
+628ms ╚Event processed successfully (628ms)
3/25/2019, 2:34:48 PM +700ms
+2ms ╔Received event [Hue (Master Bedroom: Scott’s Bedside)].switch = on with a delay of 834ms
+94ms ║RunTime Analysis CS > 21ms > PS > 54ms > PE > 18ms > CE
+97ms ║Runtime (39701 bytes) successfully initialized in 54ms (v0.3.10a.20190223) (95ms)
+99ms ║╔Execution stage started
+115ms ║║Comparison (enum) on is (string) off = false (3ms)
+118ms ║║Cancelling condition #4’s schedules…
+120ms ║║Condition #4 evaluated false (12ms)
+122ms ║║Cancelling condition #3’s schedules…
+124ms ║║Condition group #3 evaluated false (state changed) (16ms)
+128ms ║╚Execution stage complete. (29ms)
+130ms ║Setting up scheduled job for Mon, Mar 25 2019 @ 2:34:57 PM GMT (in 8.704s)
+145ms ╚Event processed successfully (144ms)
3/25/2019, 2:34:48 PM +393ms
+1ms ╔Received event [Hue (Master Bedroom: Scott’s Bedside)].switch = off with a delay of 824ms
+68ms ║RunTime Analysis CS > 13ms > PS > 42ms > PE > 13ms > CE
+71ms ║Runtime (39484 bytes) successfully initialized in 42ms (v0.3.10a.20190223) (68ms)
+72ms ║╔Execution stage started
+83ms ║║Comparison (enum) off is (string) off = true (1ms)
+85ms ║║Cancelling condition #4’s schedules…
+86ms ║║Condition #4 evaluated true (8ms)
+87ms ║║Cancelling condition #3’s schedules…
+88ms ║║Condition group #3 evaluated true (state changed) (11ms)
+91ms ║║Cancelling statement #5’s schedules…
+98ms ║║Executed virtual command [Hue (Master Bedroom: Scott’s Bedside)].setVariable (3ms)
+115ms ║║Executed physical command [Hue (Master Bedroom: Scott’s Bedside)].setLevel([1]) (13ms)
+116ms ║║Executed [Hue (Master Bedroom: Scott’s Bedside)].setLevel (15ms)
+129ms ║║Executed physical command [Hue (Master Bedroom: Scott’s Bedside)].setColorTemperature([2732]) (8ms)
+130ms ║║Executed [Hue (Master Bedroom: Scott’s Bedside)].setColorTemperature (9ms)
+134ms ║║Executed virtual command [Hue (Master Bedroom: Scott’s Bedside)].setState (1ms)
+138ms ║║Executed virtual command [Hue (Master Bedroom: Scott’s Bedside)].wait (1ms)
+139ms ║║Requesting a wake up for Mon, Mar 25 2019 @ 2:34:57 PM GMT (in 9.0s)
+144ms ║╚Execution stage complete. (73ms)
+146ms ║Setting up scheduled job for Mon, Mar 25 2019 @ 2:34:57 PM GMT (in 8.994s)
+158ms ╚Event processed successfully (158ms)