Looking to set multiple lights to a random color each as part of a piston. I am looking for each light called in the piston to go to a random color. What I am finding is that as the piston runs, it randomizes the color and then applies that 1x color to the fixtures instead of each fixture getting its own randomization. I have tried a few things such as putting fixtures as separate action items instead of grouped but they all still get the 1x color. I think all of this is because when the piston initially triggers it generates that random color and does it only once at the start of the trigger.
My current work around (below) has been to randomize color one fixture, randomize colorname another one, and the third bulb gets a randomize of previously used color variables and color/colorname. With this though the third bulb has a 2 in 5 chance of being the same color as one of the first two
I would make a list of devices as a list variable. Trigger by the button press, then loop over the the device variable and use your rand() to set the color, and finally, wait 500ms.
Do you have a set of colors you'd like, too? You could add those to a list variable as well.
I have played around with this a bit, all the way to taking the devices as action outside (and below) the initial trigger but same result. Coming back to my theory that for each instance triggered the piston will only randomize once.
if you try the following
string randValue = {random(“str1”,”str2”,”str3”)}
each time you use randValue, you will get one of the random values.
I was caught out by this, as I expected one value for the whole execution, so when logging the randValue after using it, I was actually getting a different value.
Can you show me how that would work for my use case? Looking at my shared piston, on line 64 I am pulling a random from several options, including randomColor and randomColorName. But if it picks either of those, it would then match line 49 or 56.