Logic Machine Forum
Phlips Hue - RGB Color Feedback - Zigbee - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Phlips Hue - RGB Color Feedback - Zigbee (/showthread.php?tid=5316)



Phlips Hue - RGB Color Feedback - Zigbee - Jose - 21.03.2024

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,


RE: Phlips Hue - RGB Color Feedback - Zigbee - admin - 21.03.2024

Try using xy_to_rgb from user.hue v2.lua: https://forum.logicmachine.net/showthread.php?tid=890&pid=6250#pid6250


RE: Phlips Hue - RGB Color Feedback - Zigbee - Joep - 25.03.2024

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)