Controlling Homebridge with Alexa

Controlling Homebridge with Alexa

I've written a fair few posts about HomeKit and Homebridge but there was one piece of that whole puzzle that I was never really happy with—Siri. While Siri does a job to some extent I think it's hard to say that it does it well. Constantly mishearing or misunderstanding what I'm saying, having to have a phone or iPad nearby to activate, and long waits while it converts speech-to-text were infuriating.

My Dad had recently bought into the Alexa eco-system with an Echo Dot and was controlling his Philips Hue setup with ease. He couldn't stop praising the thing—lauding its accuracy, the fact that it can hear you from a distance, and Spotify integration—and so when they had refurbished Dots on offer for £40 I bought one.

Alexa vs. Siri

I'll be honest, I never really "got" the Echo. I didn't understand what value it really added to the home but I'm now a total convert. There are three major bonuses Alexa has over Siri.

  1. It's always there.
  2. It's more responsive and more accurate.
  3. It does more thanks to thousands of third party skills.

It's surprising how quickly saying "Alexa, play Prince" or "Alexa, what's the weather like tomorrow?" has become natural. I think music and home automation are the killer applications for the Echo and while Siri has the home automation side of things covered substantially with HomeKit, Apple restrict voice control of music to Apple Music which totally sucks.

It's surprising how quickly saying "Alexa, play Prince" has become natural.

Home Automation with Alexa

Depending on your setup it's possible that Alexa will work with your lights and other smart devices right out of the box. Amazon's site lists over 400 Smart Home skills and that list is constantly growing. The big names such as Philips Hue and LIFX are here, but surprisingly there's even a Magic Home skill for those cheap lightbulbs and LED strips I wrote about previously.

Alexa Smart Home

Homebridge + Alexa

While the majority of skills will fulfil most needs there was one missing for me. In my last article I wrote about controlling my TV and other IR devices with the Broadlink RM and that was something I also wanted to do with Alexa.

I'd already got it working with HomeKit thanks to my Homebridge instance running on a Raspberry Pi Zero so thought perhaps I could utilise that to reveal the HomeKit devices to Alexa. It turns out I was right.

Installation and Configuration

Now this may not be for everyone as installation isn't quite as simple as installing a Homebridge plugin (at least at the moment). There is an open issue regarding Alexa Skill support and I'd expect that to come in the future. For now though it involves replacing your current install with one that will expose your devices.

If your install is working perfectly you may be understandably cautious about replacing it with a forked version of Homebridge. However the installation process is pretty simple and you should be back up-and-running within 10 minutes or so. I did encounter some issues with permissions but assuming your version of node is correctly installed you should be fine.

First of all, delete the existing version of Homebridge and HAP-NodeJS.

sudo npm uninstall -g homebridge
sudo npm uninstall -g hap-nodejs

Once removed the Alexa build can be installed.

sudo npm install -g https://github.com/NorthernMan54/homebridge

Finally, a new property needs to be added to the bridge section of the config.json. Add ssdp and ensure the value is set to 1900 to complete the installation.

 "bridge": {
    "name": "Example",
    "username": "CC:22:3D:E3:CE:31",
    "port": 51826,
    "pin": "031-45-154",
    "ssdp": 1900
},

Run Homebridge as you did before with the homebridge command and it will now expose your devices to an Echo on the same network.

"Alexa, turn on the lights"

Now that devices are discoverable, Alexa can be asked to find them. This can either be done via the app under the Smart Home > Devices section or by saying "Alexa, discover devices". If working, the lady in a tube will report back the number of smart devices found and reveal them in the app as "Lux Light".

Alexa + Homebridge

Not everything that can be done with HomeKit is currently supported by the following commands can now be spoken.

  • Alexa, turn on the _______
  • Alexa, turn off the _______
  • Alexa, set ______ to number percent

I also took the time to great a group for "Lights". I currently only have smart lights in my living room but you may want to separate these groups by rooms similar to Apple's Home app.

Come Say Hello! Drop me an email, follow me on Twitter, or check out Cocoon (you totally should, we're doing some cool stuff over there).