Very simple LIFX bulb control

home automation

As fellow LIFX users may know, there is yet to be an official API supporting easy to use locally-installable interface to control the bulbs. (The last part being important, as my internet connection leaves a lot to be desired).

Over the course of LIFX firmware evolution, I have tried various different solutions – the at-the-time official Ruby API, the unofficial Python API, Java API, and lastly the official cloud API. The cloud API was the only one that works reliably to this day, however, I do not like to have .5s lag when controlling my bulbs if my backups are running (this is of course no fault of the LIFX guys, it’s due to really bad bufferbloat on my internet connection).

Luckily the LIFX guys have posted an official documentation of their LAN protocol with example packets included. This enabled me to create a very simple Python script to control by bulbs via local connection.

At the moment, setting hue, brightness, saturation and temperature is supported. The script send a few packets to make sure they arrive but in the future, I am considering listening to replies and not retrying if not needed. That said, it is working very well on my WiFi network.

Without further ado – here is the link:

You can find all you need there, as well as basic usage instructions. To save any discovery, I am using statically assigned IP addresses for my bulbs.

I have also included simple HTTP API providing the colour set command functionality with ACK reply processing. This saves unnecessary re-transmits.

blog comments powered by Disqus