Color RGB mapping under 2.X

I just upgraded to Oh2.X and my rules now throw errors for the HSBType conversions back to RGB. The light only accepts RGB values.

This is the log output:

2020-04-11 22:50:06.329 [INFO ] [clipse.smarthome.model.script.vColor] - vColor=353,98,50

2020-04-11 22:50:06.331 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'vMan_Color': Could not cast 353,98,50 to org.eclipse.smarthome.core.library.types.HSBType; line 109, column 16, length 32

This is my rule:

rule 'vMan_Color'
    Item vColor changed
    logInfo("vColor", "vColor=" + vColor.state);
	val red = (vColor.state as HSBType).red / 100 * 255
	val green = (vColor.state as HSBType).green / 100 * 255
	val blue = (vColor.state as HSBType).blue / 100 * 255
	logInfo("scene.rules", "R: " + red)
	logInfo("scene.rules", "G: " + green)
	logInfo("scene.rules", "B: " + blue)	  

I think this as to do with “The HSBType state type can no longer be constructed using a java.awt.Color object, and there is no longer a toColor() method.” From here 2.X Migration

Anyway I can still get RGB values from the color picker?

You can convert HSB into RGB and vice versa. Search the forum with these keywords you have now.
It’s years so I don’t recall details but there were quite a number of threads, including solutions.

I did search the forum for new updates to the HSBType state, however as per the migration page, HSBType state is no longer valid under 2.5.3

Found the error under items, the virtual color item was a string instead of a color item.