Skip to main content

Installing ha-bridge on your Raspberry Pi

EDIT: Updated 14th June 2017 to reflect version 4.5.5. Default port is now 80 to keep Google Home happy and service now supports MQTT! Advice on backups also added 7th Feb. Version 4x also supports adding a Home Assistant instance which is great!

Want to control your Vera, Harmony hub or Home Assistant entities with your Amazon echo or Google Home? ha-bridge is the best way to achieve that and installation is actually quite easy and takes less than 5 minutes. Here are the steps.


  1. On your Raspberry Pi, make sure you are in the Pi home folder:
    cd /home/pi/
  2. Then make a habridge folder:
    mkdir habridge
  3. Now change to the folder and download the latest ha-bridge jar file:
    cd habridge
    wget
    https://github.com/bwssytems/ha-bridge/releases/download/v4.5.5/ha-bridge-4.5.5.jar
  4. Create a ‘data’ holder inside the habridge folder:
    mkdir data
  5. Now you have to create the systemd service file:
    nano habridge.service
  6. Then copy and paste the following:

    [Unit]
    Description=HA Bridge
    Wants=network.target
    After=network.target

    [Service]
    Type=simple
    ExecStart=/usr/bin/java -jar -Dconfig.file=/home/pi/habridge/data/habridge.config /home/pi/habridge/ha-bridge-4.5.5.jar

    [Install]
    WantedBy=multi-user.target


  7. Now, to save the file, hit CTRL-X, then hit Y and RETURN
  8. You need Java 8 JDK to be able to run ha-bridge
    sudo apt-get update && sudo apt-get install oracle-java8-jdk
  9. Then run:
    sudo update-alternatives --config java and select the JDK 8 version (/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/bin/java) if asked.
  10. Then run the following to confirm you have the right Java version:
    java -version
  11. Next you need to enable the systemd service so it will automatically start every time you reboot your Raspberry Pi (ignore the Shell script instructions on the ha-bridge ReadMe as newer Debian builds [Jessie] work best with systemd):
    sudo systemctl enable /home/pi/habridge/habridge.service
  12. Now that it is enabled, you have to start it. Since it is enabled, you don’t need the full path to run it:
    sudo systemctl start habridge
  13. The default port for HA Bridge is 80, so open your browser and go to your RPI address, port 80:
    http://[your-ip-address]:80
N.B If the ha-bridge version is updated, simply edit the WGET line in step 3 to download the correct version and edit the code used in step 6 (habridge.service) to reflect the correct version. If you want, you can have multiple versions downloaded in the habridge folder and simply switch between them by modifying the code in the habridge.service file (the ExecStart line).

  1. Stop ha-bridge either via the GUI or using sudo systemctl stop habridge.service
  2. Change into the ha-bridge directory cd /home/pi/habridge
  3. Edit the service file nano habridge.service
  4. Save the change then run sudo systemctl daemon-reload
  5. Start the service using sudo systemctl start habridge.service
  6. Check the status after a few seconds with sudo systemctl status habridge.service
If you want to control your Home Assistant entities with ha-bridge, there is a great guide here http://fearoffish.com/home-automation/home-assistant-and-ha-bridge/ and here on Pete Scargill's blog http://tech.scargill.net/toying-with-ha-bridge/. There is also one on controlling the MiLight bridge here http://codecorner.galanter.net/2016/05/12/full-control-of-your-limitless-ledmilight-bulbs-from-amazon-echo/.

Backups
Immediately after configuring the bridge and all of you devices, I would run a backup at the bottom of the "Bridge Devices" tab and the "Bridge Control" tab. If you do not choose a name, ha-bridge will automatically create one for you.

Bridge Devices is all of the individual actions you've created and if the defaults are left, the backup file will be located in /data and look something like device.db-2017-02-07-20-28-06.bk.

Bridge Control contains the actual bridge configuration like your Harmony Hubs IP, Vera, MQTT etc. The backup is located in /home/pi/habridge/data and looks something likes habridge.config-2017-02-07-20-28-19.cfgbk.

I strongly encourage you to remote in to your Pi using WinSCP and save these backup files locally just in case your Pi's SD card goes duff as mine has on three occasions now. Popping these backups into the appropriate folders after a rebuild certainly makes getting ha-bridge live again much simpler.

Comments

  1. Hi
    Found you via Pete Scargill's site. followed your instructions which worked perfectly. But i ran it at port 80 where the Apache page was then ran "sudo java -jar -Dserver.port=82 ha-bridge-3.2.2.jar" to put it on port 82 which works, but it is also on port 80. How do i get port 80 back to where it was ?
    Thanks Chris.

    ReplyDelete
    Replies
    1. You can configure the port in the ha-bridge GUI. Did you do that?

      Delete
  2. Thanks to your guide I am able to see the Bridge. I have a Mi-light Dimmable Led Bulb E26 with remote, plus an echo dot. What now? Do I need to purchase a controller?

    Thank you!!

    ReplyDelete
  3. I have done every thing you have said but at the end when I try access the bridge from browser it says this site cannot be reached.
    I enter http://192.168.1.110:80 in browser and it says cannot be reached. I've also tried 88. I have no idea why nothing is happening. Do you have any ideas?

    ReplyDelete
    Replies
    1. What happens when you type 'sudo systemctl status habridge' (without the quotes). Is the service running? N.B You do not need to append the port if it is 80. Just use the IP.

      Delete
  4. Hi you need to edit a line in the Service file as it still points to /ha-bridge-3.2.2.jar instead of /ha-bridge-3.5.1.jar

    Caused me a slight problem but excellent write up.

    Gareth

    ReplyDelete
  5. Thank you!

    This was the missing step for me to finish off setting up a link between openhab and echo.

    beauoooootiful

    ReplyDelete
  6. Can someone help me !!! Ive followed the script as above and i can not for the life of me work out why it wont work please someone help

    ReplyDelete
    Replies
    1. Hey there. I've not used HAB for over 2 years now (due to the lack of Google support) so you might want to reference the HAB Github page for installation instructions instead? https://github.com/bwssytems/ha-bridge#manual-installation-of-ha-bridge-and-setup-of-systemd-service

      Delete
  7. Does anyone know if HA bridge will still work after Philips withdraw online service support for Hue bridge v1? Thanks

    ReplyDelete

Post a Comment

Popular posts from this blog

Using ESPEasy with Home Assistant via MQTT

Preface: I've just started playing around with Home Assistant on a Raspberry Pi and exploring the world of MQTT to control devices on the network. Learning curve is a bit steep but worth the effort as MQTT is very fast. The hardware and software tools I'm using are as follows: 2 x Sonoff relay units 2 x NodeMCU Boards ESPEasy firmware (must be version 121 or above as that contains the MQTT 'retain' flag option. Home Assistant software on Raspberry Pi2 MQTT Test Software: PC: MQTT.fx Android: MQTT Dashboard

My Notepad++ tricks when editing YAML files in Home Assistant

To comment out a whole section in one go: Highlight the text you want to comment out and use CTRL + Q. If you do this at the start of a line, it will only comment that line. CTRL + Q is toggle mode (comment on/off). CTRL + K will allow you to add multiple comments one after the other.

How to check what entities are filling up your Home Assistant database

If you use the Home Assistant MariaDB add-on, this tip will show you how to query the database so see what Home Assistant entity states are triggering the most, filling up your database. What were going to do: Install the phMyAdmin add-on for MariaDB. Query the MariaDB database. See what entity state changes have the most action. Paste the code below into the SQL query box:  select entity_id,count( * ) from states group by entity_id order by count ( * ) desc; And if you're using the internal home-assistant_v2.db instead, you can use the SQLite Web add-on to achieve the same thing.