LIFX Developer Zone

Bias Lighting & HomeKit

Hello - I’m still new here to the community so I apologize if I missed this topic elsewhere while searching.

I recently added a few Z strips to my Lifx Inventory and quickly learned that the Bias lighting effect/theme cannot be added to HomeKit due to functionality limitations. Is this something that can be remedied in a future Lifx update…

OR

Does anyone happen to know a way to use something like a dummy switch in Homebridge to trigger the Bias lighting effect/theme as I know you can trigger it (sorta) using shortcuts. Just haven’t figured out a way to kept them on using that method due to the parameter that’s exposed from Lifx to shortcuts requires a duration to be added.

Thanks I’m advance for any direction anyone can provide.

If you’ve saved the bias as a scene, you could modify my effects switch to turn on the scene instead: Creating HomeKit Switches for LIFX Morph and Flame Effects

You’ll want to use th Activate Scene · LIFX HTTP Remote Control API option.

Thanks for the quick reply! one more “novice” question I see in the HTTP control API it’s calling for the scene ID… where can I obtain that for the URL?

List Scenes · LIFX HTTP Remote Control API will tell you the scene ID. :slight_smile:

1 Like

Would you mind giving this a quick look over? Again I apologize I’m still pretty new to the whole DIY HomeKit world. My gut tells me something is prob wrong in what I’ve substituted. I’ve attached it as a a .pdf Activate_Scene.pdf (15.3 KB)

Thanks again for all your help.

I suggest something a lot simpler:

{
    "accessory": "HTTP-SWITCH",
    "name": "Bias Lighting",
    "switchType": "stateless",
    "onUrl": {
        "url": "https://api.lifx.com/v1/scenes/scene_id:<scene uuid>/activate",
        "method": "PUT",
        "strictSSL": true,
        "headers": {
            "Authorization": "Bearer <token>",
            "Content-Type": "application/json"
        }
    }
}

If you turn this switch on, it’ll set the scene and turn itself back off.

Is there a line that I could add which when the switch is turned on, the light would turn on, set the scene, and then remain on till the switch is turned off? That way when it’s added to the scene in HomeKit everything would remain in the “On” state, till the “Off” trigger is executed in HomeKit?

Or will this code produce this result…
In native HomeKit:
New Scene
-with this switch set to turn on
-with the Z strips also set to turn on

Basically the end result I’m looking for is something like…

In Native HomeKit:
Scene: Movie Night
-trigger z strips in bias lighting (via Homebridge switch)
-plus my movie poster accent mini’s in the set color which are already part of the movie night scene.

Sorry if I’m a bother (wasn’t kidding when I said new to this, lol). But I do very much appreciate your help figuring this out.

You can achieve your result with my simple option, but the scene won’t appear as “active” once its set (because the switch will turn off).

If you want the switch to reflect the current state of the Z strip (and turn it off, if you turn the switch off), you’ll need a more complex configuration like this:

{
    "accessory": "HTTP-SWITCH",
    "name": "Bias Lighting",
    "switchType": "stateful",
    "onUrl": {
        "url": "https://api.lifx.com/v1/scenes/scene_id:<scene uuid>/activate",
        "method": "PUT",
        "strictSSL": true,
        "headers": {
            "Authorization": "Bearer <token>",
            "Content-Type": "application/json"
        }
    },
    "offUrl": {
        "url": "https://api.lifx.com/v1/lights/:selector/state",
        "method": "PUT",
        "strictSSL": true,
        "body": "{\"power\": \"off\"}",
        "headers": {
            "Authorization": "Bearer <token>",
            "Content-Type": "application/json"
        }

    },
    "statusUrl": {
        "url": "https://api.lifx.com/v1/lights/:selector",
        "method": "GET",
        "strictSSL": true,
        "headers": {
            "Authorization": "Bearer <token>",
            "Content-Type": "application/json"
        }
    },
    "statusPattern": "\"power\": \"on\"",
    "statusCache": 2000
}

Note that I haven’t actually tested this, but it should work. You’ll need to replace :selector with the actual values from your setup.

You can review Selectors · LIFX HTTP Remote Control API to see how to build a selector. The simplest option is id: d3b2f2d97452 (where d3b2f2d97452 is the serial of your Z strip).

However, if you want to get fancy, you could use scene_id:<scene_id> as the selector for the offUrl so that the switch turns off all the bulbs that are in the scene. For the statusUrl, pick a single bulb and use the id:d3... selector, otherwise Homebridge will get confused with multiple power statuses.

I’ve added a 2 second cache for the status of the bulb so that HomeKit doesn’t hammer the LIFX HTTP API. This means that the status will be up to 2 seconds out of date.

1 Like

I was able to get this into Homebridge just a few min ago, and it works perfectly! And HomeKit uses the “dummy switch” exactly how I’d hoped it would.

Thank you very much for your help with this.

You’re welcome! Keep in mind this uses LIFX’s HTTP API, which means if your internet is down, the switch won’t work.