Light Randomizer


#1

I’m trying to create a piston that will randomly turn a set of lights on and off when a virtual switch is set to ON. I’m trying to do this with a “while” statement and a “for each” statement, but so far I’m not having success with lights actually activating. I suspect it has something to do with my “wait” command.

Any help would be appreciated!


#2

Try switching the $devices and $device.

Also logs will help us solve issues


#3

Log is below. I changed $devices in my original example to $device before running this.

8/21/2017, 6:27:49 PM +391ms
+2ms ╔Received event [Light Randomizer].switch = off with a delay of 56ms
+64ms ║RunTime Analysis CS > 13ms > PS > 31ms > PE > 20ms > CE
+72ms ║Runtime (35880 bytes) successfully initialized in 31ms (v0.2.0e5.20170812) (70ms)
+73ms ║╔Execution stage started
+81ms ║║Comparison (enum) off is (string) on = false (1ms)
+82ms ║║Condition #6 evaluated false (5ms)
+82ms ║║Condition group #1 evaluated false (state did not change) (5ms)
+84ms ║╚Execution stage complete. (11ms)
+90ms ╚Event processed successfully (90ms)


#4

And if you turn the switch on?


#5

More complete log below. The second chunk at the top only pops up after I toggle the switch from on to off.

8/21/2017, 6:30:54 PM +369ms
+2ms ╔Received event [Light Randomizer].switch = off with a delay of 54ms
+67ms ║RunTime Analysis CS > 13ms > PS > 31ms > PE > 23ms > CE
+74ms ║Runtime (35967 bytes) successfully initialized in 31ms (v0.2.0e5.20170812) (72ms)
+75ms ║╔Execution stage started
+83ms ║║Comparison (enum) off is (string) on = false (1ms)
+83ms ║║Condition #6 evaluated false (4ms)
+84ms ║║Condition group #1 evaluated false (state did not change) (5ms)
+85ms ║╚Execution stage complete. (11ms)
+92ms ╚Event processed successfully (91ms)
8/21/2017, 6:29:47 PM +9ms
+3ms ╔Starting piston… (v0.2.0e5.20170812)
+94ms ║╔Subscribing to devices…
+99ms ║║Subscribing to Light Randomizer.switch…
+148ms ║╚Finished subscribing (59ms)
+169ms ║Comparison (enum) off is (string) on = false (3ms)
+187ms ╚Piston successfully started (187ms)


#6

This is when you are switching the switch off.


#7

Nothing populates in the log when I switch it on. However, I have another piston setup to report back a piston state for the switch, so I know it’s working…


#8

@Robin where is your vacation light manager. Will help get @dra started down the right path


#9

I started with that as a base…perhaps I’ll jump back to that and start over.


#10

Yea I would recommend starting over


#11

Well, I got it to work by using @Robin’s vacation lights as a more direct starting point. My goal was to have the randomization start when the switch flipped to ON and run until it flipped to OFF. This version will check the switch every 30 minutes, which functionally works just fine (I’m only annoyed that I can’t figure out how to make the program do what I originally intended!).


#12

Any IDE logs?