philips hue "xy" color value to hex value in node.js

110 Views Asked by At

When calling to the api of my philips hue bridge to get the data of a lamp I get a JSON result like this:

{
    "state": {
        "on": true,
        "bri": 254,
        "hue": 23573,
        "sat": 254,
        "effect": "none",
        "xy": [
            0.2113,
            0.669
        ],
        "ct": 500,
        "alert": "select",
        "colormode": "xy",
        "mode": "homeautomation",
        "reachable": true
    },
        // etc etc
}

Now I have node.js app where I need the hex color that is equivalent to the xy value given by the api, I have found out that the code is presumably a CIE 1931 value, but I could not find a way to convert that value properly and get a hex code back.

I tried some npm packages but couldn't get it working

0

There are 0 best solutions below