MakerAPI: setColor of an RGB light -- what is the "L" for?

Hi, I've been playing with setting the colors of an RGB light using the MakerAPI using an Android app.

What I can't quite figure out is -- is the "L" in HSL the same as the brightness level of a dimmable light? I see it's defined as "lightness" --is that the same thing?

In many color pickers there's 3 sliders - one for each of the HSL values


But, moving the L value (the bottom slider) all the way to 100 produces WHITE.

However, it does appear that passing 100 to the setColor command produces full brightness and not a WHITE light.. it just seems a little confusing to me as I'm trying to allow users to adjust both the color and the brightness of the light.

GET http://192.168.0.202/apps/api/38/devices/130/setColor/[hue:4,saturation:100,level:100]

It's not the same thing.

In my dashboard, I'm using HSL to set the color and a separate slider to set the level. Actually I then have another slider to set the temp (which puts the lamp into WW/CW CT mode instead, because in my experience with the Gledopto lamps I have, the separate CT mode is much much brighter than mixing white from RGB).

Here's a screen shot of the popup when I long-press on a lamp in my dashboard...

And the HSL/V screen if the user presses on the color picker at the top...

(screen captures from my mobile, so not quite as pretty html5 dialogue color picker as on a larger device).

Long story short, based on my experience, the L in HSL is not level and it's best to use HSL to set the color and then level to set the brightness (without changing/distorting the color).

Hope it helps :smile:

1 Like

Thanks for the reply!

In your color picker, you have HSV instead of HSL and 1 difference I notice is the the rightmost value color is bright red where on mine it's white.

it's best to use HSL to set the color and then level to set the brightness

When you say set the color, are you talking about the setColor/[HSL] API? If so, what value do you pass for L?

I guess what I'm trying to understand is - if you move that Value slider only - how is that change sent to the API? Or, is it just ignored as there's a separate Level slider which is used for the level?

From the html5 color picker I use, I get a hex (like #123456). I then use some code to convert that to HSL (there are several example javascript snippets available online) and then send that using Maker API using the setColor command. That sets the color of the lamp using HSL. I use a separate Maker API to drive the brightness/level from the other slider (on the first popup image posted above). Not sure if there is an easier way (probably :smile: ) but it works well after quite a lot of messing around to set it up!

Did you ever figure this out? When I read the HSL values from a bulb I cannot seem to get that into a value I can convert to RGB to display on an HTML page. The "level" really is the dimmer level, not the "lightness" in HSL. So... where does the L value get read from? As I'm understanding there is no way to get the current color of the bulb in HSL or RGB?

I do this, assuming the RGB attribute is kept up to date:

def getRgbMap()
{
    def RGB = device.currentValue("RGB")    
    if(null == RGB)
    {
        return
    }
    
    def rgbMap = [:]
    for(color in RGB.replace("{","").replace("}","").split(", "))
    {
        def splitColor = color.split("=")
        rgbMap[splitColor[0]] = splitColor[1]
    }
    
    return rgbMap
}

Hmm... there is no RGB value on a Hue bulb?

Welp, there goes that idea. :wink:

I figured this was a custom driver of yours or something. Apparently RGB is a new-ish and/or not that widely used attribute