[RELEASE] CoCoHue: Hue Bridge Integration (including scenes!)

That was quick, thank you so much!
Indeed my automation were using ranges instead of exact points, but now at least for levels I think I can get around it.
Edit : just tested and you are right about CT:. No issues there. I think the stock hue integration has the issues I mentioned.

Brand new user so apologise in advance.

Got my new Hubitat installed and both Hue hubs working with Alexa. Then realised none of the scenes work on the native Hue Hubitat app - does this build resolve this?

Does it also allow you to set bulb brightness, ie ‘Alexa set bulb to 70%’? Is this is what is referred to as change level?

Now reading up on Habitat Package Manager....

Is the Coco HUe Br

By "Hue Hubitat app," do you mean Hubitat's built-in Hue Bridge Integration app? If so, yes: CoCoHue allows you to import scenes from the Hue Bridge, which Hubitat's built-in integration does not support.

The command you want on Hubitat is called "Set Level," and both CoCoHue and Hubitat's stock Hue Bridge integration support this (as should pretty much all Hubitat drivers for any dimmable bulb). From Alexa, you can indeed run this command by saying something like "set bulb XYZ to 70%."

Also, note that the Hue Bridge (if you're using a v2 Bridge or newer) has its own Alexa integration. Many people like to use this instead. That way, you don't need to put Hubitat in the middle (and you'll have access to all bulbs, rooms/zones/groups, and scenes, even ones you don't use in Hubitat). However, either way should work. The pros and cons of each approach was recently discussed in another thread if you were interested in reading more: School me on Alexa Integration?

Thanks for your detailed response. I did indeed mean the Hubitat Hue integration app.

I didn’t think the Alexa app could be linked to more than one Hue hub at a time, so I thought I would have to get Alexa to link to Hubitat instead as I have two Hue hubs.

You cannot link the Hubitat Alexa skill to more than two Hubitat hubs (if that's what you meant, sorry!). You can link it to both Hubitat and Hue at the same time (they are separate skills; as far as I know, this is mostly the result of Amazon not letting you install multiple instances of the same skill--and skill developers not finding creative workarounds).

Greetings, everyone! I've been working on the next major version of CoCoHue, release 3.0, and thought I'd preview some of my changes:

  • Support for Hue Motion sensors (indoor and outdoor) with motion, illuminance, and temperature attributes. Do note that this relies on polling, so I would not recommend using this for time-sensitive automations like motion lighting. I trust people to understand the tradeoffs here. :slight_smile:
  • Support for Hue Labs "activator" devices: any Hue Labs formula you've configured on the Hue Labs website with a "virtual activator" device can be imported as a device in Hubitat. These devices, as you might expect, support being turned on and off and reporting their state (like everything on Hue, also only via polling or changing from Hubitat). I also made them a PushableButton device, so pushing button 1 is an alternative to sending an "On" command.

There are two new drivers for the above features: cocohue-generic-status-driver.groovy and cocohue-motion-sensor-driver.groovy; the former name is a bit odd but closely matches what Hue internally calls these devices and it may be usable for other things in the future. All of the apps and drivers have received at least minor updates, though these are only new visible features.

The code is available in HPM if you have the "prerelease" option turned on. If this works well enough for people, I'll tie up some loose ends and eventually promote this to a stable release in the "regular" branch. You can also manually install it from a temporary location I created for this: CoCoHue/beta at master · RMoRobert/CoCoHue · GitHub (should be apparent what code goes with what apps/drivers; don't forget the new ones).

And yes, 1.x users still need to perform the first upgrade manually for at least the app portion according to the instructions in the first post. :slight_smile: After that, HPM should work, though you'll probably still want to perform the uncommenting-in-the-app step each time.

4 Likes

That sounds great! Thanks for the hard work on this - I will give that a try.

I really enjoy the improvements CoCoHue provides over the stock integration, and would be happy to trial the new version for you. I don't have any Hue Motion sensors or Hue Labs activator devices, however. Is there a comprehensive changelog somewhere I can look at to determine if my input is even needed on this new version?

The only other changes I made were with how polling works, with me now doing one poll/refresh for the entire Hue Bridge status instead of before, where I did one for lights and one for groups. This shouldn't have any visible effect, but it was something I figured was better to do now that I need to look at more places in the API to get what I need for the sensors and Labs formulas. I also made a fix to the dimmable only, CT, and on/off drivers to match the RGBW bulb driver behavior of not changing attribute values (e.g., "switch: on") until a response is received from the Bridge (rather than immediately/"optimistically"), something I already meant to do and had already done to the RGBW and group drivers in 2.0. Handling unexpected (or no) responses from the Hue Bridge also changed a bit, but I also don't think that should affect anything (just hopefully eliminate errors if something sends a similar enough response but isn't really a Hue Bridge).

1 Like

Robert, I use these primarily (exclusively i guess) for illuminance, how does this option change the standard behavior?

S.

What standard behavior? It won't change anything on the Bridge; it just polls the sensor data from the Bridge in the same way (and at the same time as) it gets light, group, etc. information. Everything there will keep working as-is. What I mean is that you won't get instant motion events on Hubitat since, like everything that uses the Hue API, it has to poll and can't get this information "pushed" to it in real time. So, it's a Hubitat-only concern--and technically also applicable to lux and temperature, but motion is the thing where I can see this being a problem if you don't know of the polling thing. :slight_smile:

Ah. I think I confused myself when thinking about your post. I just realized you (obviously) are talking about Hue Motion Sensors paired to the Hue Hub. I now understand.

I was not connecting the blatant dots in your post, and was thinking about my use of them, which is directly connected to the Hubitat. My bulbs are on the Hue, but the sensors are on Hubitat.

Honestly...in hindsight, I don't know what the hell I was thinking.....

S.

So just messing around with scenes and dashboards, I'm realizing that turning on a scene for a room, doesn't turn off a competing scene for that same room.

For example, I have a scene called bright and relax (just the default hue ones) for a room, I turn on bright - all is good. I then turn on relax, but the bright scene stays on. Ends up making the dashboard tiles look a little funky.

Any workaround for this one?

Edit: Partially a fail on my part, but looking at the groups, I do see there is an option to do what I'm asking about, but both of the groups in question seem to be configured with the option I would expect to work, but they are not.

image

Edit 2: Well I guess I'm just being dumb today, I guess these two settings are connected. Need that second one set to refresh for it to work.

Ah, yes, I should probably clarify that in my next set of release notes since Hubitat supports these directly paired as well. (And really that's what I'd do unless you have some reason to keep them on Hue. I see lots of advantages to bulbs paired to Hue instead of Hubitat, but I'm not as sure about sensors...just figured I'd add this to CoCoHue for those who do since it's easy enough.)

As you noticed, you do need that first option set. You really shouldn't need the second option (Bridge refresh on activation/de-activation) set given that the first option should cover anything for the same room/zone, but it can't hurt (but you will need it if these are LightScenes or somehow CoCoHue didn't get the right bulbs for the group).

I'm curious if you will still see this behavior on occasion either way; with only the first option set for me, it seems to work unless I change scenes very fast (which I never do in real life but tend to do when testing things). In that case, I think the app might be working with stale, cached device data. I can force it to read new/current data, which would work around this problem if I'm correct. I thought it might have been just me--but it does seem to work well if I wait at least 5-10 seconds between scenes.

So both are group scenes. I wasn’t able to get it to work at all, with only that first preference set. I was testing a new dashboard, but I’m pretty sure I had both groups on for an extended period of time, more than 10 seconds, and an update never came through.

I did recently shuffle bulbs around, moving out of one room and into another. In the past, this has caused a bunch hue things to go crazy on me and I had to recreate all my rooms. I’m wondering if that could be causing problems for me here,

Maybe--try a "Refresh" on the scene device, which will fetch the group number a GroupScene belongs to (or the light numbers of any lights in a LightScene). Unfortunately, I don't know if I have a way to account for light-number changes within a group right now (that's just fetched on creation), so I'll have to figure out something for that if that's part of the problem. I don't think that would be related to this issue, and maybe there's more to it than I see off hand. I'll play with it some more when I have time since I was able to get this behavior under some conditions and figured time was the only cause.

Can I add a request. I am new to HE but no to HA.

Add a driver to CoCoHue to poll for Temp/Luminance and Battery from the Hue Motion Sensors connected to a Hue Hub.

I have two hubs worth of Hue devices, bulbs and motion sensors.

I understand the issues around Motion, but I would really love to be able to use Luminance/Temperature and even Battery Level from the Hue Motion Sensors using the Hue Hubs.

It would allow me to keep all the lighting on Hue Hubs to run autonomously and use HE for 'oversight' / edge cases.

And then allow me to use the ~14 Hue Motion Sensor/Temp Sensors to drive the ~14 Heating Zones in the house WITHOUT having to purchase another 14 Temp sensors that HE can use.

I know, and have one Hue Motion Sensor migrated natively to HE, but to migrate the others would require building another zigbee mesh for the battery Hue Motion sensors to connect to, to do that would require migrating ~10 Hue bulbs to provide a minimal mesh around the house.

That then means I am managing the lights in one Hub, Hue well most, and the sensors on an HE hub and it introduces a level of complexity and dependency that I am trying to avoid.

This post earlier in the thread would seem to address what you're looking for:

@scottgu3 Well now I feel foolish - sorry it is a long thread and I missed that.

That would be awesome!!

I am getting the pre-release now!!!

many thanks for pointing that out !!!!

Much appreciated

Happy New Year!

2 Likes

@bertabcd1234

Not a problem but I am getting a lot of error messages in the logs

dev:2262020-12-28 12:08:16.989 errororg.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'battery=100' with class 'java.util.LinkedHashMap$Entry' to class 'java.lang.Integer' on line 118 (createEventsFromMap)

dev:2272020-12-28 12:08:16.957 errororg.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'battery=25' with class 'java.util.LinkedHashMap$Entry' to class 'java.lang.Integer' on line 118 (createEventsFromMap)

dev:2252020-12-28 12:08:16.924 errororg.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'battery=35' with class 'java.util.LinkedHashMap$Entry' to class 'java.lang.Integer' on line 118 (createEventsFromMap)

dev:2332020-12-28 12:08:16.892 errororg.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'battery=100' with class 'java.util.LinkedHashMap$Entry' to class 'java.lang.Integer' on line 118 (createEventsFromMap)

dev:2342020-12-28 12:08:16.827 errororg.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'battery=100' with class 'java.util.LinkedHashMap$Entry' to class 'java.lang.Integer' on line 118 (createEventsFromMap)

dev:2292020-12-28 12:08:16.795 errororg.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'battery=56' with class 'java.util.LinkedHashMap$Entry' to class 'java.lang.Integer' on line 118 (createEventsFromMap)

dev:2282020-12-28 12:08:16.757 errororg.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'battery=100' with class 'java.util.LinkedHashMap$Entry' to class 'java.lang.Integer' on line 118 (createEventsFromMap)

dev:2352020-12-28 12:08:16.720 errororg.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'battery=90' with class 'java.util.LinkedHashMap$Entry' to class 'java.lang.Integer' on line 118 (createEventsFromMap)

dev:2322020-12-28 12:08:16.689 infoMaster Ensuite sensor illuminance is 46lux

dev:2322020-12-28 12:08:16.679 errororg.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'battery=100' with class 'java.util.LinkedHashMap$Entry' to class 'java.lang.Integer' on line 118 (createEventsFromMap)

dev:2302020-12-28 12:08:16.646 errororg.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'battery=100' with class 'java.util.LinkedHashMap$Entry' to class 'java.lang.Integer' on line 118 (createEventsFromMap)

dev:2312020-12-28 12:08:16.608 errororg.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'battery=49' with class 'java.util.LinkedHashMap$Entry' to class 'java.lang.Integer' on line 118 (createEventsFromMap)