I've been trying to combine my ICM and PComp midterms. But after dealing with this week's homework, I'm not sure that's a feasible idea.
So we just got these new light bulbs. Yes, light bulbs. They aren't just any light bulbs you see, look at this packaging:
I mean look at it. There's a QR code, so you know it's got to be good. (eye roll) But really, these are pretty cool. They are Philips Hue LED light bulbs that can mix to any color but still produce pretty whites. The moment Stanley brought them home I wanted to know what was going on inside. You install a bridge to the series of tubes and the bulbs are individually controllable over the web or on your iPhone or iPad. Sure that's fun, but if you can talk to them in an app, there must be a way to talk to them directly.
Sadly there isn't an API, yet. But someone still figured out how to hack them, yay! Some folks have started to build iOS apps, others connected them to Siri over at a forum called everyhue.
In class we have been working with JSON and 3D stuff. It just so happens that these bulbs also speak JSON. They are based on the new ZigBee lighting standard, although I'm not sure if Philips API is part of the standard or something unique. Either way, it's pretty cool.
So Processing…i can haz hue?
Not easily it seems. The way the hacked API bulb system goes is you get an API token via a POST request (something I've been learning about in Comm Lab web) and you can check the status of each bulb via a GET request. To change something about the bulb, like brightness or, uh, hue, it's a PUT request. PUT? What are you?
Processing doesn't like to PUT.
I had a heck of a time figuring out how to make a PUT request with processing. Rune (my comm web professor) made an awesome library for processing that can do POST & GET but no PUT. Surely someone has wanted to make an HTTP PUT stuff with processing before.
Apparently not. Or if anyone has, they haven't documented it well.
Well, I found a way and built a proof of concept for controlling Hue lights. The method I'm using is via the Apache HttpComponents Client and a conglomeration of different shared code. But it works:
Final for ICM
Originally I wanted to build a processing app for encoding new RFID tags for my PComp final. After experiencing the torture that is HTTP requests in Processing I don't think I want to try to combine that with serial communication too. Instead, I either want to make a library for the HUE lights to contribute to the community or use them in a fun way… I was thinking a Morse code translator. You would type & it would send Morse code to the lights.
An idea in progress…