rule "-Generate random 6 digits hex"
timer(int: 0 10s) // Remove this when acting on Event, otherwise it will generate a new random every 10 seconds
when
// Event(source=="your trigger", value=="on") // Make sure that value is not "on" inbetween, otherwise the rule won't trigger or you need explicitly retract the event
then
java.util.Random randomGenerator = new java.util.Random();
execute.command("RGB_Uni0", String.format("%06X", randomGenerator.nextInt(0x1000000)));
end
Thanks Michal.
I was thinking that it would be far more complex than that :-)
I'm in an installation right now that I might be able to try that out with :-)
Otherwise, I'll give it a go at home next week.
How much do I owe you now?
Cheers,
Stuart
I'm sorry, I forgot to say thank you for this.
It's been working really well :-)
I've also expanded it to a little single pixel DMX architectural light.
The only issue as that the random numbers it generates tended to be quite small, so the red elements aren't called for very often.
So I gently tweaked the code to generate 3 x 2 digit HEX values to make more use of the full RGB range.
This is the code that's working really well.
execute.command("DMX_Universal-200","pixel.api?uni=5&ordercolour=rgb&onecolour=" + String.format("%02X", randomGenerator.nextInt(0x1000000)) + String.format("%02X", randomGenerator.nextInt(0x1000000)) + String.format("%02X", randomGenerator.nextInt(0x1000000)) + "&start=1&end=1");
Thanks again,
Stuart
For those that are following this thread and are interested in seeing it in action, I made this quick and simple video of an installation I did last year.