I present for your use, my new Advance Hue Bridge Integration for integrating the Philips Hue hub with the Hubitat Elevation hub.
Download from GitHub, or install it through the Hubitat Package Manager application and be kept updated on my changes as they are published.
Overview
This project is the result of a desire to expose features and capabilities not yet available in the built-in Hue Bridge provided by Hubitat. The initial goal of this project was to provide support for Hue features that were not already available. I was not able to activate scenes, and dimmer control from HE was poor behaving at best. Capturing state was difficult, since HE could fall out of sync with Hue, and this could lead to capturing the wrong state. And since the HE integration does not support per-device, or per-group refresh, attempting to refresh the state of a single bulb, or group was time consuming.
Objectives
- Use built-in Generic Component drivers wherever possible
- Support for refresh by Bulb
- Support for refresh by Group
- Support for Hue Scenes
- Support for start/stop level change
- Proactive devices state updates
- When a scene is active, refresh the state of all affected rooms, zones, and bulbs
- When a group is modified, refresh the state of all member bulbs, and impact zones
- Avoid network saturation
- Any refresh, cancels and reschedules the auto-refresh
- Multiple stacked refresh commands are reduced to just one.
- A forced refresh is scheduled to run after a slight delay, making canceling the refresh possible.
Implementation Goals
I created this driver to satisfy some automation desires. It is currently being used as my only Hue integration.
- Want to transition to scenes organically, with all hue bulbs at once.
- Want to fix HE scene transition limitation of one bulb / group at a time.
- Want to be able to use a Z-Wave dimmer to control dimming level of Hue Bulbs/Groups
- The dimmer should feel natural
- While holding up / down, the bulb should smoothly transition up / down
- When releasing the dimmer, the bulb transitioning should stop immediately
- Want to be able to issue a refresh, then wait for refresh to complete in RM before executing next action
- This feature could make it possible to refresh a bulb/group, wait for refresh to complete, then capture state of the bulb/group
- Want to define any refresh interval I desire, rather than being locked into a pre-defined list of intervals.
Advanced Hue Bridge Integration Application
The application is the backbone of the Hue bridge integration. All of the Hue API calls are through the app. This app was made to mimic the built-in Hue integration wherever possible.
Use the app to find, and link to your Hue Bridge. Once linked, the app makes it easy to add your Hue Zones and Rooms as Groups, your Hue Scenes as child devices to your Groups, and your Hue Bulbs.
AdvancedHueBridge Device
This device requires the Advanced Hue Bridge Integration application to work. It is created by the parent application after linking to your Hue Bridge. This device functions as the All On/All Off switch for all of your Hue lights, as well as the scheduled coordinator for hub refresh events.
AdvancedHueGroup Device
This device requires the Advanced Hue Bridge Integration application to work. It is created by the parent application. This device serves as the Scene device container. The goal of this project was to avoid custom drivers were possible, however, for management of scenes, it was decided that it would be more manageable to create scenes as a child device of the groups to avoid naming conflicts, and make to keep the scenes with the groups that they are defined in Hue as. This device emulates an RGBW bulb, with configurable refresh schedules, and on-demand refresh though the refresh command.
Scenes and Bulbs Generic Component Devices
To implement the Scenes, I use a Generic Component Switch, that I have programmed to behave as a momentary switch. Since Hue does not maintain state for Scenes, neither do I. I do not try to guess which scene(s) is(are) active. If you command the scene on, the state will change to on after confirming the Hue Bridge received the request, then it will change back to off state after a few moments.
To implement the Hue Bulbs, I parse each device type in Hue, and match that device type, based on capabilities, to the best matching Generic Component device. I do not have all the different types of bulbs that Hue offers, but I do have some color bulbs, spot floods, CT bulbs, and GE+Link dimmers, so I have enough to ensure basic functionality is correct.
Advanced Hue Dimmer Sensor Device
Advanced Hue Tap Sensor Device
Advanced Hue Motion Sensor Device
Advanced Hue Light Sensor Device
Advanced Hue Temperature Sensor Device
These sensor drivers only work effectively if used with the new Hue Push notifications. The Motion, Light, and Temperature sensors can be used in polling mode if so desired. The Dimmer, and Tap button devices cannot be used in polling mode due to the nature of the devices. If any of these sensors are added to Hue without assigning to a room or zone, then Hubitat can use the devices just like any other push button devices. If assigned to a room or zone in the Hue app, the devices can still be used, but the Hue hub will use them to turn lights on/off as well.
The recommended implementation for these devices is to associate them with rooms or zones, and let Hue use them to manage the target grouped devices in the Hue app, and to use the Hubitat to monitor and supplement the Hue features.
All sensor devices are included in Hubitat Package Manager as optional devices. Be sure to install them if you wish to use them. You only need to install the ones you want to use.
Limitations
The Hue hub API is a very responsive system with constantly growing capabilities. The hardware in the Hue hub is rather slow however. The Developer's documentation states that The Hue hub is only capable of changing the state of 1 Group Per Second, or 10 Device Per Second . Anything more will likely result in queue of requests. This applies to all hue integrations. Please consider this when adding hue groups/schene/lights to HE rules and groups, and scenes.
I am playing with work-arounds for this, but there is only so much we can do. At present, I have techniques to limit what is sent to Hue when the target device is in the off state, and then queue them with the on event, to handle turning on the target group / light and setting all states with a single command.
As of Version 1.6.1 published on Oct 16, 2021, when installed on hubitat 2.2.9, the refresh schedules now behave differently. This driver now supports experimental push notifications from the Hue hub. That means that when you control a room, or zone (aka, group) or a bulb directly on the hue device, the hue hub will notify my driver of the change. As such, when the event stream connection is open, the refresh will be repurposed as a health check on the event stream, and in the event the stream is down, and cannot be re-established, then a full hub refresh is used as a fall-back mechanism.
Hub push notifications is still experimental, but it is the default behavior now, to ensure a smooth transition, the driver will make all necessary device configuration changes for you upon upgrade, and if that fails, upon save settings call.
Disclaimer
This is a product of my own independent research. All code is entirely created by me, for my network, and my friends' networks. The results of my efforts have proven to meet our needs quite well. There are still some planned updates that are not yet implemented. Your results may differ.
If you find bugs, please submit a bug report on my GitHub project page.
If you would like enhancements, please submit the requests on my GitHub project page.
Enjoy!