Hacking the Hue
The first thing that I wanted to do with the Hue bulbs is get them working with Siri. I had seen last year someone created SiriProxy (in Ruby, luckily for me), and that it should allow me to do this. I’m actually using the The-Three-Little-Pigs fork as it has active developers, although I’ll continue to just call it SiriProxy. The other part of making this work was the Hue API. Philips has said that they want to release an SDK at some point, however quite a few people have sniffed the API already and gained almost full control of the system.
The SiriProxy plugin format is very straightforward. SiriProxy will iterate through regexs in each plugin and if it doesn’t find a match, forward the request to the normal Apple server. So I wrote a script of commands to control the lights and then made some regexs to implement them.
Some of the commands I’m using:
- Turn off all the lights
- Turn on the bedroom light
- Turn up the kitchen
- Set the hallway to 20%
- Set the bedroom to light blue (not implemented yet)
- Make it look like a sunset (not implemented yet)
I found it pretty easy to get SiriProxy running on my Mac, although I already have some exposure to Ruby development. Installing it on my Raspberry Pi was a different story and took some massaging of the Ruby environment, but I wanted to use it instead because it would remain powered on at home all the time. It may be worth it to have it listen on a port above 1024 to avoid superuser privileges to run it. It’s currently a particularly fragile setup, requiring a
bundle exec rvmsudo ./siriproxy-restarter command, although it has worked well over the past few days.
A big takeaway from this project is just how well Siri handles natural language processing. SiriProxy won’t let you handle anything as magical as “Siri, could you make the kitchen a little more romantic?” unless you make that an explicit command. It’s still possible to speak commands in conversational english, but it isn’t flexible outside the regex that you create. It also tends to misrecognize words like hallway (“whole way”). I’m guessing words get weighted during recognition, and hallway doesn’t make sense in the context of Siri’s usual commands. But! Despite this weakness, and the obvious elephant that is how Apple can open up an API that directs command meaning to specific apps (and lets them declare contexts), it’s really fun to dream up what could be possible if they did.
You can grab my SiriProxy plugin for Hue lights on GitHub.
The Philips Hue hardware was first intriguing to me because they explicitly mention that it’s a ZigBee certified product on the packaging and labels. ZigBee is a wireless technology that is different from WiFi in a few important ways: Low power, equivalent range and intended for light data mesh networks. It’s popular with DIY hardware makers (think Arduinos) for this reason, as well as that it’s much cheaper than WiFi modules. It seems like it may be the wireless standards of choice for consumer home automation systems that are coming to market. As an example, the Nest thermostat was also found to have ZigBee hardware inside, although it isn’t supported in software yet. Because of all this I wanted to see exactly what hardware Philips was using, and if it would be possible to replicate the Hue system.
Opening up the Hue bridge is straightforward. It’s a very lightweight plastic box held together with two screws and plastic clips around the edge. The clips are a bit stubborn, but are certainly able to be moved without breaking. I used an ID card to wedge the two halves of the enclosure open and eventually got it apart.
Inside are just two small circuit boards, not surprising given the weight and hollow feel. One is the main board with the microcontroller and another holds the pairing button and LEDs on the top. Philips went with a STM32 microcontroller, known from the STM32 Discovery dev boards. There’s also a UMEC ethernet transformer (I’m assuming this is because ethernet uses 1/2/2.5V) and a IP101A ethernet chip. The two ICs on the top are TI ZigBee chips which connect to the large upright antenna. Notably, I didn’t see any debug headers anywhere on the board.
It’s simple stuff! Would it be easy to replicate this system? Absolutely, DIYers would not be very surprised by the hardware and there are already some homemade ZigBee automation systems out there. I don’t want to be dismissive of this product though. Philips has obviously put in a lot of engineering into the firmware to make sure that everything works easily for end users, and creating a JSON REST API for their mobile apps to talk to. Philips has also made the LED lights very compact. They’re the size of a regular 60W incandescent but contain a AC/DC converter and the ZigBee hardware to control the lights. Michael Herf has already taken some great photos of the teardown of a bulb.