General Ha-Bridge Guide (Hue Bridge for Alexa or Google Home)

A general thread with guides for Ha Bridge not buried as a fix for Emulated Hue.

Firstly - the easy install instructions from @jbardi

Copy paste with updated bits to Ha Bridge current version 3.5.1:

  1. On your Raspberry Pi, make sure you are in the Pi home folder:

cd /home/pi/

  1. Then make an habridge folder:

    mkdir habridge

  2. Now change to the folder and download the latest ha-bridge jar file:

cd habridge

wget https://github.com/bwssytems/ha-bridge/releases/download/v3.5.1/ha-bridge-3.5.1.jar

  1. I can’t remember if ha-bridge automatically creates the data folder or not, but I could have sworn it wasn’t created for me, so you an just create it yourself:

    mkdir data

  2. Now you have to create the systemd service file:

nano habridge.service

  1. 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-3.5.1.jar

    [Install]
    WantedBy=multi-user.target

  2. Now, to save the file, hit CTRL-X, then hit Y and RETURN

  3. This step was added thanks to @xbmcnut as I forgot that Java may not already be installed on your system.

    FIXED. You need Java 8 JDK

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

    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).

    Then run:

    java -version

  4. Next you need to enable the systemd service so it will automatically start every time you reboot your Raspberry Pi:

sudo systemctl enable /home/pi/habridge/habridge.service

  1. 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

  1. 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

10 Likes

Setting up a light with dim.

Settings Example:

Top Half Screenshot

and

Bottom Half Screenshot

I am using HaBridge installed on the same Pi as an AIO HASS install with no HTTPS.

In this example the entity ID of the light I want to control is light.kitchen - you will need to change this to your lights ID in the three fields for BODY.

Fields to fill in

NAME: Kitchen Light
(Whatever you put in for this is what Alexa will discover and call it, unique name for each device. Does not need to be in any way related to the HASS ID.)


TARGET: Encapsulated

DEVICE TYPE: Custom

Because I have it on the same device as Hass I use localhost - you might need to use your Hass IP address instead of localhost.

ON URL:  http://localhost:8123/api/services/light/turn_on

DIM URL: http://localhost:8123/api/services/light/turn_on

OFF URL: http://localhost:8123/api/services/light/turn_off

Adjust for your password, include “quotes”

HTTP HEADERS: [{"name":"X-HA-Access", "value":"YOUR_HASS_PASSWORD_HERE"}]

HTTP VERB: POST

CONTENT TYPE: application/json

Change these three to reflect light entity ID

CONTENT BODY ON: {"entity_id":"light.kitchen"}

CONTENT BODY DIM: {"brightness":"${intensity.byte}", "entity_id":"light.kitchen"}

CONTENT BODY OFF: {"entity_id":"light.kitchen"}
6 Likes

Works flawlessly! Thanks!

What is your suggested way to setup a thermostat?

I don’t have a thermostat, no heater or air-conditioner here.

What is it you want to do? What is it you can do? Set temperature?

I have a device set up to control volume of an AV-Receiver using the dim command. Turn On and Turn Off both run HASS scripts. Volume needs to be sent as a decimal value between 0 and 1.

The DIM URL for this is

http://localhost:8123/api/services/media_player/volume_set

The Content Body Dim is

{"volume_level":".${intensity.percent}", "entity_id":"media_player.hoolio"}

Ha Bridge can’t create decimal no’s using {intensity.math} so this has a . before the $ to convert a percent input to /100.

I suspect controlling temperature would have a similar requirement - the range of temperature you would want set?

So using intensity.percent maybe it’s something like…

http://localhost:8123/api/services/thermostat/temp_set

{"temp_level":"${intensity.percent}", "entity_id":"thermostat.kitchen"}

To work out commands, first go to the dev tab and work out your domain and service. See screen shot - Notice the domain/service is the last bit of the URL. Down below in the service fields you can see the first part of the Content Body Dim has a red dot next to it.

Dev - Services Screen shot

Great write up @BarryHampants and one that is much needed for setting up and using HA-Bridge. There is little information on HA-Bridge so this will be very helpful.
If anyone can add examples to this thread on their setup and usage it would benefit many users.

Just to be clear I’ve simply copied and pasted the instructions from @jbardi.

Truthfully, I’ve been waiting for someone with a bit more knowledge to do it.
I just wanted the information to be a bit easier to find and in its own thread.

I now use

http://192.168.1.196:8123/api/services/climate/set_temperature

in on/dim/off URL and:

{"entity_id":"climate.opentherm_gateway", "temperature":${intensity.percent}}

content body on/dim/off

And this works on both Echo & Google home. Google home answers a bit different so she will say “Themostat set to 22 percent brightness” which is a bit strange but it works (sets setpoint to 22C).

2 Likes

Hi, I followed the instructions, all seems ok. But it does not connect in port 80 …
I get

ERR_CONNECTION_REFUSED

EDIT: Now it works, had to reboot the pi3, now I see HA Bridge

I followed your instructions, but I receive this error

Request Error, Pleae look in your habridge log: error {“type”:6,“address”:"/lights/1",“description”:“Error on calling url to change device state”,“parameter”:"/lights/1state"}

p.s. I checked in Postman a program to check if POST commands are correct, and they are …???

I think that I may have just talked to you about this on another site, but I can move it here since others can help too:

Did you take a look at the log? Are you able to get to HA bridge on port 80?
Are you using SSL on HASS? If you’re using letsencrypt, you’ll need to upgrade to a newer version of Java, since the one on most pi’s is an older version that doesn’t trust letsencrypt.

I managed needed to update latest Java to have letsencrypt.

Now it works with Alexa. But GH is not picking up the device…?

How does GH pick up 2 Hue? I have a hardware hue bridge, and now HA bridge. But the latter is not picked up by GH… Do I have to put anything in configuration, or?

It’s not showing up in the Home app?

Yes correct, it’s not showing in the GH app.
I have all 12 devices of the HUE Bridge, but this one of HA Bridge (only one as test) is not showing up.

Do I need to unlink the HUE from the GH app and pair again? I can do it, its just a pain to reapprove all the devices with their respective rooms.

EDIT: I wonder if someone has 2 hardware HUE Bridge, how it works in Google Home app. When I click the sign PLUS to add new devices, it shows only NEST and SMARTTHINGS, since HUE is already present with hardware HUE Bridge

As a side note, In ALEXA the HA Bridge device is shown as LUX LIGHT, while emulated_hue devices are shown as DIMMABLE LIGHTS

had to unpair and pair again. Now it shows, but there are two of the same device … some weirdness

Other question:

does it work for scripts?

Yes - just use /script/turn_on - you can check the dev tab to find out what domain/service/data you can call.

So for ON URL you would just use

https://redacted.duckdns.org/api/services/script/turn_on

Just be aware that you are running a script, not turning it ON. So for off, you would probably need a different script to run.

Hi all,

Since i updated my home assistant to 0.38.X, i started encountering issue with HA bridge. Now the HA bridge is very unstable. It would work for some time (like 20 min) after i restart the service, but after then all devices couldn’t work. I have no clue what is going on here. Anyone can help?

I have the same issue

With 4.1.4 it looks like the Add/Edit screen has changed from the examples above. Could anyone post an example of what to enter into the new screen? The way I can turn on a light (EZControl XS1) is:

http://localhost:8123/api/services/light/turn_on

Thanks!