I’am new at OpenHAB and would like to implement the Homematic device HM-LC-RGBW-WM (LED Controller). The Problem is, that the LED controller can only receive integer from 0 to 200. So now, I haven’t an idea how I can implement a Transformation from HSBtype to integer 0-200.
I have already tested some rules to convert HSBtype to RGB. But no solution for this controller.
I have already read your tutorial. But I always receive the error that the item aacc_color_r does not exists.
And my other question is, how is it possible to calculate a number from 0-255 from the three Content of variables red, green, blue?
I Need the Color value in the HSV-format…
this is my rule to convert my Color-item to RGB and HSB/V
the only thing i didnt get correct, is the HSB Value in one String ( eg. 100/100/50 )
but i get each single value - maybe this helps
Color LED_1_color "LED 1 Farbe [%.0f]" {channel="wifiled:wifiled:XXXXXXXXXXXX:color"}
Number LED_1_color_R "ROT [%.0f]" <hue>
Number LED_1_color_G "GRÜN [%.0f]" <hue>
Number LED_1_color_B "BLAU [%.0f]" <hue>
String LED_1_color_RGB "RGB [%s]" <list>
Number LED_1_color_hue "Hue [%s]" <hue>
Number LED_1_color_sat "Saturation [%s]" <hue>
Number LED_1_color_bright "Brightness [%s]" <hue>
Number LED_1_color_HSB "HSB [%s]" <list>
import org.openhab.core.library.types.*
////////////////////////////
// LED RGB & HSB Values
////////////////////////////
var String RGBvalues
var String HSBvalues
rule "Set RGB LEDs from Color item using ColorPicker"
when
Item LED_1_color received command
then
val red = (LED_1_color.state as HSBType).red * 2.55
val green = (LED_1_color.state as HSBType).green * 2.55
val blue = (LED_1_color.state as HSBType).blue * 2.55
var hue = (LED_1_color.state as HSBType).getHue
var sat = (LED_1_color.state as HSBType).getSaturation
var b = (LED_1_color.state as HSBType).getBrightness
logInfo("LED_RGB_Values.rules", "R:" + red + " G:" + green + " B:" + blue)
logInfo("LED_RGB_Values.rules", "H:" + hue + " S:" + sat + " B:" + b)
LED_1_color_R.sendCommand(red)
LED_1_color_G.sendCommand(green)
LED_1_color_B.sendCommand(blue)
RGBvalues = red.toString + " / " + green.toString + " / " + blue.toString
LED_1_color_RGB.sendCommand(RGBvalues)
LED_1_color_hue.sendCommand(hue)
LED_1_color_sat.sendCommand(sat)
LED_1_color_bright.sendCommand(b)
HSBvalues = hue.State.toString + " / " + sat.State.toString + " / " + b.State.toString
LED_1_color_HSB.postUpdate(HSBvalues)
end
Thank you so much for your tipps/Solutions. I had a mistake! I don’t need RGB values. I need HSV-values for the Homematic LED controller. So I understand, thats the same as HSBtype. In this case I only need a calculation from HSBtype.Hue to a value from 0-200. Is that possible?