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

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

That is fantastic @hartmms! I’ll share a link to the Git.

This would make it super easy to get up and running, if this could be used with scripts and media players too you could simply import everything in one hit and then delete and customise the entries you wanted to keep.

I don’t seem to be getting any notifications on this site any more otherwise I would have tested this myself but I assume this will overwrite existing lights and switches already setup?

No, running this script multiple times seems to just keep adding and adding devices. I typically only have < 10 devices, so I use the HA Bridge web UI to manually delete devices. I guess I could have added some code to “GET” all the current devices and “DELETE” them, but I didn’t. The HA Bridge docs says you can delete a device with “DELETE http://host:port/api/devices/”, but I didn’t think “DELETE” was a valid http request method when I wrote this script. I see now it’s part of the RESTful API. Oh well.

I think it’s probably better the way you have it. What I meant was I just didn’t want to destroy my current setup testing your script. Just need to do a backup first when I have some fiddlin time.

I use a few names differently to what they are in HASS because of conflicts or in the case of echo/home predefined commands. Plus there are Harmony activities and customised commands using scripts and you cant turn off or dim a script you need to turn on another script. I’d not want those deleted or altered for the sake of easily importing a single new device.

Finally made a start. Here’s a link @claudio

2 Likes

Good news, I got a Google Home last night and I just got it working with Home Assistant!

PR here: https://github.com/home-assistant/home-assistant/pull/4708

Kinda sad that we just did a release as this would be great for people to hack with so I am considering putting this out in a point release :dancer:

3 Likes

Saw the PR this morning - please do!!

BTW, I inadvertently checked the wrong option on GitHub and subscribed to all updates on the project instead of just the one PR I was going to watch. Woke up today to over 220 emails. Gave me a new appreciation for what it must be like to be a senior dev - God bless you guys; I can’t imagine how long it takes you to go through your email each day!!

Cool.

I have both the Google Home and the Echo dot. Can I run both in emulated hue in HA?

I was using ha-bridge, but for my use case (getting Alexa to control x10 switches) I decided it was simpler to use fauxmo (wemo emulator) to emulate wifi switches instead of emulating a Hue Hub.