Issue with Light Colour Change Level

lights
execution
color
light
piston

#1

1) Give a description of the problem
This piston manages the light on my fish tank. It does 3 things, sets the on and off time based on sunset and sets the light to white 9 hours before the time and a pinkish colour at the time, both at 100% brightness.

2) What is the expected behavior?
As above.

3) What is happening/not happening?
TIme gets set and white light works as expected. The pink light comes on but it ALWAYS 50% and not 100% as expected.

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)
11/02/2019, 17:09:14 +313ms
+1ms ╔Received event [Home].time = 1549904940000 with a delay of 14313ms
+391ms ║RunTime Analysis CS > 176ms > PS > 155ms > PE > 59ms > CE
+394ms ║Runtime (38960 bytes) successfully initialized in 155ms (v0.3.109.20181207) (391ms)
+395ms ║╔Execution stage started
+430ms ║║Cancelling statement #7’s schedules…
+462ms ║║Executed physical command [Fish tank].setColor([[hex: #ff00ff, hue:83, saturation:100, level:50]]) (22ms)
+464ms ║║Executed [Fish tank].setColor (26ms)
+468ms ║║Cancelling statement #14’s schedules…
+483ms ║║Skipped execution of physical command [Fish tank].setLevel([100]) because it would make no change to the device. (6ms)
+485ms ║║Executed [Fish tank].setLevel (10ms)
+491ms ║╚Execution stage complete. (97ms)
+494ms ║Setting up scheduled job for Tue, Feb 12 2019 @ 12:00:00 AM GMT (in 24645.194s), with 2 more jobs pending
+504ms ╚Event processed successfully (504ms)
11/02/2019, 12:19:54 +125ms
+0ms ╔Starting piston… (v0.3.109.20181207)
+446ms ║╔Subscribing to devices…
+573ms ║║Subscribing to Fish tank…
+574ms ║╚Finished subscribing (137ms)
+617ms ║Calculating (decimal) 0.0 - (decimal) 9.0 >> (decimal) -9.0
+696ms ║Setting up scheduled job for Mon, Feb 11 2019 @ 5:09:00 PM GMT (in 17345.181s), with 2 more jobs pending
+709ms ╚Piston successfully started (708ms)
11/02/2019, 08:05:00 +906ms
+1ms ╔Received event [Home].time = 1549872300000 with a delay of 906ms
+477ms ║RunTime Analysis CS > 236ms > PS > 205ms > PE > 35ms > CE
+479ms ║Runtime (38780 bytes) successfully initialized in 205ms (v0.3.109.20181207) (477ms)
+481ms ║╔Execution stage started
+497ms ║║Calculating (decimal) 0.0 - (decimal) 9.0 >> (decimal) -9.0
+508ms ║║Cancelling statement #2’s schedules…
+530ms ║║Executed physical command [Fish tank].setColorTemperature([6538]) (15ms)
+531ms ║║Executed [Fish tank].setColorTemperature (18ms)
+555ms ║║Executed physical command [Fish tank].setLevel([100]) (19ms)
+557ms ║║Executed [Fish tank].setLevel (21ms)
+562ms ║╚Execution stage complete. (81ms)
+564ms ║Setting up scheduled job for Mon, Feb 11 2019 @ 5:07:00 PM GMT (in 32518.53s), with 2 more jobs pending
+575ms ╚Event processed successfully (575ms)
10/02/2019, 23:59:59 +278ms
+1ms ╔Received event [Home].time = 1549843200000 with a delay of -723ms
+381ms ║RunTime Analysis CS > 43ms > PS > 166ms > PE > 172ms > CE
+390ms ║Runtime (38781 bytes) successfully initialized in 166ms (v0.3.109.20181207) (387ms)
+396ms ║╔Execution stage started
+510ms ║║Cancelling statement #11’s schedules…
+526ms ║║Skipped execution of physical command [Fish tank].off([]) because it would make no change to the device. (9ms)
+528ms ║║Executed [Fish tank].off (13ms)
+535ms ║╚Execution stage complete. (140ms)
+551ms ║Setting up scheduled job for Mon, Feb 11 2019 @ 8:05:00 AM GMT (in 29100.184s), with 2 more jobs pending
+560ms ╚Event processed successfully (560ms)
10/02/2019, 17:05:05 +121ms
+1ms ╔Received event [Home].time = 1549818300000 with a delay of 5121ms
+376ms ║RunTime Analysis CS > 150ms > PS > 187ms > PE > 39ms > CE
+379ms ║Runtime (38781 bytes) successfully initialized in 187ms (v0.3.109.20181207) (378ms)
+380ms ║╔Execution stage started
+406ms ║║Cancelling statement #7’s schedules…
+431ms ║║Executed physical command [Fish tank].setColor([[hex: #ff00ff, hue:83, saturation:100, level:50]]) (17ms)
+433ms ║║Executed [Fish tank].setColor (21ms)
+444ms ║║Skipped execution of physical command [Fish tank].setLevel([100]) because it would make no change to the device. (5ms)
+445ms ║║Executed [Fish tank].setLevel (7ms)
+451ms ║╚Execution stage complete. (70ms)
+454ms ║Setting up scheduled job for Mon, Feb 11 2019 @ 12:00:00 AM GMT (in 24894.426s), with 2 more jobs pending
+461ms ╚Event processed successfully (461ms)
10/02/2019, 08:04:59 +430ms
+0ms ╔Received event [Home].time = 1549785900000 with a delay of -571ms
+1281ms ║RunTime Analysis CS > 250ms > PS > 271ms > PE > 761ms > CE
+1284ms ║Runtime (38783 bytes) successfully initialized in 271ms (v0.3.109.20181207) (1283ms)
+1286ms ║╔Execution stage started
+1308ms ║║Calculating (decimal) 0.0 - (decimal) 9.0 >> (decimal) -9.0
+1318ms ║║Cancelling statement #2’s schedules…
+1344ms ║║Executed physical command [Fish tank].setColorTemperature([6538]) (20ms)
+1346ms ║║Executed [Fish tank].setColorTemperature (22ms)
+1372ms ║║Executed physical command [Fish tank].setLevel([100]) (20ms)
+1373ms ║║Executed [Fish tank].setLevel (22ms)
+1378ms ║╚Execution stage complete. (93ms)
+1382ms ║Setting up scheduled job for Sun, Feb 10 2019 @ 5:05:00 PM GMT (in 32399.189s), with 2 more jobs pending
+1391ms ╚Event processed successfully (1391ms)
09/02/2019, 23:59:59 +379ms
+1ms ╔Received event [Home].time = 1549756800000 with a delay of -621ms
+321ms ║RunTime Analysis CS > 35ms > PS > 130ms > PE > 155ms > CE
+324ms ║Runtime (38781 bytes) successfully initialized in 130ms (v0.3.109.20181207) (322ms)
+326ms ║╔Execution stage started
+373ms ║║Cancelling statement #11’s schedules…
+417ms ║║Executed physical command [Fish tank].off() (21ms)
+419ms ║║Executed [Fish tank].off (25ms)
+426ms ║╚Execution stage complete. (101ms)
+430ms ║Setting up scheduled job for Sun, Feb 10 2019 @ 8:05:00 AM GMT (in 29100.192s), with 2 more jobs pending
+439ms ╚Event processed successfully (439ms)


#2

Just my two cents:

  • Lines 22 & 27 can be in the same block…
  • Lines 35 & 40 can be in the same block…

Also, in both cases, I would make the level command one line before the other command.


#3

I think I’ve solved it, but still not 100% sure why it’s not working as was.

It looks like I was getting lucky with the white change (colour temperature), with the colour I was setting it and then trying to set again immediately the level parameter. I don’t think Hue likes this, so changed from colour HEX to colour HSL and just read the Hue settings to figure out what I needed to put in.


#4

Most bulbs cannot change colors unless the bulb is already on. That is why I suggested moving the level before any color changes.