Why can't emulated Hue work with OnHub or Google Home?

I am using BWS. Here is my exact problem:

https://github.com/bwssytems/ha-bridge/issues/220

Not an option for me - I like my Alexa integrations.

Just wanted to chime in. The Emulated Hue Bridge in home assistant DOES work with Google Home just fine.

you need to set the listen_port to 80, but once you do that it works great!

1 Like

Thanks Klathmon, Iā€™ll give it another go when my G.Home arrives. You wouldnā€™t believe how difficult it is to order something like this in Australia. After a couple of cancelled orders I ended up paying a shipping forwarder to buy it for me.

I felt pretty conflicted letting it go, it took me a fair bit of time to get it to work. Iā€™d like to get the Flash Briefing skill going so might switch back if the SSL Certificate script for Java solution posted on git works for ihgates.

Just tried that, no luck. Do you have it working with the built in emulated hue inside of HASS or the one that HA Bridge has?

I had it working with the emulated_hue setup in HASS, but it seems to be semi-broken now.

For some reason itā€™s only showing a single switch out of my whole system (and annoyingly enough itā€™s the switch to the TVā€™s powerā€¦), but that one switch does work.

I canā€™t get it to find any other switches/lights, and after disconnecting the philips hue system from google home, it still shows up (but doesnā€™t work until i reconnect it), and I canā€™t seem to find a way to get rid of it (even tried resetting the google home).

I have checked the hue API and have confirmed that everything is showing up correctly there, but it just doesnā€™t want to cooperate.

1 Like

Spent a couple hours fighting with a Google Home.

So the Google Home will try to use the local network Hue API. No cloud needed. This is great news. The bad news is itā€™s going to require some work to get it functional.

Google Home isnā€™t happy with the SDP query answer delivered by emulated_hueā€™s and ignores it. This can be fixed by editing homeassistant/components/emulated_hue.py. In particular:

    resp_template = """HTTP/1.1 200 OK                                                                                               
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=60
EXT:                                                                                                                                           
LOCATION: http://{0}:{1}/description.xml                                                                                                        
SERVER: FreeRTOS/6.0.5, UPnP/1.0, IpBridge/0.1                                                                                                  
hue-bridgeid: 001E06FFFE123456                                                                                                                  
ST: urn:schemas-upnp-org:device:basic:1                                                                                                         
USN: uuid:Socket-1_0-221438K0100073::urn:schemas-upnp-org:device:basic:1                                                                                                                                                                                                                        """        

In particular it appears emulated_hue is missing the hue-bridgeid. Hat tip to the ha-bridge documentation for documenting their responses on this.

For Google Home emulated_hue MUST be listening on TCP port 80. So for now youā€™ll either have to run it as root (bad) or give python the capability to bind ports lower than 1024:

 setcap 'cap_net_bind_service=+ep' /opt/home-assistant/ha-py3env/bin/python3

Another option to fix this would be to add an option to emulated_hue configuration so that you can make the upnp responder say port 80, but really have the TCP listener on a different port, then leverage something like nginx proxy pass.

So this gets the Home talking to emulated_hue and attempting to grab the lights list. And here Iā€™m stopping for the night. It is doing the same thing as Alexa in that if there is something it doesnā€™t like about the format of the JSON response or the contents of a field it will reject everything and silently fail. In the case of the Google Home it keeps retrying over and over again long after the mobile website tells you pairing failed.

So basically we need to spend some time banging our heads at this. We need to compare our responses to real Hue API, try different values in different fields, etal until we can figure out what is making Home unhappy about the API responses.

5 Likes

This is super solid. I can confirm a lot of this as I spent a good amount of time last night trying to figure out the same problem.

Some things Iā€™ll add -> HA uses this version of Emulated Hue https://github.com/blocke/ha-local-echo

Another version -> https://github.com/bwssytems/ha-bridge seems to have direct Emulated Hue support for Google Home in their latest version. According to their dev, if you update to the latest version and run on port 80, it works 100%. Looks like this library is running on Java so Iā€™m not sure there is an easy way to migrate that into Home Assistant.

I had no idea there were so many variants of Emulated Hue bridge.

I was unaware that python canā€™t bind to lower ports. Thatā€™s a major issue that may prevent non-power users from utilizing Home Assistant on a Google Home for now.

Iā€™ve been reading a lot of the hype for the Google Assistant API coming out in December. Depending on the complexity of the fix for the Emulated Hue component, it might be easier to wait until December for the Google Assistant API. Itā€™d be silly to write a whole new emulated hue bridge only to be deprecated in a month.

I have a strong feeling that the Assistant API will enable some very robust options for HA including a new notification platform, integration with the Google Home, and maybe even a fully self-standing Google Assistant platform. Itā€™s not clear if Google will create a Python binding for it out of the box so there may be a significant amount of work required to make it play well with HA.

Iā€™m tagging at @balloob because we had talked briefly via Twitter and wanted to give him an update. Iā€™d love to know what everyone thinks the best steps forward are. Iā€™m loving the Home so far!

Cheers!

2 Likes

By the way, here is the link to the Google Assistant API page. Nothing is up yet, but there is a signup to be notified of any updates.

1 Like

I have Home Assistant, Google Home and HA Bridge (version 3.2.1) from bwssytems working good and no issue.
Only thing I would like to improve if possible is when I ask Google Home status of my lights it will be correct for only those light I controlled using Google Home. If I had it turned on/off using Home Assistant Google Home will not have the correct status. The reason I see is when I have configured my light in HA Bridge used POST restful call using service like

URL for on:
  http://localhost:8123/api/services/switch/turn_on?api_password=xxxxxx
URL for off:
  http://localhost:8123/api/services/switch/turn_off?api_password=xxxxxx
Data:
  {"entity_id":"switch.kitchen_light"}

So Google Home have no way to poll the status using that URL, if I use configuration shown below then control doesnā€™t work as Home Assistant just changes the status of light in Home Assistant but will never send command to the device so next poll that status will over-written.

URL:
  http://localhost:8123/api/states/switch.kitchen_light?api_password=xxxxxx
Data:
  {"state": "on"} 

Any possible solution?
Thanks

Iā€™m really hopeful for Actions on Google. The small amount of information that has been given so far is very encouraging! Iā€™m loving my Home as well, so far.

Supposedly we should be hearing something towards the end of November.

1 Like

Iā€™m trying to get a master list of commands going. I wasnā€™t able to find a comprehensive one out there yet. Feel free to add to it if you know more

https://github.com/iantrich/GoogleHome

1 Like

Really nice of you to put that together.

Alsoā€¦ LAANNAAAA!!!

(Huge Archer fan!)

2 Likes

After a long night work, finally got HA bridge to work with Letsencrypt so now it works with HASS without having to sacrifice the encryption. all you have to do is install java 1.8.0u111 since it has lets encrypt as a trusted certificate. here is how I did it:

Installing Java Version 1.8.0u111

Just to make sure you start with a clean(ish) slate. uninstall java from your raspberry pi by running the following command:

  • sudo apt-get remove --purge oracle-java8-jdk openjdk-7-jre oracle-java7-jdk openjdk-8-jre

Once that is done, install java 1.8.0_111 by going to this website and downloading the file shown in the picture below:

Extract the file in /opt, and set up java and javac by running the following command:

  • sudo tar zxvf jdk-8-linux-arm-vfp-hflt.tar.gz -C /opt
  • sudo update-alternatives --install /usr/bin/javac javac /opt/jdk1.8.0/bin/javac 1
  • sudo update-alternatives --install /usr/bin/java java /opt/jdk1.8.0/bin/java 1
  • sudo update-alternatives --config javac
  • sudo update-alternatives --config java

After all that is done, make sure you installed everything correctly:

  • java -version
  • javac -version

Then restart our Pi

  • sudo reboot

Things to make sure you got:
HA bridge running on port 80
HAbridge version 3.2.2 or higher (when applicable)

Now if someone can do this with less work please let me know!

8 Likes

Perhaps I am dense, but I donā€™t see an easy way to configure HA bridge to work with HASS. Do I have to manually add each device myself with the custom URL commands?

I didnā€™t have to do this with the home-assistant built in hue emulation. I was kinda hoping there was an easier way. I have a fair amount of lights and didnā€™t want to have to manually configure each one.

For now you do. Itā€™s not all that hard once youā€™ve done the first one.

It looks like a discovery type set-up might be in the works for future versions though.

I might take some screenshots and start a general ha-bridge thread if you can wait a couple of days.

2 Likes

thanks!!! Highly appreciated

After thinking more about it, I might just write a trivial python program that accepts the light device names as input and dumps the proper config file syntax for each one.

1 Like

Here is a script I wrote to get all the light and switch entities out of Home Assistant and add them to your HA bridge configuration.

!#/usr/bin/env python

import yaml, json, requests, pprint

# URL of your HA bridge server
bridge_url = 'http://<address>/api/devices'

# Home assistant API password/key
ha_api_key = 'xxxxxx'

# URL of your home assistant. Include the port if you use something other than the default 80/443
ha_url = 'https://<address>:<port>'


# don't change these
ha_data = {}
ha_data['deviceType'] = 'switch'
ha_data['httpVerb'] = 'POST'
ha_data["contentType"] = "application/json"

pp = pprint.PrettyPrinter(indent=4)
r = requests.get(ha_url + '/api/states?api_password=' + ha_api_key)

for i in r.json():
    for t in "light switch".split():
        if t+"." in i['entity_id']:
            ha_data['onUrl'] = ha_url + '/api/services/' + t + '/turn_on?api_password=' + ha_api_key
            ha_data['offUrl'] = ha_url + '/api/services/' + t + '/turn_off?api_password=' + ha_api_key
            f_name = i['attributes']['friendly_name']
            entity = i['entity_id']
            ha_data['name'] = f_name
            ha_data['contentBody'] = "{\"entity_id\":\"%s\"}" % entity
            ha_data['contentBodyOff'] = "{\"entity_id\":\"%s\"}" % entity
            # used to debug dictionary format before submitting to ha bridge
            #pp.pprint(ha_data)
            r = requests.post(bridge_url, data=json.dumps(ha_data))indent preformatted text by 4 spaces
1 Like