Button Press Next Color

Hi All
New to Node Red but enjoying it as I'm starting to get my head around it.

I have the 5 button Ikea Tradfi remote that the kids use in their room with a Tasmota flash RGBW globe. Im also using Home assistant.

I need one of the buttons on the remote to cycle through a set of colors like a "next color" type button. So Start on red, then button press to change to next color of blue, button press changes to next color yellow......

Looking in HA I can see a parameter called color_name. How do I create like a list of colors in Nodered to cycle through?

Thanks in advance

Hi and welcome to the forum! Are you familiar with JavaScript? I would create an array of the colors and then use node context in a function node to store the previous array index. Every time a msg arrives at function node I'd increment the array index by one and using it pick a color from the array. With an added if condition I would reset the counter to 0 when it goes higher than the size of the array.

See https://nodered.org/docs/user-guide/context for more info on using the context.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.