Controlling my light bulb from the command line
Because why use a mobile app when I'm not on my phone
As mentioned in previous posts, I really like LEDs. (I mean, who doesn't?)
A while back I got myself an Avea LED light bulb from Elgato, mainly because it wasn't too expensive compared to other devices and it didn't require any additional base-stations or Wi-Fi setup headaches. And for that, it's pretty neat. It comes with a relatively decent mobile application, which works fine most of the time. However, there was and still is no way to use it with anything else. No API, not even IFTTT integration or anything else to get the bulb out of its isolated Elgato-bubble.
I contacted Elgato about this way back in 2014, but unsurprisingly, I received a pretty sobering answer.
[...] Thank you for contacting Elgato Systems. Unfortunately, we are unable to comment as to the exact time frame of future updates and if certain features will be implemented or not. Currently we have no API available and no IFTT integration.
I will however pass on your request to our product management team in the form of a feature request. [...]
Of course up until now, Elgato has released absolutely nothing to work with.
So ever since I had "get a Bluetooth sniffer and reverse-engineer the protocol" on my TODO-list, but I never seriously tackled it until 2 weeks ago. It was a usual Sunday night in chilly Finland, I just got out of the sauna and if you've ever been you know that you're usually super relaxed afterwards. So I'm sitting in my bean bag chair, coding away on something when I feel like turning down the lights a bit. Looking around I see that my phone is all the way across the room. Too comfortable to get up I start
googling DuckDuckGoing and find this GitHub repository.
Neat! He figured out what bytes to send, no need for a sniffer anymore!
Long story short, I wrote a command line interface in Swift, which starts up a CoreBluetooth Manager, connects to the bulb and sends the bytes corresponding to whatever color is desired.
Since this is not just a PoC and I actually want to use it, I added a bookmark-like "color descriptor" feature to not have to type out RGB(W) values each time.
The entire fun is on Github, and it works pretty much exactly how I want it too, here's a little demo: