Hey guys, I’m trying to figure out why this script that I had working quit working recently. I’m using it to randomize a color for a couple RGB bulbs I have. This was working great up until a week or so ago…It seems to randomize when I restart HASS, but calling the script anytime after that results in the same item being returned every time. Any ideas?
I didn’t think you could set colors programmatically. The template itself is sound; testing it in the editor produced a random value each time I updated it.
I think the main problem is that the value will only get set when the templates are all rendered in HA on initialization. There’s nothing there to reinitialize the template. Something like this would probably work better in AppDaemon.
That’s whats odd, it tests fine in the editor, and it worked fine like this for a couple months. The only change I made was upgrading to 0.36, and when I noticed it wasn’t randomizing anymore I reverted back to 34.5 and that didn’t help.
I’ll try to replicate this issue later tonight and see if I can find any problems. In the mean time, some users were in our Gitter earlier today also trying to generate random RGB colors. Instead of having to fight with Jinja for a while like they did here’s what they came up with. Just use this to generate a tuple of RGB colors.