HueEmulation and Google Home support

That worked, thank you for your help.

I got the Google Home to pair with the emulator, but I cant add any devices. It seems like OH2 does not accept hard brackets in the .items file.

I have an item set up like this:

Dimmer Light_GF_Living_Table "Sofa" (GF_Living, Proxy_Lights_Stue, Lights) {ihc="0x7c95d"}

When I try to make it wisible to the Google Home through the HueEmulator I add [“Dimmer”] to the item like this:

Dimmer Light_GF_Living_Table "Sofa" [ "Lighting" ] (GF_Living, Proxy_Lights_Stue, Lights) {ihc="0x7c95d"}

Now I get an error in the editor: “Missing EOF at ‘[’” and the sitemap (based on groups) is messed up.

Have I misunderstood how to use HueEmulator?

I’ve hacked a bit around, and tried to match the format of a real philips hue as posted earlier in this thread. With those changes it looks like dimming works for google home… If you want to experiment you can get the jar here: http://t0yen.asuscomm.com/org.openhab.io.hueemulation-2.0.0-SNAPSHOT.jar

1 Like

Oh yeah, and this is my .items list for it to work with my zwave setup:
Dimmer TestHue1 “Office Light” [“Lighting”] { channel=“zwave:device:2d54f1b3:node2:switch_dimmer” }
Dimmer TestHue2 “Dining Light” [“Lighting”] { channel=“zwave:device:2d54f1b3:node3:switch_dimmer” }
Dimmer TestHue3 “Living room light” [“Lighting”] { channel=“zwave:device:2d54f1b3:node5:switch_dimmer” }
Dimmer TestHue4 “Kitchen light” [“Lighting”] { channel=“zwave:device:2d54f1b3:node6:switch_dimmer” }

@staalebk thanks for your efforts. I’ll give it a try. Where these changes done from @digitaldan source that works with google home? Mind showing the changes so @digitaldan can apply them to his source and package it up for distribution?

Again thanks for your efforts,

Garrett

@garrettwp: You can see the changes here: https://github.com/staalebk/openhab2-addons/commits/hueemulation-google-home (the last two commits). I don’t know how much of them are needed. This is a hack so I’m guessing @digitaldan want a better fix :slight_smile:

Im using digitaldan’s version ( thanks for your efforts @staalebk - will try your version later)

Ive a question/problem. Last night i wanted to remove my garage door item from the binding

Switch	GarageDoorMQTT	"Garage Door"		(gOutside,gSecurity) ["Switchable","iss:room:Garage","iss:type:DevLock","iss:invert:true"]		{ mqtt="<[MyMQTT:mygateway1-out/8/1/1/0/36:state:MAP(miosSwitchIn.map)],>[MyMQTT:mygateway1-in/8/1/1/0/36:command:ON:1],>[MyMQTT:mygateway1-in/8/1/1/0/36:command:OFF:0]", autoupdate="false", imperihab="room:Garage,type:DevLock" }

as you can see ive set the tag as “Switchable”

I wanted to remove this, as i asked Google Home “Turn off the lights” , which it did and said replied “Turning off 16 lights”
…but it closed the garage door!..not what i wanted and so i presumed i could simply remove the tag in the item for now.

When i removed it however, the binding failed, and threw this error:

2016-11-30 11:35:14.466 [WARN ] [eclipse.jetty.servlet.ServletHandler] - /api/4feb2bd0-d814-46ff-90be-e9b5ffef89be/lights
java.lang.ClassCastException

and subsequently the /api/discovery.xml stops working with an error…

HTTP ERROR 500

Problem accessing /api/discovery.xml. Reason:

    Server Error
Caused by:

java.lang.ClassCastException
Powered by Jetty://

if i put the tag back the binding recovers, If i leave the tag out and restart OH2, the error remains, so i guess there is some data persisted by the binding.
Is there a way to clear this data? or should it be rebuilt at startup/periodically?

Secondly, even though im using tags “Lighting”, Switchable and Dimmer in my items file, all are shown in discovery.xml as “Dimmable Light” - Is this a bug?

{"lights":{"1":{"state":{"on":false,"bri":-1,"hue":0,"sat":0,"xy":[0.0,0.0],"ct":500,"alert":"none","effect":"none","colormode":"ct","reachable":true},"type":"Dimmable Light","name":"Good Night","modelid":"LWB004","manufacturername":"openHAB","swversion":"66009461","pointsymbol":{"1":"none","2":"none","3":"none","4":"none","5":"none","6":"none","7":"none","8":"none"}},"2":{"state":{"on":false,"bri":-1,"hue":0,"sat":0,"xy":[0.0,0.0],"ct":500,"alert":"none","effect":"none","colormode":"ct","reachable":true},"type":"Dimmable Light","name":"Party Time","modelid":"LWB004","manufacturername":"openHAB","swversion":"66009461","pointsymbol":{"1":"none","2":"none","3":"none","4":"none","5":"none","6":"none","7":"none","8":"none"}},"3":{"state":{"on":false,"bri":-1,"hue":0,"sat":0,"xy":[0.0,0.0],"ct":500,"alert":"none","effect":"none","colormode":"ct","reachable":true},"type":"Dimmable Light","name":"Chandelier","modelid":"LWB004","manufacturername":"openHAB","swversion":"66009461","pointsymbol":{"1":"none","2":"none","3":"none","4":"none","5":"none","6":"none","7":"none","8":"none"}},"4":{"state":{"on":false,"bri":-1,"hue":0,"sat":0,"xy":[0.0,0.0],"ct":500,"alert":"none","effect":"none","colormode":"ct","reachable":true},"type":"Dimmable Light","name":"Downlights","modelid":"LWB004","manufacturername":"openHAB","swversion":"66009461","pointsymbol":{"1":"none","2":"none","3":"none","4":"none","5":"none","6":"none","7":"none","8":"none"}},"5":{"state":{"on":false,"bri":-1,"hue":0,"sat":0,"xy":[0.0,0.0],"ct":500,"alert":"none","effect":"none","colormode":"ct","reachable":true},"type":"Dimmable Light","name":"Wall Lights","modelid":"LWB004","manufacturername":"openHAB","swversion":"66009461","pointsymbol":{"1":"none","2":"none","3":"none","4":"none","5":"none","6":"none","7":"none","8":"none"}},"6":{"state":{"on":false,"bri":-1,"hue":0,"sat":0,"xy":[0.0,0.0],"ct":500,"alert":"none","effect":"none","colormode":"ct","reachable":true},"type":"Dimmable Light","name":"Floor Light","modelid":"LWB004","manufacturername":"openHAB","swversion":"66009461","pointsymbol":{"1":"none","2":"none","3":"none","4":"none","5":"none","6":"none","7":"none","8":"none"}},"7":{"state":{"on":false,"bri":-1,"hue":0,"sat":0,"xy":[0.0,0.0],"ct":500,"alert":"none","effect":"none","colormode":"ct","reachable":true},"type":"Dimmable Light","name":"Island Bench","modelid":"LWB004","manufacturername":"openHAB","swversion":"66009461","pointsymbol":{"1":"none","2":"none","3":"none","4":"none","5":"none","6":"none","7":"none","8":"none"}},"8":{"state":{"on":false,"bri":-1,"hue":0,"sat":0,"xy":[0.0,0.0],"ct":500,"alert":"none","effect":"none","colormode":"ct","reachable":true},"type":"Dimmable Light","name":"Kitchen Downlights","modelid":"LWB004","manufacturername":"openHAB","swversion":"66009461","pointsymbol":{"1":"none","2":"none","3":"none","4":"none","5":"none","6":"none","7":"none","8":"none"}},"9":{"state":{"on":false,"bri":-1,"hue":0,"sat":0,"xy":[0.0,0.0],"ct":500,"alert":"none","effect":"none","colormode":"ct","reachable":true},"type":"Dimmable Light","name":"TV Light","modelid":"LWB004","manufacturername":"openHAB","swversion":"66009461","pointsymbol":{"1":"none","2":"none","3":"none","4":"none","5":"none","6":"none","7":"none","8":"none"}},"10":{"state":{"on":false,"bri":-1,"hue":0,"sat":0,"xy":[0.0,0.0],"ct":500,"alert":"none","effect":"none","colormode":"ct","reachable":true},"type":"Dimmable Light","name":"Tall Light","modelid":"LWB004","manufacturername":"openHAB","swversion":"66009461","pointsymbol":{"1":"none","2":"none","3":"none","4":"none","5":"none","6":"none","7":"none","8":"none"}},"11":{"state":{"on":false,"bri":-1,"hue":0,"sat":0,"xy":[0.0,0.0],"ct":500,"alert":"none","effect":"none","colormode":"ct","reachable":true},"type":"Dimmable Light","name":"Family Room Downlights","modelid":"LWB004","manufacturername":"openHAB","swversion":"66009461","pointsymbol":{"1":"none","2":"none","3":"none","4":"none","5":"none","6":"none","7":"none","8":"none"}},"12":{"state":{"on":false,"bri":-1,"hue":0,"sat":0,"xy":[0.0,0.0],"ct":500,"alert":"none","effect":"none","colormode":"ct","reachable":true},"type":"Dimmable Light","name":"Driveway Lights","modelid":"LWB004","manufacturername":"openHAB","swversion":"66009461","pointsymbol":{"1":"none","2":"none","3":"none","4":"none","5":"none","6":"none","7":"none","8":"none"}},"13":{"state":{"on":false,"bri":-1,"hue":0,"sat":0,"xy":[0.0,0.0],"ct":500,"alert":"none","effect":"none","colormode":"ct","reachable":true},"type":"Dimmable Light","name":"Deck Wall Lights","modelid":"LWB004","manufacturername":"openHAB","swversion":"66009461","pointsymbol":{"1":"none","2":"none","3":"none","4":"none","5":"none","6":"none","7":"none","8":"none"}},"14":{"state":{"on":false,"bri":-1,"hue":0,"sat":0,"xy":[0.0,0.0],"ct":500,"alert":"none","effect":"none","colormode":"ct","reachable":true},"type":"Dimmable Light","name":"Deck Pendant","modelid":"LWB004","manufacturername":"openHAB","swversion":"66009461","pointsymbol":{"1":"none","2":"none","3":"none","4":"none","5":"none","6":"none","7":"none","8":"none"}},"15":{"state":{"on":false,"bri":-1,"hue":0,"sat":0,"xy":[0.0,0.0],"ct":500,"alert":"none","effect":"none","colormode":"ct","reachable":true},"type":"Dimmable Light","name":"Deck Spot Lights","modelid":"LWB004","manufacturername":"openHAB","swversion":"66009461","pointsymbol":{"1":"none","2":"none","3":"none","4":"none","5":"none","6":"none","7":"none","8":"none"}},"16":{"state":{"on":false,"bri":-1,"hue":0,"sat":0,"xy":[0.0,0.0],"ct":500,"alert":"none","effect":"none","colormode":"ct","reachable":true},"type":"Dimmable Light","name":"Garage Door","modelid":"LWB004","manufacturername":"openHAB","swversion":"66009461","pointsymbol":{"1":"none","2":"none","3":"none","4":"none","5":"none","6":"none","7":"none","8":"none"}}}}

The solution to my question is to include the icon tag ex in the item description. Without this tag it doesn’t work (for me anyhow)

1 Like

@staalebk You confirmed my theory in that the json data being passed to the Google Home telling it what devices are available needs to be modified slightly. For one the type has a typo and needs to read Dimmable light and not Dimmable Light. The other changes to report it more like a Philips Hue probably help as well. These changes should not take much time to implement and hopefully @digitaldan can add them soon.

  • Garrett

I just wanted to add that I got @staalebk modified binding to work with Google Home to control the brightness of the lights.

Nice to hear that it is working for you as well @garretwp. I can report that I’ve had zero problems with the bindings, and I am really impressed by google home and it’s understanding of my broken English. :slight_smile:

Can anyon reproduce the problem above where the binding does not like if a tag is removed from the items file?

Cheers,
Greg

It happens for me as well for the first item I added to the .items file. If I remove it then i get a 500 error on the discovery.xml file with the following backtrace:

java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
at java.lang.String.compareTo(String.java:111)
at java.util.TreeMap.getEntry(TreeMap.java:352)
at java.util.TreeMap.remove(TreeMap.java:603)
at org.openhab.io.hueemulation.internal.HueEmulationServlet.getHueDevices(HueEmulationServlet.java:576)
at org.openhab.io.hueemulation.internal.HueEmulationServlet.apiDataStore(HueEmulationServlet.java:433)
at org.openhab.io.hueemulation.internal.HueEmulationServlet.service(HueEmulationServlet.java:258)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)
at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:70)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:271)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:499)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
at java.lang.Thread.run(Thread.java:745)

Thanks @staalebk for confirming its not just me!

I have the same problem. I can unpair and pair the emulator with google home, but get the error 500 in the discovery.xml and the same errors in the log. I can’t get it back to working again. Is it possible to delete the information from the binding that must be stored somewhere and just start over?

Mine works again if I re-add the entry I removed.

I too would like to know how to clear the binding’s “memory” so it re-initialises itself.

I stopped OH2 and tried deleting the text in the “items” file located at /var/lib/openhab2/hueemulation. After a restart the hueemulation worked again. So some of the “memory” is in this file.

1 Like

Thanks, all, for your collective efforts on this. It have this running reliably with OH2 build 648 on OS X server (El Capitan) using @staalebk jar.

It may be a consequence of the way I forwarded the traffic from port 80 to my openhab port for the hue emulator pairing, but it doesn’t seem to work after pairing the google home and devices unless I leave the rule in place. It’s not a big deal for me, as I wasn’t running any services from that box that need to serve anything on port 80 anyway, so I’ll just leave it alone for now. I was under the impression the port forward only needed to be in place to add devices and initially pair, not operate them after the fact. Is that incorrect?

Anyway, this is how I did the forward with pfctl, for any Macinfolk who may be wondering (or maybe can offer up an even better way). The IP tables way won’t work on OS X and ipfw was recently deprecated and removed (which is a pity because it is much easier).

Copy/paste the following into a Terminal session (replacing my IP and port choices for your OH2 instance accordingly):

echo “
rdr pass inet proto tcp from any to any port 80 -> 10.1.10.100 port 10003
” | sudo pfctl -ef -

It works, but has it’s drawbacks.

Also, I tried to change some items after setting it up and it freaked out Jetty (error 500). Setting the .items file entries I’d changed (from ‘test’ to something more meaningful) back to what they were unbroke Jetty exactly as @greg described.

I also have the HomeKit extension configured and the items work exactly the same between Siri/Homekit and Google Home as I have them defined. It’s pretty slick. No noticeable lag switching devices with either. I have a pretty varied mix of different z-wave device-types and ZigBee lightbulbs. It’s all seamless. Well done!

Just wondering what this tag does?

I have just set this all up with my Echo Dots, and my new Google Home. Took a bit of configuring (second ip, forwarding ports etc. but I have it all working! I’m using the @staalebk jar, and dimming works on that now, although I had to try a couple of times.

Everything does now show as “Dimmable light”, even if they are defined as “Switchable” - I have a few things that are virtual switches (not actual devices). Don’t now if this will be an issue.

It will be nice if this can be folded into OH2. Is there a PR planned for these fixes soon?

Interestingly, google home can also give you the status of the lights as well (Alexa can’t do that).

Thanks for all the good work on this! got my google home yesterday, and it’s controlling my 38 devices today!