Time to cook: 60min
In this recipe we will cover all the steps necessary to integrate Alexa with our Smart HUB. The integration allows you to control lights, thermostats and other connected items with your voice.
In chapter 2 of the connected house cookbook we covered the Alexa voice assistant platform and what it is capable of in relation with our connected home.
A Raspberry Pi with OpenHabian installed
An Echo Dot or compatible Alexa device
The Building Plan
Setting up your Alexa device
When you have bought an Amazon Echo or Echo Dot, you must register your smart speaker in your Amazon account.
Download the Alexa app from the Android or IoS Store on a smartphone or tablet
plugin the Alexa dot and wait for the light ring turns orange, as this is a sign that Alexa is preparing to greet you. When that is done, you’ll hear Alexa’s voice telling you the device is ready for set-up
Next, you’ll need to connect your Echo device to your home Wi-Fi network. The latest versions of the Echo should guide you through this process.
To get started, say the wake word, which by default is “Alexa.” To make sure everything’s working properly, you can conduct a simple test by trying out a few basic commands. For example, say the wake word and “Hello.” If your Echo is properly set up, Alexa should respond with a simple “Hello” in return.
Connect openHAB to the Amazon Alexa Service
Of course we want the Echo to do much more than greet you. We want it to use it as a human interface within our Home Automation scene. In the Alexa app menu, you will see a section called Skills. Skills will give Alexa certain capabilities — think of them as mini-apps from many different creators that you can use for entertainment, organization, news, and much more.
There is a skill available to integrate with the openHAB. This skill will give Alexa the ability to control all the devices hooked up to our openHAB hub and to report the state about them.
The certified Amazon Smart Home Skill allows users to control their openHAB powered smart home with natural voice commands. Lights, locks, thermostats, AV devices, sensors and many other device types can be controlled through a user's Alexa powered device like the Echo or Dot.
When you have added the openHAB skill, you have to link your openHAB account with it, so Alexa can discover all your devices which you want to integrate with Alexa.
The skill connects to your openHAB setup through the myopenHAB.org cloud service to Amazon Alexa. If you have not already done so, execute the setup the myopenHAB cloud service, it’s covered in the recipe ‘Building a Smart HUB’
To add the openHab skill onto your Alexa account:
Open a browser an go to https://alexa.amazon.com
Login with your Alexa account
under Skills, search for ‘openhab’
Install the Skill
link your myopenHAB account
import your devices
Install the Amazon Echo Control Binding on openHAB hub
The following steps will add your Alexa device as a Thing in OpenHAB and allow you to use it for example as a text-to-speech device or to give commands.
This binding can control Amazon Echo devices:
Open Paper UI
Select Add-ons from the left menu
Select Bindings from the top menu
Search or scroll down for the Amazon Echo Control Binding
Adding your Echo devices to the Smart HUB
The Echo Control binding uses the same API as the Web-Browser-Based Alexa site (alexa.amazon.com). In other words, it simulates a user which is using the web page. Unfortunately, the binding can get broken if Amazon changes the web site.
Proceed as follows:
Create an 'Amazon Account' thing in configuration on PaperUI
open the url YOUR_OPENHAB/amazonechocontrol in your browser (e.g. http://openhab:8080/amazonechocontrol/), click the link for your account ‘thing’ and login with your Alexa account.
You should now see a message that the login was successful
You should get something like:
The Amazon Account does not need any configurations. For each of the Amazon Devices discovered, you can add them as a ‘Thing’ on openHAB hub and configure it’s channels.
To Add the Echo Dot in the above example:
Open Paper UI
Select Configuration/Things from the left menu
Click the ‘+’ sign
Select the ‘Amazon Echo Control Binding’
Select ‘Add Manually’
Select Amazon Echo ( to add an echo Dot)
Under Bridge Selection, Select the Amazon Account you have set up previously
In Configuration parameters, enter the serial number of your echo Dot device. The Serial number is shown in the list on the web page http://openhab:8080/amazonechocontrol/ (see image above)
Save your Thing by clicking on the ‘V’ sign.
Testing your Setup
To test the set up, we are going to use the text-to-speech functionality.
When you have added your echo device as a Thing, a number of channels are created under the device in OpenHAB. Click on ’SHOW MORE’ to get the complete list.
Select the ‘Speak’ channel in the list.
Now, go to Controls and search for your Echo device.
Click on the ‘-’ sign and enter a text you want Alexa to say. For example, Hello Alexa!
Click on the ‘v’ sign.
If everything is set up correctly, Alexa should say the sentence you have entered. In Another recipe we will cover how you can use the text-to-speech feature within automation rules to send notifications.