A common programming way to do this is to sort the list randomly, and then take each one in order. When you get to the end of the list, sort it again. You could probably translate to an HA automation in conjunction with a text_input to store the values, but it would be simpler if you’re also using Node Red.
Having said that, the way I rotate random colors in Node Red is to randomize each of RGB between 0 and 255, and then randomly set one of them to 0. Without the last step, and with all three having values, it tended to come out white-ish too often. If you wanted to ensure adjacent colors weren’t too similar, you could just rotate which one got set to zero, along the lines of that below (the template could probably be better).
I’m specifically trying to stay with a small set of defined colors for this particular application…thinking it would be easier to work with a list…but i’m getting stuck on list functions.
Here is what I have in Developer Tools
{%- set all_colors = ('red', 'blue', 'green', 'yellow', 'orange', 'magneta', 'purple') -%}
{%- set color = (all_colors | random) -%}
{{ color }}
{%- set all_colors = (all_colors | replace(color,'')) -%}
{{ all_colors }}
But I cant figure out how to remove the list item = ‘’
Even if I could, it seems as thought the all_colors variable is local to the service call, so: