Chris has wanted the Philips Hue light bulbs for awhile. They're wifi-controlled LED light bulbs that you can control locally or via the internet with your iOS (or android) device. So for Christmas he received a starter kit that came with three bulbs and he's been enjoying changing the lights in the rooms to different colors. Honestly having the two different colors in the same room is somewhat irksome.

One of the really nice things about the Hue is it's hackability, and I wouldn't have even known about that if not for this awesome ars technica review. There's a pretty vibrant hacking community and the ars review does a really nice job laying out how to do everything. There's even a nice javascript file to set everything up for yourself. While I don't personally have any experience in javascript, Chris does. And the internet has an answer for anything we can't figure out.

So armed with the information from the ars review and information from rsmck, who has been pioneering hue hacking, I got to work.
The first order of business was to get access to the Philips Hue Hub so I could make requests (changing the colors, turning lights on and off). The way to do this is to make a HTTP POST request of the Philips Hue hub to establish a username. That username is then used to make changes to the various light bulbs.

I tried a few ways yesterday to get a POST request to work in windows with python and javascript, based on some examples I saw online and stuff Chris helped me with. No luck.
So tonight I logged into the Raspberry Pi I have running a web server for the Kindle, and tried my hand at cURL.

Not surprisingly, I'm not the only one who tried this and I found a pretty handy example of what to do. Here's what worked for me via the command line in linux:

curl -d "{\"username\": \"PLACE YOUR USERNAME HERE\", \"devicetype\": \"PLACE YOUR DEVICE NAME HERE\"}" http://PLACE YOUR HUB IP ADDRESS HERE/api

As noted on rsmck's website, the first thing I saw was an error saying the link on the hub wasn't pressed. So...I pressed it and tried again.

Success!
Next I downloaded and opened up the javascript file Lee Hutchinson from ars technicia provided in the Hue review. All that was needed was a simple tweak to the file to add my hub's IP address and the username I just established. Then I dropped the file on the Pi web server and away I went!
We can now control the light bulbs via the web server if we'd like. Sure, I could have just done that with the iOS app, but there's a lot more potential here. With access to the Hue Hub I can schedule the lights to act as a sunrise lamp on weekdays but not weekends, or only turn on on certain days of the week. Since the Philips app wont let you schedule anything based on weekdays or weekends (or even indefinitely) the whole concept of scheduling a lamp to slowly go on or off is out the window. And since I know Chris has always wanted a sunrise lamp, that's exactly what I needed.

I look forward to tweaking this over the next week while I'm off work. And the really great part is that Chris knows javascript and he's pretty excited to set up things how he wants them. Plus he can code and design the website and make it really nice.

1 comments:

Instead of the 10 different thread colors the pattern suggested, I used 9 total, 8 of which ... SSH via USBNetwork Hack on Kindle 4 ... Hacking the Philips Hue ... 1380/365 - Random Friday · 1379/365 - Colorful Lights: Hacking The Philips Hu. coaster ville

Post a Comment