HSBType.getRed etc

I’ve a rule which should analyze the RGB parts of the value of a colour item.
When I set the colour (e.g. with .sendCommand(HSBType::fromRGB(100, 100, 100)) the red, green and blue value will not be returned as 100 but instead I get the value of the brightness???.
Here is my rule:

rule "Farbcode setzen"
when
  Item cLt_TerrasseLichtFarbe changed 
then
  var HSBType hsbValue
  var int red
  var int green
  var int blue
  var int bright
  
  if (cLt_TerrasseLichtFarbe.state != UNDEF)
  {
	  hsbValue = cLt_TerrasseLichtFarbe.state as HSBType
	  red = hsbValue.getRed.intValue
	  green = hsbValue.getGreen.intValue
	  blue = hsbValue.getBlue.intValue
	  bright = hsbValue.getBrightness.intValue
logInfo("Farbcode ", red.toString + ", " + green.toString + ", " + blue.toString + ", " + bright.toString)	    
	  
	  if ((red == 100) && (green == 0) && (blue == 0)) // rot
	  	Farbcode = 1
	  else if ((red == 100) && (green == 100) && (blue == 0)) // gelb
	  	Farbcode = 2
	  else if ((red == 0) && (green == 100) && (blue == 0))  // grün
	  	Farbcode = 3
	  else if ((red == 0) && (green == 100) && (blue == 100))  // cyan
	  	Farbcode = 4
	  else if ((red == 0) && (green == 0) && (blue == 100)) // blau
	  	Farbcode = 5
	  else if ((red == 100) && (green == 0) && (blue == 100))  // magenta
	  	Farbcode = 6
	  else if (sLt_TerrasseLichtDisco.state == ON) // Disco-Modus
	    Farbcode = 7
	  else  // frei definiert
	    Farbcode = 8
logInfo("Farbcode", Farbcode.toString)	    
	  nLt_TerrasseFarbe.postUpdate(Farbcode)
  }
end

The logged values are:
2017-08-18 08:56:48.634 [INFO ] [pse.smarthome.model.script.Farbcode ] - 39, 39, 39, 39

If I use .red instead of .getRed it’s the same.

Any idea what’s wrong?

hsbValue.getRed, hsbValue.getGreen and hsbValue.getBlue return a percentage type (source) and 100 from 255 is approx. 39%.

If you want the RGB values you probably need to do something like:

Color color = hsbValue.toColor()
logInfo("Farbcode", "R: " + color.getRed())
logInfo("Farbcode", "G: " + color.getGreen())
logInfo("Farbcode", "B: " + color.getBlue())