The two numbers are generated by a function node and have the variables X and Y. I've tried a few things but I can't get the payload to form.
I have tried several things but I can't get the payload formatted like this. And without the " the Zigbee lamp always changes to green.
Hello, sorry I'm only getting in touch now.
Here is the code that creates the payload.
If I use an inverted comma instead of the square bracket, I don't get a value.
let red = msg.payload.r
let green = msg.payload.g
let blue = msg.payload.b
let redC = (red / 255)
let greenC = (green / 255)
let blueC = (blue / 255)
console.log(redC, greenC , blueC)
let redN = (redC > 0.04045) ? Math.pow((redC + 0.055) / (1.0 + 0.055), 2.4): (redC / 12.92)
let greenN = (greenC > 0.04045) ? Math.pow((greenC + 0.055) / (1.0 + 0.055), 2.4) : (greenC / 12.92)
let blueN = (blueC > 0.04045) ? Math.pow((blueC + 0.055) / (1.0 + 0.055), 2.4) : (blueC / 12.92)
console.log(redN, greenN, blueN)
let X = redN * 0.664511 + greenN * 0.154324 + blueN * 0.162028;
let Y = redN * 0.283881 + greenN * 0.668433 + blueN * 0.047685;
let Z = redN * 0.000088 + greenN * 0.072310 + blueN * 0.986039;
console.log(X, Y, Z)
let x = X / (X + Y + Z);
let y = Y / (X + Y + Z);
X = x * 65536
Y = y * 65536
msg.payload = {"Device":"0x88DA","Send":{"Color":[X,Y]}};
return msg;
node and therefore node-red run in JavaScript (totally different to Java) so don't go looking for Java tutorials otherwise you will be completely baffled