Here are some quick instructions on how to use your Raspberry Pi and the amazon-echo-ha-bridge with HomeSeer3. This method emulates a Philips hue bridge and I found it to be the quickest and most reliable way to control your lights.
Note1: The amazon-echo-ha-bridge appears to be limited to about 25 devices per instance. I simply run 2 instances using different ports to support 50 devices (see notes below).
Note2: You must change the IP address in the examples from 10.0.0.74 to the IP address of your Raspberry Pi 2.
The amazon-echo-ha-bridge take several minutes to start. Once you're have gathered the data for the next steps you should be ready to proceed.
If you are only running 1 instance, then you can simple ask your Alexa to "discover devices". However, if you're running multiple instances, you *must* do the following:
Regards,
Ultrajones
Note1: The amazon-echo-ha-bridge appears to be limited to about 25 devices per instance. I simply run 2 instances using different ports to support 50 devices (see notes below).
Note2: You must change the IP address in the examples from 10.0.0.74 to the IP address of your Raspberry Pi 2.
- Log into your Raspberry Pi, then create a directory to hold the amazon-echo-ha-bridge software.
Code:cd ~pi mkdir echobridge1 mkdir echobridge2
- Change directory into echobridge1, then download the jar file from
https://github.com/armzilla/amazon-e...ridge/releases
Code:cd ~pi/echobridge1 wget [url]https://github.com/armzilla/amazon-echo-ha-bridge/releases/download/v0.2.1/amazon-echo-bridge-0.2.1.jar[/url]
- Copy this jar file to echobridge2 if you have more than 25 devices.
Code:cd ~pi/echobridge1 cp amazon-echo-bridge-0.2.1.jar ../echobridge2
- Figure out what your IP address is by running ifconfig. If you're using wireless, then look under wlan0, otherwise, look under eth0.
Code:ifconfig eth0 Link encap:Ethernet HWaddr b8:27:eb:00:00:00 inet addr:10.0.0.74 Bcast:10.0.0.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:23630 errors:0 dropped:16 overruns:0 frame:0 TX packets:6302 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1912887 (1.8 MiB) TX bytes:1337342 (1.2 MiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:1494 errors:0 dropped:0 overruns:0 frame:0 TX packets:1494 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:165212 (161.3 KiB) TX bytes:165212 (161.3 KiB) wlan0 Link encap:Ethernet HWaddr 74:da:38:00:00:00 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
- For your first instance (supports about 25 devices), launch the program as follows.
Code:cd ~pi/echobridge1 java -jar -Djava.net.preferIPv4Stack=true amazon-echo-bridge-0.2.1.jar --logging.level.com.armzilla.ha.upnp=INFO --logging.file=ha.log --upnp.config.address=10.0.0.74 --server.port=8080 --upnp.response.port=50000 >log.txt &
- If you have more than about 25 devices, then launch a second instance of the program as follows. Please note: You must change the IP address from the example of 10.0.0.74 shown below.
Code:java -jar -Djava.net.preferIPv4Stack=true amazon-echo-bridge-0.2.1.jar --logging.level.com.armzilla.ha.upnp=INFO --logging.file=ha.log --upnp.config.address=10.0.0.74 --server.port=8081 --upnp.response.port=50001 >log.txt &
The amazon-echo-ha-bridge take several minutes to start. Once you're have gathered the data for the next steps you should be ready to proceed.
- Create an import.sh script for the echobridge1 directory and put the contents of the following file into the script. You *must* change the BRIDGE_IP and HS3_IP. Please also note that my HomeSeer lights use a 0 for off and a 100 for on. Your lights may be different.
import.sh script for the ~pi/echobridge directory.
Code:#!/bin/bash BRIDGE_IP="10.0.0.74" HS3_IP="10.0.0.12" OFF_VALUE="0" ON_VALUE="100" IFS="," while read DEVICE_NAME REF_ID do echo "Adding ${DEVICE_NAME} with HS3 device ref ${REF_ID}" curl -H "Content-Type: application/json" \ -X POST http://${BRIDGE_IP}:8080/api/devices \ -d "{ \"name\" : \"${DEVICE_NAME}\", \"deviceType\" : \"switch\", \"onUrl\" : \"http://${HS3_IP}/JSON?request=controldevicebyvalue&ref=${REF_ID}&value=${ON_VALUE}\", \"offUrl\" : \"http://${HS3_IP}/JSON?request=controldevicebyvalue&ref=${REF_ID}&value=${OFF_VALUE}\" }" echo "" done < lights.csv
Code:#!/bin/bash BRIDGE_IP="10.0.0.74" HS3_IP="10.0.0.12" OFF_VALUE="0" ON_VALUE="100" IFS="," while read DEVICE_NAME REF_ID do echo "Adding ${DEVICE_NAME} with HS3 device ref ${REF_ID}" curl -H "Content-Type: application/json" \ -X POST http://${BRIDGE_IP}:8081/api/devices \ -d "{ \"name\" : \"${DEVICE_NAME}\", \"deviceType\" : \"switch\", \"onUrl\" : \"http://${HS3_IP}/JSON?request=controldevicebyvalue&ref=${REF_ID}&value=${ON_VALUE}\", \"offUrl\" : \"http://${HS3_IP}/JSON?request=controldevicebyvalue&ref=${REF_ID}&value=${OFF_VALUE}\" }" echo "" done < lights.csv
- Now populate the lights.csv for each amazon-echo-ha-bridge you plan to run. In the example below, the file contains the light name, then the HomeSeer Reference Id.
Code:Basement Stairs Light,213 Basement Table Lamp,167 Basement Lights N1,189 Basement Lights N2,190 Basement Lights S1,191 Basement Lights S2,192 Basement Dehumidifier,172 Dining Room Chandelier Lights,197 Dining Room China Cabinet Lights,179 Dining Room Table Lamps,178 Family Room Overhead Light,173 Garage Lights,224 Kitchen Cabinet Lights,175 Kitchen Desk Lights,184 Kitchen Island Lights,195 Kitchen Sink Light,182 Kitchen Table Lights,186 Deck Lights,236 Back Door Lights,223 Front Door Lights,220 Landscape Lights,216 Flood Lights,222
- To import the lights, you simply do the following:
Code:cd ~pi/echobridge1 ./import.sh cd ~pi/echobridge2 ./import.sh
If you are only running 1 instance, then you can simple ask your Alexa to "discover devices". However, if you're running multiple instances, you *must* do the following:
- Stop all instances of the amazon-echo-ha-bridge as follows:
Code:pkill -f java
Code:cd ~pi/echobridge1 java -jar -Djava.net.preferIPv4Stack=true amazon-echo-bridge-0.2.1.jar --logging.level.com.armzilla.ha.upnp=INFO --logging.file=ha.log --upnp.config.address=10.0.0.74 --server.port=8080 --upnp.response.port=50000 >log.txt &
- Wait until you get a response from http://10.0.0.74:8080/api/devices before proceeding.
- Ask your Alexa to "discover devices"
- Log into http://alexa.amazon.com/spa/index.ht...connected-home to make sure your devices were discovered.
- Stop all instances of the amazon-echo-ha-bridge as follows:
Code:pkill -f java
Code:cd ~pi/echobridge2 java -jar -Djava.net.preferIPv4Stack=true amazon-echo-bridge-0.2.1.jar --logging.level.com.armzilla.ha.upnp=INFO --logging.file=ha.log --upnp.config.address=10.0.0.74 --server.port=8081 --upnp.response.port=50001 >log.txt &
- Wait until you get a response from http://10.0.0.74:8081/api/devices before proceeding.
- Ask your Alexa to "discover devices"
- Log into http://alexa.amazon.com/spa/index.ht...connected-home to make sure your devices were discovered.
- Restart the first instance:
Code:cd ~pi/echobridge1 java -jar -Djava.net.preferIPv4Stack=true amazon-echo-bridge-0.2.1.jar --logging.level.com.armzilla.ha.upnp=INFO --logging.file=ha.log --upnp.config.address=10.0.0.74 --server.port=8080 --upnp.response.port=50000 >log.txt &
- Wait about 5 minutes before you ask your Amazon Alexa to control your lights.
Regards,
Ultrajones
Comment