Change OSRAM lightify colors on certain bulbs randomly every minute (cycle through colors)


#1

Hello all! I am trying to figure out how to cycle my lights every minute when a simulated switch it turned on. After it’s turned off, I want it to reset my normal light levels/colors. I have the second part figure out, but cycling the lights is where I am unable to get it to function. Here is what I have so far:

Any help would be appreciated!


#2

Have you tried set level instead of adjust level?


#3

Yes, I just switched it and the lights will come on, but they will not loop through colors (I have no clue why I put adjust instead of set, I know better :slight_smile: )


#4

Change the logging to full and trigger it and post up the logs


#5

Ok, I ran it for 4 minutes, here is the log file:

8/21/2017, 7:34:45 PM +134ms
+2ms ╔Received event [Party lights].switch = off with a delay of 205ms
+486ms ║RunTime Analysis CS > 318ms > PS > 114ms > PE > 55ms > CE
+494ms ║Runtime (38533 bytes) successfully initialized in 114ms (v0.2.0db.20170717) (491ms)
+496ms ║╔Execution stage started
+516ms ║║Comparison off changes_to on = false (1ms)
+519ms ║║Cancelling condition #30’s schedules…
+520ms ║║Condition #30 evaluated false (13ms)
+522ms ║║Cancelling condition #1’s schedules…
+523ms ║║Condition group #1 evaluated false (state changed) (16ms)
+535ms ║║Comparison off is off = true (3ms)
+537ms ║║Condition #22 evaluated true (12ms)
+539ms ║║Condition group #2 evaluated true (state did not change) (14ms)
+543ms ║║Cancelling statement #8’s schedules…
+1140ms ║║Executed physical command [Bedroom Floor Lamp].setColor([[hex: #87CEEB, hue:55, saturation:71, level:73]]) (580ms)
+1141ms ║║Executed [Bedroom Floor Lamp].setColor (592ms)
+1265ms ║║Executed physical command [Bedroom Floor Lamp].setLevel([30]) (116ms)
+1266ms ║║Executed [Bedroom Floor Lamp].setLevel (118ms)
+1271ms ║║Cancelling statement #11’s schedules…
+1288ms ║║Skipped execution of physical command [Kitchen Light].setLevel([100]) because it would make no change to the device. (7ms)
+1289ms ║║Executed [Kitchen Light].setLevel (9ms)
+1323ms ║║Executed physical command [Kitchen Light].setColor([[hex: #CEF4FD, hue:53, saturation:9, level:90]]) (29ms)
+1324ms ║║Executed [Kitchen Light].setColor (32ms)
+1330ms ║║Cancelling statement #14’s schedules…
+1370ms ║║Executed physical command [Living Room Accent Light].setLevel([15]) (30ms)
+1371ms ║║Executed [Living Room Accent Light].setLevel (32ms)
+1408ms ║║Executed physical command [Living Room Floor Lamp].setLevel([15]) (33ms)
+1410ms ║║Executed [Living Room Floor Lamp].setLevel (35ms)
+1454ms ║║Executed physical command [Living Room Accent Light].setColor([[hex: #FF0000, hue:0, saturation:100, level:50]]) (37ms)
+1456ms ║║Executed [Living Room Accent Light].setColor (40ms)
+1714ms ║║Executed physical command [Living Room Floor Lamp].setColor([[hex: #FF0000, hue:0, saturation:100, level:50]]) (32ms)
+1715ms ║║Executed [Living Room Floor Lamp].setColor (258ms)
+1727ms ║║Cancelling statement #17’s schedules…
+1857ms ║║Executed physical command [Living Room Table Lamp].setLevel([80]) (99ms)
+1858ms ║║Executed [Living Room Table Lamp].setLevel (101ms)
+1985ms ║║Executed physical command [Living Room Table Lamp].setColor([[hex: #FFFF00, hue:17, saturation:100, level:50]]) (121ms)
+1986ms ║║Executed [Living Room Table Lamp].setColor (124ms)
+1992ms ║║Cancelling statement #20’s schedules…
+2072ms ║║Executed physical command [Bedroom Floor Lamp].off() (73ms)
+2074ms ║║Executed [Bedroom Floor Lamp].off (76ms)
+2161ms ║║Executed physical command [Kitchen Light].off() (85ms)
+2162ms ║║Executed [Kitchen Light].off (87ms)
+2251ms ║║Executed physical command [Living Room Accent Light].off() (86ms)
+2252ms ║║Executed [Living Room Accent Light].off (89ms)
+2340ms ║║Executed physical command [Living Room Floor Lamp].off() (84ms)
+2341ms ║║Executed [Living Room Floor Lamp].off (87ms)
+2346ms ║╚Execution stage complete. (1851ms)
+2357ms ╚Event processed successfully (2357ms)
8/21/2017, 7:30:10 PM +179ms
+4ms ╔Received event [Party lights].switch = on with a delay of 75ms
+179ms ║RunTime Analysis CS > 27ms > PS > 100ms > PE > 53ms > CE
+304ms ║Runtime (38536 bytes) successfully initialized in 100ms (v0.2.0db.20170717) (298ms)
+305ms ║╔Execution stage started
+328ms ║║Comparison on changes_to on = true (1ms)
+330ms ║║Cancelling condition #30’s schedules…
+332ms ║║Condition #30 evaluated true (13ms)
+333ms ║║Cancelling condition #1’s schedules…
+334ms ║║Condition group #1 evaluated true (state changed) (17ms)
+339ms ║║Cancelling statement #31’s schedules…
+395ms ║║Executed physical command [Bedroom Floor Lamp].setLevel([100]) (29ms)
+396ms ║║Executed [Bedroom Floor Lamp].setLevel (31ms)
+407ms ║║Skipped execution of physical command [Kitchen Light].setLevel([100]) because it would make no change to the device. (9ms)
+408ms ║║Executed [Kitchen Light].setLevel (11ms)
+444ms ║║Executed physical command [Living Room Accent Light].setLevel([100]) (34ms)
+446ms ║║Executed [Living Room Accent Light].setLevel (36ms)
+484ms ║║Executed physical command [Living Room Floor Lamp].setLevel([100]) (34ms)
+485ms ║║Executed [Living Room Floor Lamp].setLevel (37ms)
+520ms ║║Executed physical command [Living Room Table Lamp].setLevel([100]) (32ms)
+521ms ║║Executed [Living Room Table Lamp].setLevel (35ms)
+560ms ║║Executed physical command [Bedroom Floor Lamp].setColor([[hex: #191970, hue:67, saturation:64, level:27]]) (24ms)
+561ms ║║Executed [Bedroom Floor Lamp].setColor (35ms)
+591ms ║║Executed physical command [Kitchen Light].setColor([[hex: #1E90FF, hue:58, saturation:100, level:56]]) (27ms)
+592ms ║║Executed [Kitchen Light].setColor (29ms)
+617ms ║║Executed physical command [Living Room Accent Light].setColor([[hex: #D2691E, hue:7, saturation:75, level:47]]) (22ms)
+618ms ║║Executed [Living Room Accent Light].setColor (25ms)
+645ms ║║Executed physical command [Living Room Floor Lamp].setColor([[hex: #808000, hue:17, saturation:100, level:25]]) (24ms)
+646ms ║║Executed [Living Room Floor Lamp].setColor (26ms)
+671ms ║║Executed physical command [Living Room Table Lamp].setColor([[hex: #32CD32, hue:33, saturation:61, level:50]]) (22ms)
+672ms ║║Executed [Living Room Table Lamp].setColor (24ms)
+677ms ║╚Execution stage complete. (371ms)
+686ms ╚Event processed successfully (685ms)


#6

Ok so what was the result in the house?

Were the lights turning on like they said in the logs?


#7

Oh, sorry! The lights all came on, they switched from the previous state, to 100% and to a random color. Then they stopped. My goal is for them to keep changing to random colors at a set interval (I had 2 seconds in the code to see results, but most likely, will be every 1 or 2 mins) until I stop the piston.


#8

Ok sorry I might have missed something. You are going to want to use a while loop.

While your switch is on
With @lights
Your actions
Add a wait (very very important the wait is in there)


#9

Sorry, I’m still learning this stuff, so I should put the wait after “Set color to Random;”? Does the wait time matter?


#10

The placement doesn’t make much difference once it is going. I typically put it after so that you see your actions sooner.

Essentially the wait is so there is a break before issuing the next command instead of flooding the platform with new commands


#11

Ok, here is my code with the change:

I ran my new code for a few minutes, and the lights functioned the same as last time. They came on, went to 100% level, changed from previous state color and stayed that color. They did not cycle again. Here is the log:

8/21/2017, 8:52:22 PM +889ms
+2ms ╔Received event [Party lights].switch = off with a delay of 72ms
+198ms ║RunTime Analysis CS > 22ms > PS > 107ms > PE > 69ms > CE
+209ms ║Runtime (38664 bytes) successfully initialized in 107ms (v0.2.0db.20170717) (206ms)
+211ms ║╔Execution stage started
+235ms ║║Comparison off changes_to on = false (1ms)
+240ms ║║Cancelling condition #30’s schedules…
+242ms ║║Condition #30 evaluated false (18ms)
+244ms ║║Cancelling condition #1’s schedules…
+245ms ║║Condition group #1 evaluated false (state changed) (22ms)
+258ms ║║Comparison off is off = true (4ms)
+260ms ║║Condition #22 evaluated true (13ms)
+262ms ║║Condition group #2 evaluated true (state did not change) (16ms)
+269ms ║║Cancelling statement #8’s schedules…
+318ms ║║Executed physical command [Bedroom Floor Lamp].setColor([[hex: #87CEEB, hue:55, saturation:71, level:73]]) (37ms)
+319ms ║║Executed [Bedroom Floor Lamp].setColor (41ms)
+352ms ║║Executed physical command [Bedroom Floor Lamp].setLevel([30]) (25ms)
+354ms ║║Executed [Bedroom Floor Lamp].setLevel (28ms)
+360ms ║║Cancelling statement #11’s schedules…
+379ms ║║Skipped execution of physical command [Kitchen Light].setLevel([100]) because it would make no change to the device. (9ms)
+381ms ║║Executed [Kitchen Light].setLevel (13ms)
+416ms ║║Executed physical command [Kitchen Light].setColor([[hex: #CEF4FD, hue:53, saturation:9, level:90]]) (28ms)
+417ms ║║Executed [Kitchen Light].setColor (30ms)
+423ms ║║Cancelling statement #14’s schedules…
+481ms ║║Executed physical command [Living Room Accent Light].setLevel([15]) (47ms)
+482ms ║║Executed [Living Room Accent Light].setLevel (49ms)
+520ms ║║Executed physical command [Living Room Floor Lamp].setLevel([15]) (33ms)
+521ms ║║Executed [Living Room Floor Lamp].setLevel (35ms)
+550ms ║║Executed physical command [Living Room Accent Light].setColor([[hex: #FF0000, hue:0, saturation:100, level:50]]) (22ms)
+551ms ║║Executed [Living Room Accent Light].setColor (25ms)
+577ms ║║Executed physical command [Living Room Floor Lamp].setColor([[hex: #FF0000, hue:0, saturation:100, level:50]]) (22ms)
+578ms ║║Executed [Living Room Floor Lamp].setColor (25ms)
+583ms ║║Cancelling statement #17’s schedules…
+630ms ║║Executed physical command [Living Room Table Lamp].setLevel([80]) (36ms)
+631ms ║║Executed [Living Room Table Lamp].setLevel (39ms)
+667ms ║║Executed physical command [Living Room Table Lamp].setColor([[hex: #FFFF00, hue:17, saturation:100, level:50]]) (27ms)
+668ms ║║Executed [Living Room Table Lamp].setColor (30ms)
+674ms ║║Cancelling statement #20’s schedules…
+707ms ║║Executed physical command [Bedroom Floor Lamp].off() (25ms)
+709ms ║║Executed [Bedroom Floor Lamp].off (27ms)
+737ms ║║Executed physical command [Kitchen Light].off() (24ms)
+738ms ║║Executed [Kitchen Light].off (27ms)
+771ms ║║Executed physical command [Living Room Accent Light].off() (30ms)
+772ms ║║Executed [Living Room Accent Light].off (33ms)
+802ms ║║Executed physical command [Living Room Floor Lamp].off() (27ms)
+803ms ║║Executed [Living Room Floor Lamp].off (30ms)
+808ms ║╚Execution stage complete. (598ms)
+817ms ╚Event processed successfully (818ms)
8/21/2017, 8:49:57 PM +90ms
+1ms ╔Received event [Home Leesburg VA].time = 1503362998172 with a delay of -1085ms
+228ms ║RunTime Analysis CS > 42ms > PS > 148ms > PE > 40ms > CE
+239ms ║Runtime (38679 bytes) successfully initialized in 148ms (v0.2.0db.20170717) (236ms)
+241ms ║╔Execution stage started
+304ms ║╚Execution stage complete. (64ms)
+312ms ╚Event processed successfully (311ms)
8/21/2017, 8:49:27 PM +440ms
+2ms ╔Received event [Party lights].switch = on with a delay of 359ms
+235ms ║RunTime Analysis CS > 49ms > PS > 120ms > PE > 66ms > CE
+245ms ║Runtime (38670 bytes) successfully initialized in 120ms (v0.2.0db.20170717) (241ms)
+248ms ║╔Execution stage started
+277ms ║║Comparison on changes_to on = true (2ms)
+281ms ║║Cancelling condition #30’s schedules…
+282ms ║║Condition #30 evaluated true (19ms)
+285ms ║║Cancelling condition #1’s schedules…
+287ms ║║Condition group #1 evaluated true (state changed) (23ms)
+293ms ║║Cancelling statement #31’s schedules…
+393ms ║║Executed physical command [Bedroom Floor Lamp].setLevel([100]) (60ms)
+395ms ║║Executed [Bedroom Floor Lamp].setLevel (63ms)
+468ms ║║Executed physical command [Kitchen Light].setLevel([100]) (71ms)
+469ms ║║Executed [Kitchen Light].setLevel (73ms)
+508ms ║║Executed physical command [Living Room Accent Light].setLevel([100]) (37ms)
+509ms ║║Executed [Living Room Accent Light].setLevel (39ms)
+542ms ║║Executed physical command [Living Room Floor Lamp].setLevel([100]) (31ms)
+544ms ║║Executed [Living Room Floor Lamp].setLevel (33ms)
+575ms ║║Executed physical command [Living Room Table Lamp].setLevel([100]) (29ms)
+577ms ║║Executed [Living Room Table Lamp].setLevel (31ms)
+615ms ║║Executed physical command [Bedroom Floor Lamp].setColor([[hex: #00008B, hue:67, saturation:100, level:27]]) (23ms)
+616ms ║║Executed [Bedroom Floor Lamp].setColor (36ms)
+643ms ║║Executed physical command [Kitchen Light].setColor([[hex: #4169E1, hue:63, saturation:73, level:57]]) (24ms)
+645ms ║║Executed [Kitchen Light].setColor (27ms)
+670ms ║║Executed physical command [Living Room Accent Light].setColor([[hex: #FFD700, hue:14, saturation:100, level:50]]) (23ms)
+671ms ║║Executed [Living Room Accent Light].setColor (25ms)
+696ms ║║Executed physical command [Living Room Floor Lamp].setColor([[hex: #FFA500, hue:11, saturation:100, level:50]]) (21ms)
+697ms ║║Executed [Living Room Floor Lamp].setColor (24ms)
+721ms ║║Executed physical command [Living Room Table Lamp].setColor([[hex: #2E8B57, hue:41, saturation:50, level:36]]) (21ms)
+722ms ║║Executed [Living Room Table Lamp].setColor (23ms)
+729ms ║║Executed virtual command [Bedroom Floor Lamp, Kitchen Light, Living Room Accent Light, Living Room Floor Lamp, Living Room Table Lamp].wait (1ms)
+731ms ║║Requesting a wake up for Mon, Aug 21 2017 @ 8:49:58 PM EDT (in 30.0s)
+742ms ║╚Execution stage complete. (496ms)
+746ms ║Setting up scheduled job for Mon, Aug 21 2017 @ 8:49:58 PM EDT (in 29.988s)
+763ms ╚Event processed successfully (762ms)


#12

Under the options in the top right of the piston editor, make sure show advanced statements is enabled. Then add a new while loop statement.

The while will be your switch being on. Then add all your actions that you currently have except for the loop duration. This won’t be needed. You should have set level, set color and your wait.

Keep it simple with just that and check if it works. Then build on top of that when you get the desired results.


#13

Thank you so much for the help so far!! I changed it to show advanced statements, I am using the template build option and I don’t see a while loop statement in there? Can you help me out with where I’d find that?


#14

So there is no templates yet. You are still starting with the blank piston. Click on add a new statement and select the while loop. https://wiki.webcore.co/webCoRE#The_execute_section


#15

i’ve been struggling with this all day until i found this thread, thanks! :smiley: But I now got a working piston for party mode! If anyone is interested i have attached below