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

I think you might need to start fresh if you upgrade to version 4 or above - I don’t think your old set ups will work any more, when I was testing it I seem to remember a light being activated would cause all the lights to be activated.

Unfortunately I can’t test this as all my old stuff is gone, I may have a backup of the old config somewhere but it will be a week before I can look for it. You could always backup and see if it stops hanging with a clean start.

I actually noticed that the old setting wouldn’t work- I would try all lights on/off with a single bottom.
The thing is, I updated all configurations, and all lights/ switches worked as expected- but just for a while. After a certain period of time (like 15 min), it wouldn’t work at all.

Also I noticed that, seems the harmony devices will still work- so just the manually added devices go down.

I was thinking if uninstall everything the do the installation would work. Yet I don’t know how I can do that (uninstall HA bridge). Can someone teach me how to do this so that I can test if this. A a solution to this issue?

You don’t really need to uninstall. Since you have working Harmony devices I would just go to the DEVICES tab and delete all the HASS devices, and keep the Harmony stuff. Then restart or reinitialise from the bridge control tab and see how you go. If that doesn’t work just rename the config file in the habridge/data directory to something like habridge.config.backup or delete it and restart and it should be the same as a clean start.

I’ll try and take some screenshots tonight and install a light or two.

Many thanks Barry. I cheated a little and downgraded to the version you used (3.5.1) and that works perfectly. I am new to Home Assistant so still struggling a bit to configure everything. I have added an entry in configuration.yaml:

switch:
platform: command_line
switches:
living_room:
command_on: “/usr/bin/curl -X GET ‘http://192.168.1.3/preset?switch=1&value=on’”
command_off: “/usr/bin/curl -X GET ‘http://192.168.1.3/preset?switch=1&value=off’”
friendly_name: Living Room

and changed the On and Off URL to:

http://localhost:8123/api/services/switch/turn_on (or off)

and the content body on/off to:

{“entity_id”:“switch.living_room”}

That’s working now. Perhaps there is an easier way, but that’s the next challenge. My Echo Dot should arrive this afternoon, fingers crossed!

Thanks! @BarryHampants

  1. I tried deleted all HASS devices and also the habridge.config. Yet the results seem to be the same- it worked ok for a while then stoped working. Also, i noticed that, in the short period that HA does work, usually it will only work in the second click (call the service 2nd time). In the first time, it showed an error message.

Error on calling url to change device state: https://XXXXXX.duckdns.org/api/services/switch/turn_on?api_password=XXXXXXX

But when i click again, it magically works (if it would work).

2.In this version (i upgraded from 3.5.1), i found there is a HASS server there and seems the HA bridge can automatically add the HASS devices (previously i added them all manually). Yet i tried it doesn’t seem to work.

17 22:54:23.039	WARN	Error calling out to HA gateway: IOException in log	com.bwssystems.HABridge.plugins.http.HTTPHandler
02-22-2017 22:54:23.041	WARN	Cannot get an devices for HomeAssistant HA http call failed.	com.bwssystems.HABridge.plugins.hass.HomeAssistant
02-22-2017 22:54:23.042	WARN	Cannot get devices for HomeAssistant with name: HA, skipping this Hass.	com.bwssystems.HABridge.plugins.hass.HassHome

Not sure if it is because i am running letsencrypt. Can you teach me how i can get this right? (of course, not sure if this will fix my current issue…but just want to try some other way to do it).

Sorry @yungling - I was going off memory, forgot there is also devices.db in that same directory.

Anyway - for letsencrypt, the answer was posted here Why can't emulated Hue work with OnHub or Google Home?

I actually noticed that the old setting wouldn’t work- I would try all lights on/off with a single bottom.
The thing is, I updated all configurations, and all lights/ switches worked as expected- but just for a while. After a certain period of time (like 15 min), it wouldn’t work at all.

Also I noticed that, seems the harmony devices will still work- so just the manually added devices go down.

I was thinking if uninstall everything the do the installation would work. Yet I don’t know how I can do that (uninstall HA bridge). Can someone teach me how to do this so that I can test if this. A a solution to this issue?

this is the exact same experience I have had. I even tried a complete rebuild Ubuntu 16.04 svr and 4.1.4 ha bridge.
Might try using 3.5.1 to see whether that behaves.
Gone back to emulated hue at the moment.

Hi @BarryHampants,

I only see habridge.config in the data directory…(but i do see the “device.db” listed in the bridge control).

Also, i have seen that post about lesencrypt and actually followed it in my manually added devices (in 3.5.1). It worked perfectly. But seems doesnt work when i add the Home assistant via bridge control.

@Aussybob,

i actually upgraded from 3.5.1 because i encountered issues. Just upgrading doesn’t seem to be the solution. So i think it might be something about the Home Assistant 0.38.X. (not sure if it is just me).

If I cannot get the HA bridge fixed, i probably have to go using emulated hue. I hesitate to do so coz i have both GH and Alexa…

Dumb question… If I change emulated hue to port 80 will both GH and Echo work?

Sorry @yungling, I did a fresh install of Home Assistant last week on a new machine and am having a few problems so can’t really check it out at the moment - I’ve been forced to unplug it and go back to my backup pi. On that machine I went through several stages of beta so it’s possible the devices.db is a remnant from that. I seem to remember people having trouble due to permissions creating the habridge.config and the devices.db on first run so that might be something too. I have 38.4 of Hass and 4.1.4 of HaBridge and seems to be all running OK.

Also, I stopped using letsencrypt and just have no external access available any more.

You can always downgrade HaBridge and Hass to an earlier version.

$ pip3 install homeassistant==0.XX.X

I have upgraded to 4.1.4 again and with that version it is very easy to add the devices you have configured in HASS. On the Bridge Control tab, just add your HomeAssistant details (name, ip, port and password). Once added, a new tab appears on the main menu ‘Home Assistant Devices’. From that tab, just select the ‘Build Item’ button for the device you want to add. The Add/Edit screen appears and the only thing you have to do is change the name and click on Add Bridge Device.

The Bulk Add does not seem to do a lot but adding the individual devices works perfectly. After calling ‘Alexa, Discover’, all devices are found automatically. The only issue I have left is a known bug in HA-Bridge, which ‘hangs’ after about 10 mins. After this, you can no longer switch devices on or off through HA-Bridge but you can still do so in HASS. For now I am using a cron job to restart HA-Bridge every 15 mins. Hopefully a new version of HA-Bridge will solve this issue.

@Ide,

I managed to include home assistant in my HA bridge. It turns out that I don’t have to input “https://”, just the xxxxx.duckdns.org.

The auto-restarting HA bridge seems to be a good work-around. Just I have too little knowledge about programming. Do you mind sharing how you did it? Please be reminded that I have really poor knowledge so appreciate if you can be sharing step-by-step details. Thanks!

@Ide you can review the following link that gives an easy to follow instruction on setting up a Crontab.
https://www.raspberrypi.org/documentation/linux/usage/cron.md

Thanks to @Ide for the idea and @mchinery for the steps. I have got the habridge auto restart running. I set the restart cycle at 10 min. First 20 min seemed to be working alright. :slight_smile:

Is the crashing still hapening on the latest release? Have you updated to 4.2?

Releases · bwssytems/ha-bridge · GitHub

Added LIFX support, fixed Home Assistant connections for new HA release, fixed bulk add, fixed Domoticz handling. Fixed Hex handling for value replacement. Many other enhancements and fixes.

@BarryHampants

I was using 4.1.4. Knew there’s a new version just now.
Have just upgraded and removed the auto-restart. Will give it some time maybe report the results later.

Well I’m not sure if it’s happening to me now or or it’s because I’ve just updated to 0.39 but Ha Bridge doesn’t seem to pick up anything from Hass for me - just rebooting my pi now. I’ll let you know…

EDIT: @yungling - after a reboot it’s back so I suspect I’ll be needing an auto restart too.

Before HA bridge stops working like in the 4.1.4, i found, in 4.2.0, after some time (~2 min), the first call of service wouldn’t work. You have call the service for the second time for HA bridge to work.
I kind of think it is even worse than the old version- at least it lasts for 10-15 min…

Gonna try it out more to decide whether i go back to 4.1.4. Keep everyone updated.

Also just installed 4.2.0 and removed the restart. Let’s see if that fixes the problem. @yungling: to do the restart every 15 mins, I just did a ‘sudo crontab -e’ (to run as root) and added ‘*/15 * * * * systemctl restart habridge’.