Install Java Development Kit
sudo apt-get install default-jre
sudo apt-get install default-jdk
sudo apt-get install software-properties-common
sudo add-apt-repository "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main"
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt install oracle-java8-set-default
Install HA-bridge
This guide assume installation of v2.07 at /home/pi/habridge - feel free to change location as you see fit
Make sure you get the latest release
cd /home/pi/ mkdir habridge cd habridge wget https://github.com/bwssytems/ha-bridge/releases/download/<your version1>/ha-bridge-<your version2>.jar use this command latest link at date 6 august 2017: wget https://github.com/bwssytems/ha-bridge/releases/download/v4.5.6/ha-bridge-4.5.6.jar
Note: 1) "your version" ie. "v3.5.1" with the "v" in front 2) without the "v"
Edit the shell script for starting:
pi@raspberrypi:~/habridge $ nano starthabridge.sh
Then cut and past this, modify any locations that are not correct
cd /home/pi/habridge rm /home/pi/habridge/habridge-log.txt nohup sudo java -jar /home/pi/habridge/ha-bridge-<your version>.jar > /home/pi/habridge/habridge-log.txt 2>&1 & chmod 777 /home/pi/habridge/habridge-log.txt
Make script executable
pi@raspberrypi:~/habridge $ chmod u+x starthabridge.sh
Then execute the script:
pi@raspberrypi:~/habridge $ ./starthabridge.sh
You should now be running the bridge. Check for errors:
pi@raspberrypi:~/habridge $ tail -f habridge-log.txt
By default, the bridge runs on port 8080 - if you running this on the same machine as domoticz, do not forget to change the port on either domoticz or HA-bridge
To change the port on HA-bridge, use the following argument
java -jar -Dserver.port=80 ha-bridge-<your version>.jar
Add to startup
Copy the script to your rc.local (or systemctl as your case may be)
nano /etc/rc.local
add the lines between "fi" and "end"
/home/pi/habridge/starthabridge.sh
And you are all set
Configuring HA bridge
Navigate to the HA bridge configuration page on IP_of_server_running_bridge:8080 The first screen (bridge devices) shows the devices that Alexa would add to her list of available devices (nothing will be shown here if you didn't add devices yet).
Automatic configuration (HA bridge version 4.1.0 and higher)
From version 4.1.0 of the HA-bridge there is a built in feature for Domoticz. Do the following to set the HA bridge up for Domoticz:
- Go to the Bridge Control page
- Scroll down to "Domoticz Names and IP Addresses"
- Fill in a name of your choice for your Domoticz device (e.g. "Domoticz"), enter your IP address and Domoticz port number (also username and password if you use that).
- Click "Add" on the right hand side of what you just filled in.
- A very important last step: scroll to the top of the page and click "Save"!
After you have done the above, a new tab called "Domoticz Devices" is created. In this tab you will see all your Domoticz devices. This is where you can add your devices to the HA bridge, after which they will appear on the Bridge Devices page and can be controlled via Alexa.
Manual device list pull (for older versions)
For older ha-bridge versions (before 4.1.0) you may use this script, which will automatically pull your device list from the Domoticz API and write them into the device configuration file for ha-bridge:https://github.com/dswinton/domoticz-habridge-sync
Adding devices to HA bridge
You can either use the Domoticz Devices page or a manually add devices to the HA bridge.
Via Domoticz Devices page
On the Domoticz Devices page you will see all your Domoticz devices.
- Search the device you want to add and tick the box in the Name column.
- If the device you are adding is a dimmer, select the dim control type via the drop down list at the top of the page. If it is not a dimmer, leave this on "none".
- Click on the "Build item" button in the row of your ticked device.
- The name you fill in here is how you will ask Alexa for this device.
- The rest of the fields are already filled in for you so you don't need to do anything with it, but you can adjust things here if you like (e.g. the JSON URL).
- Click at the top of the page on "Add bridge device".
- At the Bridge devices page, you will now see your added device. You can click on the test buttons to see whether it does what you want.
- Say to your Echo "Alexa, discover devices" or alternatively you can open the Alexa app on your phone and go to Menu > Smart Home > and click on "Discover devices".
- The device(s) is/are now added in Alexa and are ready to use via voice command.
Manually add devices
- Name - Porch Lights (The name you would like to use for Alexa to identify the scene/switches )
- Device Type - Custom
- Map Type - Blanks
- On URL: http://192.168.0.100:8080/json.htm?type=command¶m=switchlight&idx=25&switchcmd=On
- Dim URL : http://192.168.0.100:8080/json.htm?type=command¶m=switchlight&idx=25&switchcmd=Set%20Level&level=${intensity.percent}
- Off URL: http://192.168.0.100:8080/json.htm?type=command¶m=switchlight&idx=25&switchcmd=Off
Change the IP and idx as per your setup
Testing
- Ask Alexa to Discover devices ("Alex, discover devices" or through the alexa app
- Alexa should find a new device called porch lights
- test by asking alexa to "turn porch lights on" (or off , or dim)