This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Phlips Hue - RGB Color Feedback - Zigbee
#1
Hello everyone,
I am trying to read the color status of a Philips RGB lamp with the Zigbee gateway.
Looking at the link: https://kb.logicmachine.net/libraries/zigbee/

I have been able to get the On/Off status, color temperature, but I am not able to read the RGB status.I don't understand that about xy and then being able to convert it to 3 bytes to use it on KNX screens.
Can anybody help me?
Thank you so much in advance,
Reply
#2
Try using xy_to_rgb from user.hue v2.lua: https://forum.logicmachine.net/showthrea...50#pid6250
Reply
#3
Code:
RGB = event.getvalue()

-- Norm of RGB values
R = bit.rshift(bit.band(RGB, 0xFF0000), 16)
G = bit.rshift(bit.band(RGB, 0x00FF00), 8)
B = bit.band(RGB, 0x0000FF)

Red =    R / 255
Green = G / 255
Blue = B / 255

-- Gamma correction
if Red > 0.04045 then
  Red = ((Red + 0.055) / (1 + 0.055))^2.4
else
  Red = Red / 12.92
end

if Green > 0.04045 then
  Green = ((Green + 0.055) / (1 + 0.055))^2.4
else
  Green = Green / 12.92
end

if Blue > 0.04045 then
  Blue = ((Blue + 0.055) / (1 + 0.055))^2.4
else
  Blue = Red / 12.92
end

-- Coversion RGB > XY
X = Red * 0.649926 + Green * 0.103455 + Blue * 0.197109
Y = Red * 0.234327 + Green * 0.743075 + Blue * 0.022598
Z = Green * 0.053077 + Blue * 1.035763

x = X / (X+Y+Z)
y = Y / (X+Y+Z)

-- Coversion XY > CCT
n = (x - 0.3320) / (0.1858 - y)
cct = math.floor((-449 * ((x - 0.332) / (y - 0.1858))^3) + (3525 * ((x - 0.332) / (y - 0.1858))^2) - (6823.3 * ((x - 0.332) / (y - 0.1858))) + (5520.33))

log(cct)
Reply


Forum Jump: