Tuesday, February 9, 2016

Homebridge It

Tomorrow, and tomorrow, and tomorrow, creeps in this petty pace from day to day, to the last syllable of recorded time - Macbeth

When Apple announced HomeKit at WWDC it sounded awesome. I have been slowly getting my house onto the Internet of Things (IoT) over the past few years, much to my delight, and perhaps to Mrs.Chaos' annoyance. I have a lot of apps on my phone to control all the different Things in my home and the promise of my beloved Apple solving the multiapp problem was amazing.

Then months and months and months passed and none of my devices were becoming HomeKit enabled. Tomorrow, and tomorrow, and tomorrow, brings forth this petty pace. Then came the vendor leaks that Apple was imposing stringent security requirements on devices for them to be certified for HomeKit. Which in the grand scheme of things is fantastic - we were heading towards a future where every device in home was connected to the Internet and they all had a password "admin/admin." Apple is forcing real passwords and real cryptography, but it means that none of my legacy unsecured devices had any hope of making into HomeKit.

I learned about an open source project called Homebridge - which is a server designed to wrap older devices with HomeKit APIs. Homebridge isn't HomeKit certified, so it means when you connect to it, Apple gives you the BIG warning that it's not certified, is probably not secure, and could be malicious. But of course I did it.

The result was that magically my WeMo-controlled fan, coffee pot, garage lights, my Nest thermostat, my MyQ garage, and my Netatmo Weather Station all appeared like magic! MAGIC! I bought the highly recommended Home app immediately to start taking advantage of it.

There were some holes in my home internet of things - my TCP Connected lights don't show up. The August SmartLock doesn't show up. Sad, right? Whatever to do.

Well ya know what? Homebridge is written in Node.js and the modules that run the devices are just Node.js packages. I know how to write JavaScript. How hard could it be?

I installed Charles Proxy to proxy my iPhone traffic and started running the apps that control my lights, garage, and lock - and you know what? They all use pretty clean and simple REST APIs that are easy to understand.

The result? I wrote a module that controlled my TCP Connected Lights - it probably took about 8 total hours to do. Because my only personal development time when the kids are asleep, 8 hours of work took over two weeks of my time to do - but hey, it's up and it's working!

Now I can say, “Hey Siri, goodnight” and the bedroom lights turn off and the bedroom fan turns on.  I can say, “Hey siri, open the garage” and the door opens. The temporal forces are trying to rip my home apart, because I am living in the future!