Connecting my echo dot to a raspberry pi 3
2020-11-05Recently I wanted to connect my echo dot 3rd gen to a node-red server inside a raspberry pi 3.
The best solution looks like setting up a nodered server and then configuring it to listen to my echo inside my local network.
There were some issues I've ran into and hopefully this guide is usefull for you.
First, set up the server by following the official guide.
After installing node-red, install the node-red-contrib-amazon-echo pallete.
To do this connect to your node-red instance at http://localhost:1880 an click on the menu icon on the right upper part.
Then choose "Manage pallete", click on the "install" tab and search for node-red-contrib-amazon-echo
Click on install
Inside input you will see two new nodes "amazon echo hub" and "amazon echo device"
The basic setup is one "amazon echo hub" that connects to a "amazon echo device" and the on any other node, for now let's use a common/debug node
For "amazon echo hub" double click to edit properties. Change the port to 8080.
For "amazon echo device" double click to edit properties and give it a name. This will be the name you will call with alexa.
Connect "amazon echo device" to the debug node.
Click on the "deploy" button on the upper part
Unfortunately echo 3rd generation expects your device to be listening to port 80, but unless you are running nodered as sudo you will not have the rights to expose port 80.
The solution is to redirect from port 80 to 8080 using iptables.
And since we want the iptables rules to be persisted, we need to install iptables-persistent
First run:
sudo apt-get install iptables-persistent
Then copy these rules:
*nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080 COMMIT *filter -I INPUT 1 -p tcp --dport 80 -j ACCEPT COMMIT
Write them on this file:
sudo nano /etc/iptables.test.rules
Now execute and save the rules:
sudo iptables-restore < /etc/iptables.test.rules sudo sh -c 'iptables-save > /etc/iptables.up.rules'
And lastly, copy this
#!/bin/sh /sbin/iptables-restore < /etc/iptables.up.rules
And paste it into this file to reload the rules when restarting your raspberry pi
sudo nano /etc/network/if-pre-up.d/iptables
And make the file executable:
sudo chmod +x /etc/network/if-pre-up.d/iptables
Now just ask alexa to look for devices and a new device with the name from the node "amazon echo device" should show up
Commands like "Alexa, turn on deviceName" will show up on your debug node
Links:
http://www.intellamech.com/RaspberryPi-projects/rpi_iptables.html