[Release] Advanced Hue Bridge Integration

I tried the advanced Hue Bridge Integration, but I'm not sure I have done it correctly. At least, it doesn't work yet.

What I've done:

Installed App Code (Integration App)
Installed Driver Code (Bridge Device and Group Device)

Imported Groups and Scenes

There is now an advanced hue bulb as a device and a group with a scene as a child device.

When I activate a Scene from the device page, the scene is not activated in hue. logs shows:
errorjava.lang.NullPointerException: Cannot invoke method resetRefreshSchedule() on null object on line 839 (componentSetLevel)

any idea?

thanks for your support.

Did you install this using Hubitat Package Manager? And what version software is running your hub? I am on 2.2.8.136 and I do not get this error. I will look at the source to see what it may pertain to. I also plan to update my hub today, so I can see if it is related to the update maybe?

Update: Looking at the source, lines 838-839 reads:

def hub = getChildDeviceForMac(selectedDevice)
hub.resetRefreshSchedule()

this means the hub cannot be located using the Mac address of the selectedDevice.

Did you try to pair this to more than one Hue hub?

Did you delete the hub device maybe?

If it was installed correctly, it should look something like this:

Where Philips hue (ACC32F) is my hue hub. It is this device that the app is unable to find.

If your hub device does not exist, you can recreate by going through the hub linking process again.

IF your hub device does exist, please send me the "Settings" section of the Advance Hue Bridge app (it will look like this)

and the "Application State" for "hubs" which looks like this:


(Be sure to remove the "userName" section as that is your Hub's login credential for the hue.

Thanks for your quick answer.

Did you install this using Hubitat Package Manager?

No, but I want to do that. See my questions at the end of this post.

I am on 2.2.8.136 and I do not get this error.

I'm on 2.2.7.126

If your hub device does not exist, you can recreate by going through the hub linking process again.

IF your hub device does exist, please send me the "Settings" section of the Advance Hue Bridge app (it will look like this)

The Bridge is there. After I linked it again, it worked. But only to turn the scene on. Toogling the switch again ended in endless wait...

Before I waste more of your time, I would like to try and reinstall it via package manager. I hesitated, because it's still labeled "beta".

Before installing I would manually remove all "advancedhue" device (Buld, Groups, Scenes, Bridge) and then remove the app. Is that correct? Do I need to check anything else, before installing package manager? (I will update the hub...)

thanks, hope it works after reinstall.

Personally, I'd try to do a match up from HPM, and after it finds it just do a HPM update.

Toggling what switch? I feel there is more here than in your original post. If you have the hue light connected to a wall switch, and you turn the switch off, the hue hub loses all communications with the light until the switch is turned on. And even then, the state of the light depends on your settings in the hue bridge.

When my Hue app thinks that the light is already on, it does not send an ON event again, because Hue can only handle about 10 device commands per second, and only 1 group command per second.

If the behavior in Hue Hub for the power being restored is set to turn the light on (this is factory default, so it behaves like a normal bulb), the app will not know that the state changed, because Hue does not have any sort of notification system.

Depending on your setup, you can refresh the hub (as a whole), on a schedule, or refresh the group that contains the light.

But if the issue is that you receive the null pointer exception after toggling the switch, then there may be a whole different issue. When 2.2.8 was released, I did have to make a change to fix a bug, but I do not recall what that was. I wonder if this is because you are on 2.2.7.

As @thebearmay stated, you can match up the installed drivers and app to HPM published apps. When you install HPM, this still will run as part of the setup (you must accept doing so when prompted). And you may do it from within the app at a later time. I run the match up process periodically to see if anything I have installed has been added to HPM.
In addition to a repair, it may be helpful to run the repair option too, which forces the download/update of the latest drivers from GitHub, even if HPM thinks you have the latest one installed. This can happen when the metadata gets confused about the state of the currently installed drivers/apps.

Sorry, I was unclear. I put the scene (as a device) in a Dashboard for testing. I can turn the scene on, but when I turn it off, nothing happens. I now think, this could be intentional. You cannot turn a scene off? You can turn bulbs off or activate another scene.

Question: Switching off a scene (-device), should that turn the bulbs off?

Thanks for the info to hpm. I will try that after updating the hub.

looking at the logs, I still get Nullpointers.

Curios, what is app176? It seems that you have more than one integration that is unable to obtain child devices properly. I recommend upgrading your HE hub to the latest version. If you are creating custom rules, you will want the new Rules-5 and button controller 5.

Also, HE does have their own, official, Hue integration. I wrote mine to solve some very specific needs that the built-in system does not support. I also learned that there is another hue solutions that was released around the same time I released mine (maybe sooner, but I discovered it well after I released mine). I have not so much as even looked at the other driver, as I do not want my solution influenced by another. I do not know which is better at what. Before you get too far into it, you may want to consider the various solutions.

The default behavior of a scene is to not turn off the lights when the scene is turned off. Hue does not have an off option for scenes, as the scene is just a default collection of settings for the group. But, if the bulbs change state, the hue scene will no longer appear to be set, so I have an option for that. There is a setting in the group that is the parent of the scene.
Here are the settings available.

Default Scene allows you to enter the name, or Hue interval number of the scene. If the group is turned on, and no other options are defined (brightness, color, temp, etc), then the default scene is activated. Here, I have my office lights (two dimmable lights) set to also turn on to "Dimmed" scene when turned on.

Scene Child Device Behavior allows you to control the scene as a switch, or a trigger.
trigger - The scene will turn on, then turn back off. This changes the child device to a momentary switch.
switch - The scene will turn on, and stay on, until turned off. Only one scene can be active at any one time, so turning on any other scene will turn off the prior scene. When in switch state, turning off the scene, will turn off the group.

Track Scene State - If enabled, any change to this group will turn off all child scenes. That is, if you turn on the dimmed scene, but then change the level to a lower level, the child scene device will be turned off. This setting only applies to switch type scenes.

Auto refresh - If enabled, then the hub will poll the group for current state on the schedule you provide. After any device state is changed, a delayed full-hub-refresh is issued regardless of the state of this setting. This should only be required when you control your hue lights/groups/scenes from outside of the HE system.

ANY on or ALL on - If this setting is turn on, then the group will turn on when any light within the group turns on. When this is off, then the group must be turned on, or all lights must turn on for the group to be considered on. This is a HUE setting. HUE reports two states for groups, and this settings determines which one the HE group will refer to for on/off state.

So, for your need, set the group's Scene Child Device Behavior to "Switch" and set "Track Scene State" to on.

If you control your HUE devices outside of HE, turn on the refresh and set the timing to the longest delay you can tolerate. if you have more than a few groups, consider using the refresh interval of the hub device instead of the groups.

In my setup, I configure my echo devices to point to HE for Hue control, and do not integrate Hue to anything at all. If I need direct control of Hue I use the Hue app. Generally, I don't need that unless the HE hub is offline.

1 Like

Ok, Hubitat update: Check
Package Manager Install: Check
Repair Advanced Integration App: Check

Question: If I want to use the Motion and Mode Lighting app, I can't select the imported scenes. Should the advanced Hue scenes be available?

Scenes are in the device list:
grafik

The scenes are not selectable in the motion and mode lighting app
grafik

Thank you for your time!

Edit:

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.

That would mean, I cannot select the scenes as scenes, but would need to select them as switches. Am i correct?

In the motion lighting app, I can choose set scenes per mode, where I can choose which scenes comes with a specific mode.
With the switches it's a little bit different, I can choose which switch to turn on, and which modes. But all the selected mode would turn on all the selected switches.

Long story short: How do you guys control your motion lighting with modes and scenes?

You cannot select it as a "Scene", you must select it as a switch. There is no "Scene" type in HE that developers can create .. at least, none that are documented as such, as the scenes are HE momentary switches managed by the Groups and Scenes app. If anyone has idea on how to create 3rd party scenes, I would be happy to convert this logic over, but as best I can tell, treating them as switches is really the only way.

On motion, I turn on my scene. For my master bedroom, I have a few Hue Scenes for different times of the day. I use two mode based motion Rules. Master Bedroom Evening Light, and Master Bedroom Night Light. If the switches are off, then motion triggers the rules based on mode. The two rules are identical, except for the scene that is turned on.

Master Bedroom Evening Light

Master Bedroom Night Light

For my Front Yard accent lights, I do it differently. I have a rule with a variable "level" that is tied to a connector. I then use another rule to set the value of the connector based on time of day, and outdoor luminance. This is my Auto Dimming Manger - Outdoor Motion Lights rule. And then I have my Light Controller - Front Yard Motion Lights rule that triggers on motion, porch switch state change, and connector value change. Since the variable is local to this rule, I don't need to read the value, I simply set the level of my my front yard to 100% on motion, and set to the variable's level value on motion stop. This has the effect of turn all front yard lights to 100% when anyone moves in the front yard, lighting up the house really wlel. And when motion stops, I dim to different level. I use the scene to turn on the night light initially, (if from yard is off) then I use the connector level for mood lighting, and 100% for motion lighting.
The way my mood lighting works, is in mode "evening" or lux < 3000 then set level to 45. If mode is night, or (mode is evening and time > 2am) set level to 20, and if mode is not day and time > 4am then set level = 0 (off).

With HE 2.2.8 and the new hub variables, and connectors along with the new rules-5.0 I am in the middle of changing this logic, so I don't have rules to show you that work for this as described. If you want to see my rules, they are an adaptation of the original logic under legacy rules for now.

Ok, thanks for confirmation. That would mean, that with 5 modes I would need 5 rules instead of one. I have over 30 lights, that would end in too many rules...

I'm not a developer, so maybe this is useless:
With the groups and scene app one can create scene devices.

Maybe you could use this driver or something similar to create scenes instead of switches.

What exactly do you want to do? It sounds like you may want to use Rule Machine so that you can code your behaviors in a single rule with conditional actions. The limitation of mode and motion manager is that you cannot select a scene (or turn on a device) for each mode, in one rule. But, you can do that in Rule Machine. If you can tell me what you want, I can show you how to create the rule manager rule -- but that is outside the scope of my driver, or the scenes app.

Yes, and I do the same thing. I allow you to link a scene to a child device that turns the scene on. This is no different than the groups and scenes apps. I just cannot use HE's scene devices, I have to create my own.

You always have to option to use HE's hue integration, and scenes. But understand that they turn your lights in a group/scene on one-at-a-time because they are not Hue scene aware.

Armand

That's not entirely true IMO. You can select a scene for each mode in one rule. You cannot do the same with switches. That's why using switches instead of scene need more rules.

I'm very thankful for you to put your time and effort in this solution and to share this with others. My questions are not in any way criticism. I just sometime don't know, if the limitations lay in the technic or in my understanding of it. :grinning: that's why I ask.

For example: I have a bulb in the entry hall which I would like to behave differently, depending on the mode.

I would like to use different scenes, and also different shut off times.
For example: During Mode "Outdoor Party" I would like to shut off the light quickly after no motion is detected, to prevent mosquitos entering the house for their own party.

So
mode 1 ->motion-> scene 1 -> shut off time 1
mode 2 ->motion-> scene 2 -> shut off time 1
mode 3 ->motion-> scene 2 -> shut off time 2

on a greater scale: As a home automation noob I miss best practices. I think most user have some hue equipment, there should/could be a best practice to integrate it in HE. I thought using your outstanding integration app and the motion and mode lighting app.

I'm afraid of programming all the rules and learn afterwards there had been a better and quicker way.

That very well could be. I don't use HE scenes, because they are very slow to transition. I moved everything over to Hue, and so I use the Hue switch. That was an incorrect assumption of the rule based on my personal experience.

What you could do is put the Hue "scene" switch in a HE Scene. Then for the HE scene, it's just going to capture on/off state. So, activate the HE scene with motion, turn off the group with motion stop.

This is actually the use-case I created the Hue scene to solve, but in my home I never used it, because once everything was migrated (except my goodnight scene which has z-wave devices in it) I didn't need it. So I forget you can do this.

You cannot manipulate the Hue scene from the HE scene, but you can turn the scene on/off and you can group multiple hue scenes into a single HE scene if so desired.

I'm now trying different ways with the rules. I will report my experience. Thanks for your support

While using the AHI App I maybe found a litte bug.

I add lights -> lights added
I add groups -> groupd added
I add scenes -> I land at the site to add groups (that would be my bug)
I add scenes again (somehow difficult to navigate there) (they are now preselected) -> scenes added

Maybe you can reproduce this. thanks.

I am aware of this. I do not know how to solve this. The API for writing apps keeps track of last page. I am open to input from others. I have not been able to resolve this as the documentation for writing apps is non-existing. I have to rely on the SmartThings documentation which is similar but not identical. You can just click through to return to main screen for now.

I just updated the driver and app to support push notifications from the hue hub. Please update to hubitat 2.2.9 to leverage this feature.

2 Likes

Are there any limitations on what is pushed? Is it predominantly lights and maybe scenes? I assume accessories such as dimmers and motion sensors are not included (which is not a problem for me)?

Excellent question.

For this release it is lights, and groups. Scenes will be available when I figure out if that is possible.

Next release will be support for sensors and dimmers. Testing is already underway

1 Like