Issue converting java.awt.Color to HSBType (NumberFormatException)

hi,

I want to convert a Colortemperature to HSB, so I first calculate RGB and then update an item with an HSBType.

unfortunately, handing over the RGB Color Object causes an Exception:

2021-01-20 13:04:30.479 [WARN ] [e.automation.internal.RuleEngineImpl] - Fail to execute action: 2
java.lang.NumberFormatException: Character array is missing "e" notation exponential mark.
at java.math.BigDecimal.<init>(BigDecimal.java:577) ~[?:?]

this is weird, as my code looks very similar to the official Rules docs:

var tempInternal = colorTemp/100
var red = 0;
var green = 0;
var blue = 0;

if (tempInternal <= 66) {
  red = 255
  green = 99.4708025861 * Math.log(tempInternal) - 161.1195681661
} else {
  red = 329.698727446 * Math.pow(tempInternal - 60, -0.1332047592)
  green = 288.1221695283 * Math.pow(tempInternal - 60, -0.0755148492)
}
if (tempInternal >= 66) {
  blue = 255
} else if (tempInternal <= 19) {
  blue = 0
} else {
  blue = 138.5177312231 * Math.log(tempInternal - 10) - 305.0447927307
}
red = parseInt(red)
blue = parseInt(blue)
green = parseInt(green)
this.logger.info("rot: "+red+", gruen: "+green+", blau: "+blue)
var rgbColor = new java.awt.Color(red, green, blue) 

this.logger.info("percentage: "+percentage+", temp: "+colorTemp+", brightness: "+brightness+", rgbColor: "+rgbColor);
events.postUpdate('AdaptiveLichttemperaturHSB', new HSBType(rgbColor))

it fails then at the post update step.
logging the colors individually gives:

 2021-01-20 13:04:30.476 [INFO ] [org.openhab                         ] - rot: 255, gruen: 234, blau: 216
 2021-01-20 13:04:30.477 [INFO ] [org.openhab                         ] - percentage: 95.0327221302614, temp: 5326.145274559149, brightness: 100, rgbColor: java.awt.Color[r=255,g=234,b=216]

so also the java.awt.Color Object seems to be initialized properly.

any Idea? thanks

should have looked at the forum :slight_smile:
works now by using this:

HSBType.fromRGB(redValue,greenValue,blueValue)

but still, that’s different to what this says: Rules | openHAB

is this simply a mistake in the official docs or did I misinterpret it?