[quote=“hmspain, post:324, topic:187039”][size=18pt]Running the amazon-echo-bridge on a Raspberry Pi[/size]
First of all, why a Raspberry Pi (RPi)? The answer is simple, they are cheap, reliable, and run on a handful of watts so you can keep your RPi running all day, no worries.
How does it work? The Amazon Echo already supports the Hue Bridge. The Hue Bridge is that white hockey puck device with some LEDs and a big button in the middle that talks ZigBee to Hue LED bulbs/strips. Don?t worry, you don?t need a Hue bridge or Hue bulbs/strips to get this to work.
The trick is to make your Raspberry Pi perform like a Hue Bridge. It really is a Hue Bridge Emulator when all is said and done. Instead of turning on and off Hue bulbs, you will be turning on and off devices/scenes ON YOUR VERA! You can control scenes just like your devices, although saying “Alexa, turn on ” can use a little creativity when you name things in configurator. I’ll go over configurator once you have your Hue Bridge Emulator up and running.
Hardware needed:
- Raspberry Pi board
- Raspberry Pi power supply
- MicroSD card
- Raspberry Pi case (optional)
- Ethernet cable
- Open Ethernet port; on your router, or hub connected to your router
- USB Keyboard (temporary)
- USB Mouse (temporary)
- HDMI cable (temporary)
Software needed:
- Amazon-echo-bridge-x-x-x.jar (I used 0.1.3)
- Java V8 for Debian or the OS you are using
OK, let’s get started. Where can I buy this hardware?
If you just want the board (item 1):
Here is a nice kit ($70) from Amazon (items 1,2,3,4,9):
or
http://www.amazon.com/Adapter--20-Guide--Clear-Case--Power-Supply--Kingston-Adapter--HDMI/dp/B00MV6TAJI/ref=sr_1_5?s=pc&ie=UTF8&qid=1436319177&sr=1-5&keywords=raspberry+pi
NOTE: I would hard wire the RPi (Ethernet) to your router, and not try to get the WiFi adapter up and running. There are reports of delays when trying to use WiFi, and no need to risk it. Just put your RPi next to your router.
I built my Raspberry with Debian, but the preloaded NOOBS OS may work just fine as long as Java V8 loads on it.
If all fails with the NOOBS operating system, you can always re-flash the MicroSD with Debian. You can use UNetbootin Universal Netboot Installer and flash Debian to the MicroSD.
I had a spare USB keyboard and mouse, and you can always borrow these from your PC or Mac. Once you get your RPi up and running, you can use putty to SSH into the operating system eliminating the need for a mouse or keyboard.
Log into your RPi (you will more than likely want to connect it to your TV and use your mouse and keyboard). Set the root password to something simple.
[size=14pt]Installing Java V8[/size]
Make sure to login using “root”. It just keeps things easy, and ISIS is not looking to hack into your RPi.
Once logged in, assuming you are ?up on the net? (i.e. your RPi has pulled an IP address DHCP from your router), you can issue the following commands:
su -
echo “deb Index of /webupd8team/java/ubuntu trusty main” | tee /etc/apt/sources.list.d/webupd8team-java.list
echo “deb-src Index of /webupd8team/java/ubuntu trusty main” | tee -a /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
apt-get update
apt-get install oracle-java8-installer
exit
NOTE: This works for Debian. If you are not running Debian, research the command(s) for your specific version of Linux running on your RPi. I was told there are easier ways, but these commands worked for me. The ?su ?? is most likely not needed since you are logged in as root. The next two echo commands can be omitted. I suspect only the two apt-get commands are needed.
If you don?t know what OS you are running, you can type:
uname -a
If Java successfully installs, you can type:
java -version
A response from Java says you are good to go!
[size=14pt]Loading the jar file on your RPi[/size]
There are several ways to get the jar file on your RPi. I decided to copy the jar file from github (Releases · armzilla/amazon-echo-ha-bridge · GitHub) to a flash drive on my PC, and then plug in the flash drive on my RPi and copy the file. Simple right? No so fast. Format the USB FAT32 with a label of ECHO (keeping it simple). Copy the jar file from github to the flash drive. Move the flash drive to your RPi.
df ?h
will show you the device location (in my case /media/ECHO).
mkdir /usr/local/echobridge
cp /media/ECHO/amazon-echo-bridge-0.1.3.jar /usr/local/echobridge
At this point, you can simply run the jar file using Java, but we want to make sure things are done ?right?, so:
vi /usr/local/echobridge/echobridge.sh
Put the following ONE LINE in the file (use ?I? to insert, and esc :wq! To save and exit);
java -jar -Djava.net.preferIPv4Stack=true /usr/local/echobridge/amazon-echo-bridge-0.1.3.jar --upnp.config.address=192.168.1.125 > /usr/local/echobridge/echobridge.log
Notice that 192.168.1.125? That’s the IP address of the RPi. If you don?t know what the RPi IP address is, use the command:
netstat
Look for “Local Address” at the top.
Next, create an echobridge_daemon.sh file (vi /usr/local/echobridge/echobridge_daemon.sh), and add the following line:
/usr/local/echobridge/echobridge.sh &
NOTE: That “&” is used to run the java process in the background.
[size=14pt]To make sure the java process restarts when your RPi reboots[/size]
crontab -e
(at the top of the file add the line)
@reboot java -jar -Djava.net.preferIPv4Stack=true /usr/local/echobridge/amazon-echo-bridge-0.1.3.jar --upnp.config.address=192.168.1.125 > /usr/local/echobridge/echobridge.log
NOTE: Make sure to change the IP address to your specific RPi IP address.
[size=12pt]Starting the Amazon Echo Bridge process for the first time[/size]
/usr/local/echobridge/echobridge_daemon.sh
ps -ef | grep echo
tail -f /usr/local/echobridge/echobridge.log
The “ps” and “tail” commands let you watch the magic (if you want). It helps to know how long the bridge takes to come up so you don?t start thinking something is wrong.
[size=14pt]Configuring the Amazon Echo Bridge[/size]
From your browser (I used Chrome) use this URL (note the IP address of your RPi, yours will most likely be different);
http://192.168.1.125:8080/configurator.html
This should display the configurator allowing you to add devices/scenes.
Change the “Bridge server” to the IP address of your RPi. In my case;
http://192.168.1.125:8080/api/devices
Pick a name for your device/scene (don?t worry, you can delete and re-add them if you find the name does not work, or is reserved somehow).
Put the IP address of your VERA SERVER in the “Vera Server” field URL. This worked for me “http://192.168.1.91:3480”. If you know the device number, enter that in the ?Device ID? field, and press “Generate URLs”. This is the syntax for turning ON and turning OFF your device. Click “Add Device”.
IMPORTANT: When you add or remove devices/scenes using configurator, make sure to tell Alexa to ?Discover Devices? ? it?s the fun part ;-).
If you want to add a scene, use the following syntax manually (the example uses scene 356); don?t use the “Generate URLs” button;
http://192.168.1.91:3480/data_request?id=action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=356
Add devices/scenes, test the ON and OFF buttons, delete things that don?t work, until you get everything ?right?; enjoy.
NOTE: Sometimes the configurator will not display your devices. Be patient. It make take a few tries to get it to display. Sometimes I add a bogus device “xxxyyy” and when the devices display, I simply remove “xxxyyy” and go about my work. Sometimes that does not work, but a few refreshes later, the devices suddenly appear. I?m not sure the trick, but don?t give up, it will display.
Enjoy talking to your Amazon Echo, turning on/off various devices, and running any scene. This is what home automation looks like circa 2015.
Harrison Spain
hmspain@gmail.com[/quote]
Did all that - except everything is in /home/pi/echobridge/ folder, as I started out with the instructions from here: http://www.airedalez.net/?p=263&cpage=1#comment-824
When I try Starting the Amazon Echo Bridge process for the first time
/homw/pi/echobridge/echobridge_daemon.sh
ps -ef | grep echo
tail -f /usr/local/echobridge/echobridge.log
I get a Permission denied response …