HTTP API: LIFX Z Current Visual State

Hi. :wave:

How can I determine the current visual state of a LIFX Z strip via the HTTP API?

By visual state, I mean when I’m looking at a Z strip, is it currently appearing as a solid colour, or as a gradient across its zones?

Looking at this example “/lights” endpoint response (cropped for brevity)…

[
    {
        "label": "LIFX Z",
        "color": {
            "hue": 68.64911879148546,
            "saturation": 1,
            "kelvin": 3500
        },
        "brightness": 0.6915999084458686,
        "zones": {
            "count": 16,
            "zones": [
                {
                    "brightness": 1,
                    "hue": 0,
                    "kelvin": 3500,
                    "saturation": 1,
                    "zone": 0
                },
                {
                    "brightness": 1,
                    "hue": 315.5,
                    "kelvin": 3500,
                    "saturation": 1,
                    "zone": 1
                },
                // etc…
            ]
        },
        // etc…
    }
]

…you can see I could pull the state from the root color/brightness nodes (i.e. displaying as a solid colour), or from each zone (i.e. as a gradient across its zones).

Changing a Z strip via the official app, I see that home screen Z strip previews use their root color/brightness nodes…

…and selected Z strip previews use their root color/brightness nodes when visually a solid colour…

…and use their zone values when visually a gradient:

As there’s nothing in the “/lights” response telling me where to pull the current visual state from, I’m stumped as to when to use the root color/brightness values over the zone values.

Would the inclusion of a “using” boolean, something similar to the following, solve the problem?

[
    {
        "label": "LIFX Z",
        // etc…
        "zones": {
            "using": true,
            // etc…
            "zones": [
                // etc…
            ]
        },
        // etc…
    }
]

I’m trying to build a GUI to display Z strips and can’t work this one out.

Cheers!

Hey James,

Thanks for your detailed question! For the Z, the color/brightness values should just reflect the values for the 0th zone, as it ~does in your second and fourth screenshots above.

In the cases where it doesn’t, what I believe is happening is that the API values are read from a cache, and the cache can sometimes be a little stale. I’ve just pushed an API change to ensure it’s freshened in the circumstances you’re looking at, so let us know if you notice a difference.

N

1 Like

Hi @nick,

Yep, a Z’s “zones.zones” array now updates noticeably faster to reflect its visual state – thank you!

Just noticed a root “zones” node is now added to other lights returned by the “/lights” endpoint, not just Zs.

To clarify, I can see it appended to my “lifx_color_a19” bulbs but not my “lifx_original_a21” bulbs.

Does LIFX expose a HTTP API change log anywhere that developers can check for breaking changes?

Being able to periodically check (or even better, subscribe to) something like that would be super helpful.

Cheers!

:nerd_face::call_me_hand: