RGB color step-change - suggestion needed

I need some help with a rule;

I have an rgb zigbee bulb (IKEA) which I have connected to an item in OH2.12 through Deconz. Works! I also have an IKEA remote connected through the same binding. Also works.

Now, what I want to achieve is, that by pressing a button on the remote, I want to cycle the color element of the button a step so that continously pressing the button would change the color through “the RGB rainbow”.

The state of the RBG-bulb (color item type) in OH is i.e. “264,100,100”. What I want to do is basically to change the first number in that three-sequence with +20 each time the button is pressed - until a high limit is reached (unsure how much that is, but i.e. 350) and then start over from 0.
The last part of the sequence I just want to retain (",100,100").

At the end, I expect just to send the updated string to the RGB item with a “sendCommand”.

Any suggestions how to achieve this in a nifty code without me breaking my mind with substrings and back-forward conversion from strings to numbers ?

OK - played around and fixed it;

			var HSBType color = IKEA_E27RGBBULB_1_Color.state
			var DecimalType hue = color.getHue
			hue = new DecimalType(hue + 10)
			if (hue > 360) {
				hue = new DecimalType(0)
			color = new HSBType(hue,color.getSaturation,color.getBrightness)
1 Like