Domoticz Alexa integration

You can setup Amazon echo to voice trigger any scene/switch/activity in domoticz using HA-bridge (e.g. “Alexa, turn on living room lights” ). I have been using this setup with an amazon echo outside the target market for the echo (In India) and it works beautifully well. The HA-bridge emulates Philips hue devices that is supported natively by the echo

Pre-requisites

  • An Amazon Echo device
  • A spare RPi/processing capacity on your domoticz box/ any other linux box
  • HA-bridge running on the above mentioned box

I use a spare Gen 2 Rpi B that I had lying unused The rest of the guide assumes that the HA-bridge is running on a separate box

 

Installing HA-bridge

On a vanilla Raspbian system, installing HA_bridge is relatively trivial

install java and all updates

Newer Raspbian images should have java pre-installed, if not:

 sudo apt-get update && sudo apt-get install oracle-java8-jdk

Install HA-bridge

This guide assume an installation of v4.5.0 at /home/pi/habridge

Make sure you get the latest release

cd /home/pi/
mkdir habridge
cd habridge
wget https://github.com/bwssytems/ha-bridge/releases/download/v<version#>/ha-bridge-<version#>.jar
java -jar ha-bridge-<version#>.jar

Note: 1) <version#>” ie. “v4.5.0”

Note: 2) <version#> i.e “4.5.0”

Edit the shell script for starting:

sudo 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-<version#>.jar > /home/pi/habridge/habridge-log.txt 2>&1 &
chmod 777 /home/pi/habridge/habridge-log.txt

Make script executable

sudo chmod u+x starthabridge.sh

Then execute the script:

sudo ./starthabridge.sh

You should now be running the bridge. Check for errors:

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

sudo java -jar -Dserver.port=80 ha-bridge-<version#>.jar

Add to startup

Copy the script to your rc.local (or systemctl as your case may be)

sudo nano /etc/rc.local

add the lines between “fi” and “exit”

sudo /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

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)

Finishing

  • I couldn’t get the echo to recognize the new hue devices at the first attempt and required a restart of the echo device (not sure why)
  • I had to run my HA bridge (v3.2.1) on port 80 as root before Alexa would pick up any devices
  • Once the first device is added succesfully, you should be able to create as many new bridge devices as you want

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s