Help using device state values in a template

Hello. I’m looking to recreate the functionality that Philips Hue’s have with multiple button presses on the hue dummer to go between various colour profiles you’ve set for a bulb. My thinking is:

Create an if else condition that sets the colour to white by default, but if the colour is white set the colour to blue, if the colour if blue then set it to green or whatever. Essentially mimicking the way you can click the top button on the hue dimmer to alternative between light shades and colours.

The problem is I’m not sure how to get about doing this. I think it’s possible, but all of the videos and discussions I’ve read don’t seem to click. I’m not really getting anywhere. (I’m fairly new to all of this). Reading the values of the temp_kelvin would be a good way I think. So as a starting point changing the colour temperature if the value is one of the ifs. e.g. 5000k > 4000k if 4000k > 3500k if 3500k > 2000k if 2000k > 5000k. and loop.

Is this something that someone can help me achieve? If there’s a better way of doing it I’m all ears and would love to learn more about the best way of doing things.

My end goes it to possibly have a blueprint or something or a script where the colours can be set easily for a particular dimmer switch.

Thanks.

This approach is workable for temperatures, but a lot more complicated for colors.

I have something similar at home and i implemented it with helpers that keep track of what the next setting (color or brightness or whatever) should be. I don’t rely on reading the state of the lights, which can be finicky with Hue lights in a lot of ways.