Magically control (nearly) everything – how to effortlessly add voice control with Alexa and OpenHab

Published by Oliver on

Do you like those films as much as I do where can just talk to their computer and it will do what they want it to? Think of Jarvis from the Iron Man movies. While we are not quite there yet simple voice control with devices like the Amazon Echo is working quite well already. In this article I will show you how to control pretty much every smart device with your voice.

What we need

Well of course we need a voice control device. While it is also possible to use device like the Google home I have decided to use the Echo devices from Amazon with their Alexa. Which one does not really matter, it should be working with all of them. I personally have a couple of small Echo Dots.

If you are interested in buying a voice assistant consider doing it via my affiliate link. It does not change prices for you and allows me to pay for the servers 😉
Echo Dot
Echo
Echo Show

The second thing we need is a smart device we want to control with our voice. For example your smart lights. While some devices can be directly controlled by your Echos this only works with cloud connections and a lot of the really cheap devices are not supported. So I chose to go another route.

If you are looking for full control of your own devices and a simple interface for all of them you should use a smart home controller software. There are easy to set up, opensource and free options here like OpenHab and HomeAssistant. I am personally using OpenHab. So first get your things set up in OpenHab. If you are looking powerful yet cheap devices maybe use Tasmota or Zigbee devices.

Connect OpenHab to your Echos

Usually smart devices are connected to the Amazon Echos via their cloud services and so called “Skills” to add voice control. This means all your devices are relying on the cloud and might not even work without it. While the Echos themselves won’t work without an Internet connection (sadly we can’t change that) we can at least decouple everything else. This means we will have full (offline) control over our devices but still expose them to voice control via the Echos. Let’s do it.

First go to the PaperUI of your Openhab installation and install the “Hue Emulation” binding in the “Misc” tab. This will allow us to expose any device controlled by OpenHab as a fake Hue light to the echos.

Installing the Hue Emulation binding

Now open your item config files and find the devices you want to control via voice. To each you need to add a new tag like this [“Lighting”]. It will look like

Dimmer BulbHallway_dimmer       "Birne Flur Dimmer"                <light> (grBulbs) ["Lighting"] { channel="mqtt:topic:mosquitto:BulbHallway:brightness" }

You can use three different tags here that will result in different kinds of devices shown to the Echos:

  • Lighting” can be used for simple on/off/dimmable light bulbs and will be exposed as a dimmable white bulb to Alexa
  • ColorLighting” can be used for RGB lights and will be exposed as a color bulb
  • Switchable” can be used for anything that can only be turned on or off and will be exposed as an OSRAM SMART+ plug

I use “Lighting” for all my Tradfri light bulbs, “ColorLighting” for my RGBW LED light strips (controlled by H801 LED controllers) and “Switchable” to start or stop my Roborock S50 robot vacuum.

Pair your devices with Alexa

Now we are ready to pair those items with Alexa. First go back to the PaperUI and go to “Configuration” – “Services” – “IO” – “Hue Emulation” and click “Configure”. To avoid problems later fill the “Optional Discovery Address” field with the name or IP adress of the device that is running OpenHab. The enable the first “Device Pairing” slider to expose your devices for the next minute.

configure the hue emulation to enable voice control
Configure the Hue emulation to enable voice control

Now ask Alexa to find new devices or start a search via the App. This will take about half a minute but then it should find all your devices. The name used should always be name in OpenHab. “Birne Flur Dimmer” in my example above (which means bulb hallway dimmer). That’s it. Now go and feel like a god while you command your devices 😉

Wait, it is not working!

I had two things go wrong with this. In both cases Alexa was suddenly not able to find the devices anymore. The first one was caused by a change made by Amazon: the Echos are now only looking for new devices on Port 80. OpenHab normally runs on port 8080 so we need a small trick here: we can either run a reverse proxy or simply forward that port by using this:

sudo iptables -A PREROUTING -t nat -p tcp --dport 80 -j REDIRECT --to-ports 8080

This command needs to be run after every restart of the controller.

The second time I had problems after updating to a newer version (2.5.4) of OpenHab. This was solved by adding the “Optional Discovery Address” as described above.

If you are looking for even more information try the official documentation.

Categories: BasicsOpenhab