Having Trouble Finding a Good Resource To Convert Between RGB and HSVK

I’m using the Python LANLifx library for a project and I’m working on and I’m trying to find resources to understand how the HSVK values work. I guess what I’m really asking is for a good resource to understand representing Hue on a level of 0-65k. I see some other topics on this forum about this question but really am curious on how it works not just how to convert.

If I look on this site (and many others),

I see Hue represented on a scale of degrees to 360. I’m curious of how we get from this 0-360 to the much greater level, and how it factors in with the current libraries out there. Just out of putting random values in there I get
current_bulb.set_color( [5000, 65535, 65535, 3500]) # Red
current_bulb.set_color( [20000, 65535, 65535, 3500]) # Green

        current_bulb.set_color(	[10000, 65535, 65535, 3500]) # Yellow

I’m coming from an RGB world so just getting pointed in the right direction would be really helpful!
Cheers!

Hi,

In the case of our HSBK, the conversion is

hue = lifxhue / 65535 * 360
saturation = lifxsaturation / 65535
brightness = lifxbrightness / 65535
kelvin = lifxkelvin
1 Like

Hi @delfick-employee thanks for the reply. Where would you get those values from though. If HSB is on a value from 0-360 and we need a integer value why would we need to divide by 65535 and multiply by 360. If I have a hue of
250 I would put it into the formula of
250 / 65535 * 360 = 1.3,

which isn’t on the scale of 0 - 65535. So I’m still a bit confused. Thanks for the help.

So for example, if you ask the bulb for a GetColor then you’ll get back the following in the payload:

hue         : 10922
saturation  : 65535
brightness  : 19660
kelvin      : 3500

Which corresponds to a hsbk value of

hue         : 60
saturation  : 1
brightness  : 0.3
kelvin      : 3500

I used the colormine library: http://colormine.org/ - super, super handy as it does everything for you!!

4 posts were split to a new topic: Does kelvin have an effect when saturation isn’t zero?