I’m in a really annoying situation where I can’t add my new Switch to HomeAssistant because LIFX doesn’t have switch support for it for some reason, and I can’t add the Switch to HomeAssistant via HomeKit because I dont own an iPhone so I can’t obtain the HomeKit Pairing Code to add it to HomeAssistant via HomeKit.
Please just add switch support to HomeAssistant to fall in line with other products. Failing that, please let Android devices view the HomeKit Pairing Code. Neither of these things could be hard to do given other products already have HomeAssistant support, and the pairing code exists in the app already, just let me view it.
Second that. In the meantime, I’m writing a python polling script that presents the relays on mqtt topics
If you buy a LIFX Switch that has a HomeKit code provided in the manual, you don’t need any iOS device at all.
While you can poll the relay state, you cannot be notified of a button push except via HomeKit.
Switches were installed by a licenced electrician (as is required in Australia), and they promptly threw away all the packaging. But as far as I understand the home kit pairing codes are no longer in there anyway.
Not concerned with reading buttons at this stage, just need a way to read and control relays. Polling every few seconds seems a good enough solution.
Yep, codes arent printed on newer switches. I pulled mine off the wall (it says it’s printed on the device on the back side) and it was not there. I also checked all the documentation in the box, was not there.
I’ve got a few more wrinkles to iron out, but then I’ll share my code. Should be in a few days
My fork of lifxlan python repo with a few additions: GitHub - dii/lifxlan: Python library for accessing LIFX devices locally using the official LIFX LAN protocol.
If you run
examples/mqtt.py it’ll detect all the switches on your local network, check which buttons control relays, and then create a set of mqtt topics for each relay before doing an mqtt loop_forever(). The topic names are printed so you can easily copy/paste them into your home assistant config, described next. By default, it polls relay states every 5 seconds.
In your home assistant
configuration.yaml, add mqtt entries for what is attached to your relays. For example, I have a chandelier on one of them and it is configured as a light as follows:
name: "Kitchen chandelier"
Pushed a new update that allows you to configure what is attached to each relay and then offer discovery so you don’t need to manually configure anything in home assistant. I’m running this as a systemd service now and works great