Thanks for sharing. Now only one feature left to solve.
I found a RGB to CIE color converter in the Samsung ST driver for Ikea RGB bulbs.
I'm not familiar with the groovy language nor with programming zigbee devices but
if another developer wants to pick it up from here, this might be a clue to
converting the color space and returning the correct value.
If someone has a link to the Generic Zigbee bulb CT driver I would be glad
to have a look at it anyway.
Code below:
def colorRgb2Xy(r, g, b) {
logTrace "> Color RGB: ($r, $g, $b)"
r = colorGammaAdjust(r)
g = colorGammaAdjust(g)
b = colorGammaAdjust(b)
// sRGB, Reference White D65
// D65 0.31271 0.32902
// R 0.64000 0.33000
// G 0.30000 0.60000
// B 0.15000 0.06000
def M = [
[ 0.4123866, 0.3575915, 0.1804505 ],
[ 0.2126368, 0.7151830, 0.0721802 ],
[ 0.0193306, 0.1191972, 0.9503726 ]
]
def X = r * M[0][0] + g * M[0][1] + b * M[0][2]
def Y = r * M[1][0] + g * M[1][1] + b * M[1][2]
def Z = r * M[2][0] + g * M[2][1] + b * M[2][2]
logTrace "> Color XYZ: ($X, $Y, $Z)"
def x = X / (X + Y + Z)
def y = Y / (X + Y + Z)
logTrace "> Color xy: ($x, $y)"
[x: x, y: y]
}
def colorGammaAdjust(component) {
return (component > 0.04045) ? Math.pow((component + 0.055) / (1.0 + 0.055), 2.4) : (component / 12.92)
}