home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.14k stars 29.81k forks source link

Hue = new resource type - `private_group` #110836

Closed RogerSelwyn closed 1 month ago

RogerSelwyn commented 6 months ago

The problem

My Hue integration has recently started taking longer than 10 seconds to start-up, so I investigated why. It seems to be because it is taking a long time to load Grouped Lights. There is a process that reties 5 times at 1/2 second intervals before timing out, and I appear to have 4 failing to be found.

Tracing back it seems that in the call to /clip/v2/resource it is finding grouped_light resources with and rtype of private_group, when it tries to retrieve more detail on them they can't be found, which I have checked by doing calls to groups/{{id}}, where that group cannot be found. The groups are ids 0, 81, 82, 83. I think group 0 which is of rtype bridge_home is different to the others in some way, but also fails after the 5 retrieval tries, but not dug into why.

For the other 3 groups (81-83), I'm pretty sure they are a new undocumented resource type (private_group) since they aren't in the docs groups_light here - https://developers.meethue.com/develop/hue-api-v2/api-reference/#resource_grouped_light__id__get

This is an example of the resource:-

        {
            "id": "e8e099e2-2d06-482b-bb49-7f2682aa3f0f",
            "id_v1": "/groups/81",
            "owner": {
                "rid": "0c1c0f35-6e65-47ae-8aa1-d98a34653ca7",
                "rtype": "private_group"
            },
            "on": {
                "on": false
            },
            "dimming": {
                "brightness": 0.0
            },
            "dimming_delta": {},
            "color_temperature": {},
            "color_temperature_delta": {},
            "alert": {
                "action_values": [
                    "breathe"
                ]
            },
            "signaling": {
                "signal_values": [
                    "no_signal",
                    "on_off"
                ]
            },
            "dynamics": {},
            "type": "grouped_light"
        },

I suspect it maybe due to the new timed based light switch control mechanism that Hue have added, but I can't be sure of this. I think that until these can be identified they should be ignored but not sure of the best way of doing this so I haven't raised a PR.

What version of Home Assistant Core has the issue?

core-2024.2.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

Hue

Link to integration documentation on our website

https://www.home-assistant.io/integrations/hue/

Diagnostics information

n/a

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2024-02-18 07:32:43.400 WARNING (MainThread) [homeassistant.components.light] Setup of light platform hue is taking over 10 seconds.

Additional information

No response

home-assistant[bot] commented 6 months ago

Hey there @balloob, @marcelveldt, mind taking a look at this issue as it has been labeled with an integration (hue) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `hue` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign hue` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


hue documentation hue source (message by IssueLinks)

marcelveldt commented 6 months ago

Interesting.. I have not seen these groups yet.

Do you have any reproduce steps for me how to create such an private_group on a hue bridge ?

marcelveldt commented 6 months ago

BTW: Nothing in the code is doing more calls to individual resource types. The full resource collection is received in one dump, there are no individual calls, unless you have any automations or whatever trying to do something with the entities. Maybe some code is crashing and the integration se-up is retrying and is that what you see ?

I'd like to see some logging of whatever you see with retrying and ofc doublecheck the HA core log if any issues are reported during loading of the Hue integration.

RogerSelwyn commented 6 months ago

I think they are zones I created in the Hue app. I think the problem only came up recently, not noticed the delay before, so did some debugging. To be honest not really sure. They don't appear in any of the debug type apps (iConnectHue/etc).

RogerSelwyn commented 6 months ago

I'm busy now, otherwise I'd debug again now. So I need to find where it is doing the loop in the Hue integration. It does do a look for the group to get the details on it, I just need to find here. Found it...

group.py/async_setup_entry lines 53-->

The get_zone fails on those resource id's after 1/2 second, but tries 5 times.

I'd have to validate that, but 95% sure it was there.

marcelveldt commented 6 months ago

Those are not API calls...

marcelveldt commented 6 months ago

ah, its waiting. for that group that never comes

RogerSelwyn commented 6 months ago

Yep

marcelveldt commented 6 months ago

Well, as I said before. You are the first to report this behavior and I have not seen this new group type in the wild. Please let me know what steps to take to create a group that has "private_group" as owner. Did you set any special automations in the Hue app ? Smart scenes ?

marcelveldt commented 6 months ago

Can you please send me the full diagnostics dump ? It contains all info I need to further diagnose this issue. The info in the dump is redacted btw, so there's no sensitive info in there.

Scherm­afbeelding 2024-03-11 om 15 12 29

RogerSelwyn commented 6 months ago

config_entry-hue-5cb65fdcbfde49efbad6c9a1e3e6e4a6.json

Diagnostics. If you need me to debug/dig into stuff I will be able to do it in the UK morning.

marcelveldt commented 6 months ago

So these are really just ghost groups - they do not exist at all according to all the other relationships. I'll update the aiohue library so we can filter them out.

RogerSelwyn commented 6 months ago

Excellent, thanks

RogerSelwyn commented 3 months ago

@marcelveldt do you know when this will get included into an HA release? It looks like there hasn't been an aiohue release since 4.7.1 in Feb, and I still have this problem in my environment.

RogerSelwyn commented 1 month ago

So these are really just ghost groups - they do not exist at all according to all the other relationships. I'll update the aiohue library so we can filter them out.

I've just updated to latest version of Dev which has aiohue 4.7.2 (I noticed Frenck merged the change this AM). I still have a delay showing on startup and the private groups showing when I download the diagnostics. config_entry-hue-4398069227527c349135ba5eadcf2a59.json