Voice control of the house
In this article, we will connect the Amazon Echo Dot voice assistant with open source home automation. We won't be using OpenHAB Cloud, so everything runs locally. In this case, a few additional settings are necessary, but the result is worth it!
Hardware
Pi-Home - if you don't have it, see the section How to do it
Alexa Echo Dot
Software
OpenHAB 3
Procedure:
1) Connect to Raspberry via SSH and install nginx to redirect traffic from port 8080 to port 80 (default port for HTTP traffic)
sudo apt-get update && sudo apt-get install nginx
2) Then edit the configuration file by command below and insert the following code into the file:
sudo nano /etc/nginx/sites-enabled/default
server{
listen 80;
listen [::]:80;
location / {
proxy_pass http://127.0.0.1:8080/;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /api {
proxy_pass http://localhost:8080/api/;
}
}
Save by pressing Ctrl+o and close the nano editor (Ctrl+x).
Check if the configuration is correct with the command:
sudo nginx -t
If it says OK, restart nginx
sudo service nginx restart
3) Now enter your OpenHAB IP address in the browser. You should reach OpenHAB on default port 80. To connect with Alexa, we will use the "Hue emulation" binding. Install it in the Bindings section:
After installation, click Settings -> then at the bottom right, expand Other services and click on Hue Emulation.
Check Show advanced. Fill in at least 120 seconds for the pairing time. If you have an older Alexa, also check the option
Switch TestSwitch "Kitchen Switch" [ "Switchable" ] {channel="..."}
Color TestColorBulb "Bathroom" [ "ColorLighting" ] {channel="..."}
Dimmer TestDimmer "Hallway" [ "Lighting" ] {channel="..."}
Final note:
Alexa currently only works in a few world languages, so you can use English or German. Therefore, in some cases, a change in the names of lights may be required. For example, turn on a light by saying: "Alexa, turn on living light" (Turns on a light named living light).
Tip:
The goal is, of course, to have as many functions as possible. In OpenHAB, create new dump Switch items, such as "Alarm" and add tag "Switchable". Then add a rule, for example, to arm the house after 60 seconds. When leaving, simply say to Alexa: "Alexa, turn on Alarm".
Note: Of course, it doesn't make sense to turn off the alarm by voice for security reasons ;) For that, we use an application or NFC tag. They are secure.
Add comment