Friday, December 9, 2016

Persistence for Philips Hue

Two of the lights in our living are Philips Hue lights.
I especially like them for their ability to reach 2000K color temperature (very warm white light), which gives a nice mellow yellowish white light.

We control the lights via normal light switches contained in the light fixture.
Due to the way Philips Hue lights work this implies that whenever we turn on the lights again they go back to the default setting of around 2700K (normal warm white).

In order to fix this once and for all I wrote a little program in rust that does this:

  • poll the state of the lights every 10 seconds (there is no subscribe/notify :( )
  • keep the light state in memory
  • if a light changes from unreachable (usually due to being turned off by the switch) to reachable (turned on by the switch), restore the hue to the last state before it became unreachable
Code is in rust (of course) and can be found at

Just run it on a local server (I use my shuttle xs36v) and it automatically starts working.
Keep in mind that it can take up to a minute for the Hue system to detect that a light is reachable again.

A short video demoing the system in action:

No comments: