October 2016

Controlling X10 (or Anything) from an Echo with Hue Bridge Emulation on a Pi

The Amazon Echo can be extremely useful for triggering home automation. This ranges from custom homebrew devices to widely used devices like Insteon, Wink, etc. I happen to have a mixture of devices including newer Insteon devices and some older X10 devices. I thought it might be nice to control all of them even though Amazon and the home automation vendors didn't necessarily support them (and sometimes required special hubs). I wanted this to work with just what I had already installed.

While Amazon has ways to create custom home automation integrations (using the cloud) -- certain vendors seem to have more privileged implementations than those that can be pulled off with what Amazon has published. In particular, the Echo is capable of "discovering" a Philips Hue Bridge on your private network, enumerating its devices, and making it possible to command them all directly by voice.

So why not emulate a Hue Bridge in software -- for instance, on a Raspberry Pi? That's exactly what some folks did. One good implementation is the Amazon Echo HA Bridge. One can set this up on a Raspberry Pi (or any other machine you have handy) and it emulates a Hue Bridge. This particular implementation is in the form of a Java Spring Boot application. It offers up a web interface one can use to assign "on" and "off" URLs to devices. When you speak the commands, the emulator does GETs on the given "on" and "off" URLs to trigger other devices. While this is convenient for some devices -- others require specific actions to be taken for "on", "off" and other cases. I made some modifications to the core of the emulator (Hue Emulator Mod Example) to support my older X10 network bridge. So far I've kept the code separate from the main project which is evolving. Another recent change that I'll share soon allows a sequence of URLs to be triggered in response to a single command. For X10 control I'd started with the PI running the bridge being connected serially to an X10 network controller using Heyu. But when that controller failed I needed to move to issuing sequences of URLs to another style of X10 controller to support more complex sequences of triggered actions soon. But I offer up my earlier Heyu modification as an example of how it can be done. Now I've got a home full of older X10 devices that are under voice command (without needing to get a new Insteon Hub -- for which later support became available). In fact, I prefer having the flexibility to code my own actions in response to the voice commands.