RGB to XY for Philips Hue
Enter a color as HEX, RGB, HSL or a CSS name and get the CIE xy pair a Hue light understands, moved into the gamut of your lamp, with a brightness value and ready-to-paste commands for the Hue API and Home Assistant. Below it, «XY to color» does the reverse.
Gamut C: Hue White and Color Ambiance lights. The Hue API reports it for each light: colorgamuttype in v1, gamut_type in v2.
CIE xy
0.6173, 0.3419Brightness: bri 254 (API v1, 1–254) · 100% (API v2)
Hue API v1 (PUT /api/<user>/lights/<id>/state)
{
"on": true,
"xy": [0.6173, 0.3419],
"bri": 254
}Hue API v2 (PUT /clip/v2/resource/light/<id>)
{
"on": {
"on": true
},
"dimming": {
"brightness": 100
},
"color": {
"xy": {
"x": 0.6173,
"y": 0.3419
}
}
}Home Assistant action
action: light.turn_on target: entity_id: light.your_light data: xy_color: [0.6173, 0.3419] brightness: 255
| Formula | xy before the gamut | xy in Gamut C |
|---|---|---|
| Home Assistant and rgbxy formula · used above | 0.6173, 0.3419 | 0.6173, 0.3419 |
| Philips SDK application note | 0.6334, 0.3245 | 0.6334, 0.3245 |
| Standard sRGB colorimetry | 0.5466, 0.3715 | 0.5466, 0.3715 |
XY to color
Paste the xy of a light, for example from the Hue app’s API or a Home Assistant state, to see the color on screen.
HEX
#FF2700rgb(255, 39, 0) by the Home Assistant formula
This xy is more saturated than a screen can show, so the nearest screen color is given.
How the conversion works
Each channel is linearized with the sRGB curve, then a 3×3 matrix turns the linear red, green and blue into the CIE XYZ values, and x and y are X and Y divided by their sum. The main answer uses the matrix of Home Assistant’s color utilities, the same as in the rgbxy library; the table under the result shows the two other formulas in circulation. If the point lies outside the triangle of the chosen gamut, it is moved to the nearest point on the triangle, as the Philips application note recommends.
The gamut corners for A and B come from that note. For C no public Philips table was found; the corners used here (0.6915, 0.3083 / 0.17, 0.7 / 0.1532, 0.0475) are the ones shared by openHAB and the open Hue libraries. Results are rounded to four decimals; the Hue API accepts more.
Other color tools
For color formats on screens see the color converter; for CIE values used in design, HEX to LAB and HEX to OKLCH.
RGB to xy for Hue: questions
- How do I convert RGB to xy for Philips Hue?
- Undo the sRGB gamma of each channel, multiply the linear red, green and blue by a 3×3 matrix to get X, Y and Z, then take x = X / (X + Y + Z) and y = Y / (X + Y + Z). If the point is outside the triangle of colors your lamp can show, move it to the nearest point of the triangle. This page does all of it and gives values ready for the Hue API and Home Assistant.
- How do I convert xy back to RGB or HEX?
- Paste the x, y pair into «XY to color» below the converter, with the bri value if you have it. The page reverses the same formula: xy sets the ratio of the red, green and blue light, and bri sets the brightest channel. Some xy points that a lamp can show are more saturated than any screen color; then the nearest screen color is shown and marked.
- Which gamut does my Hue light use?
- Current Hue White and Color Ambiance lights use gamut C, the first Hue color bulbs use gamut B, and early Philips color-only lights such as LivingColors, Bloom and Iris use gamut A. The Hue API reports it for each light: colorgamuttype in API v1 and gamut_type in API v2. If you are not sure, use C.
- Why do different xy tables give different values for the same color?
- Three different matrices are in use: the one in Home Assistant and the rgbxy library, another version in a Philips SDK application note, and standard sRGB colorimetry. The application note and sRGB put white at 0.3127, 0.3290; the Home Assistant matrix puts it at 0.3227, 0.3290, a little warmer. On saturated colors they drift much further apart: pure green comes out at x 0.17, 0.12 or 0.30 depending on the formula. Some code also feeds 0–255 values into a gamma curve made for 0–1, which shifts mid-tones. The table on this page shows the result of all three formulas side by side.
- Why is the brightness not taken from the Y value?
- Y is how bright the color looks to the eye, and pure blue has a Y of only about 0.05. Sent as brightness, blue would come out barely lit. The bri value here follows the brightest of the red, green and blue channels instead, so #0000FF gives full brightness and #000080 about half.
- Will the lamp show exactly the color on my screen?
- Close, not exact. A lamp mixes its own LEDs, its gamut differs from your screen, and the color of a light also depends on the room and the surface it falls on. xy fixes the hue and saturation; set the brightness separately.