One of the things that was missing for me when I got my HC3 recently was support for LIFX lights. I have some of these lights and wanted to add them to my integrations in HC3. So, I have written a QA to provide this integration. It’s my first QA (and Lua programming) but seems to work OK.
The QA is a controller for the LIFX lights in the system. On start-up it discovers the lights on the network and for each light it creates a child device. Discovery is run regularly (based on a number of seconds in a QA Variable) to allow for devices being added. Light capabilities are read from the LIFX repository on GitHub and each child is given a UI according to it’s capabilities (e.g. white temperature, colour, infrared). These are then devices in the dashboard and can be operated from scenes and other QAs like EventRunner4. This is stretching the boundaries of official feature support on the HC3 but it works!
Lights are polled on a regular interval (again set by a QA Variable) to get their latest settings. This allows for the fact that other software such as the LIFX official app may also be used to control the lights and keeps them in sync.
If a device goes “dark” for a period of time, (it may be turned off at a switch), then the child device is hidden. It is not deleted as it may then be created with a different ID when available again and that would make it difficult to keep consistent in other scenes/QAs. If a device is no longer used or has failed, then there is a button in the controller UI to toggle hidden children and you can then delete it using the dashboard.
Light names are read from the devices and used to name the child device. Location is read and can be seen in the log file when the list devices button is used in the UI. The location is not used as you can put the devices in your own sections and rooms in the HC3.
I only have white, variable white temperatures and colour lights which I can test with. It should also work with the infrared light as well. Multi-zone products are not supported as I cannot test them, and it is a UI challenge on the HC3.
The controller uses the LAN protocol as I didn’t want to be dependent on the LIFX web services being available given the aim is to keep things controlled from the hub. It’s UDP over Wi-Fi so packets can go missing occasionally especially if other software is interacting with the lights as they are not good with concurrent queries and tend to send incomplete packets. This does not happen very often though.
You will still need to use the LIFX app to edit names or if there are firmware upgrades available.
This is a first version but does most of what I think is needed. If others think this is of any use, then I can add it to the download section.
LIFX_Controller (v0-1).fqa