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
73.67k stars 30.8k forks source link

Philips Hue: RuntimeError: coroutine raised StopIteration #72829

Closed Mariusthvdb closed 2 years ago

Mariusthvdb commented 2 years ago

The problem

2 Hue Bridges, 1 wont connect anymore at startup

both are on Firmware: 1.51.1951086030 according top the app

did power cycle both bridges, and ofc restart HA a few times

What version of Home Assistant Core has the issue?

2022.7.0.dev20220601

What was the last working version of Home Assistant Core?

day before ;-)

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Philips Hue

Link to integration documentation on our website

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

Diagnostics information

not available:

Schermafbeelding 2022-06-01 om 15 43 36

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.hue.bridge
Source: components/hue/bridge.py:76 
Integration: Philips Hue (documentation, issues) 
First occurred: 15:31:17 (1 occurrences) 
Last logged: 15:31:17

Unknown error connecting to Hue bridge
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/controllers/base.py", line 253, in _handle_event
    callback(evt_type, cur_item)
  File "/usr/src/homeassistant/homeassistant/components/hue/scene.py", line 50, in async_add_entity
    async_add_entities([HueSceneEntity(bridge, api.scenes, resource)])
  File "/usr/src/homeassistant/homeassistant/components/hue/scene.py", line 94, in __init__
    self.group = self.controller.get_group(self.resource.id)
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/controllers/scenes.py", line 36, in get_group
    return next((x for x in self._bridge.groups if x.id == scene.group.rid))
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/hue/bridge.py", line 76, in async_initialize_bridge
    await self.api.initialize()
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/__init__.py", line 104, in initialize
    await self.fetch_full_state()
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/__init__.py", line 242, in fetch_full_state
    await asyncio.gather(
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/controllers/base.py", line 81, in initialize
    await self._handle_event(EventType.RESOURCE_ADDED, item)
RuntimeError: coroutine raised StopIteration

Logger: homeassistant.config_entries
Source: helpers/entity_component.py:157 
First occurred: 15:04:46 (5 occurrences) 
Last logged: 15:04:46

Error setting up entry Philips Hue 2 for binary_sensor
Error setting up entry Philips Hue 2 for light
Error setting up entry Philips Hue 2 for scene
Error setting up entry Philips Hue 2 for sensor
Error setting up entry Philips Hue 2 for switch
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 339, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/binary_sensor/__init__.py", line 167, in async_setup_entry
    return await component.async_setup_entry(entry)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 157, in async_setup_entry
    raise ValueError("Config entry has already been setup!")
ValueError: Config entry has already been setup!

Additional information

Note the above errors are confusing: the 2nd Bridge is configured and showing in the HA Dashboards, even though the config_entry error above is raised

Schermafbeelding 2022-06-01 om 15 11 46 Schermafbeelding 2022-06-01 om 15 11 55
probot-home-assistant[bot] commented 2 years ago

hue documentation hue source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years 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! (message by CodeOwnersMention)

Mariusthvdb commented 2 years ago

not sure if this is related in anyway, but another error is reported I now notice:

2022-06-01 16:09:14 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from supervisor (172.30.32.2). (HomeAssistantSupervisor/2022.05.dev3001 aiohttp/3.8.1 Python/3.9)

and Supervisor logs:

22-06-01 16:11:55 ERROR (MainThread) [supervisor.homeassistant.api] Error on call http://172.30.32.1:redacted/api/config: 
22-06-01 16:11:55 ERROR (MainThread) [supervisor.misc.tasks] Watchdog found a problem with Home Assistant API!

both bridges are gone now:

Schermafbeelding 2022-06-01 om 16 20 00

Google Home still controls the bridges nicely (via their own connection in the App)

Mariusthvdb commented 2 years ago

I tried to add another integration:

Schermafbeelding 2022-06-01 om 17 26 44 Schermafbeelding 2022-06-01 om 17 27 40

so, that s not good at all. finally decided to leave dev and upgraded to final beta of this cycle once again with ha core update --version 2022.6.0b7 which brought everything back!

Mariusthvdb commented 2 years ago

updated to 2022.7.0.dev20220602, and/or 2022.6.0/1 and all show the Hue devices on both my Bridges again, so this seems automatically fixed.

Ill wait a bit before closing if thats ok.

Mariusthvdb commented 2 years ago

ok so, glad I kept this open, it has happened twice after this again:

not much more to report other than I am using 2022.7.0.dev20220604 now. Another restart fixes it then. Maybe its simply a matter of timing during startup?

balloob commented 2 years ago

So what is happening here is that it seems like scenes are loaded before groups, which is causing a scene to reference a group that is not yet loaded. Now I'm not sure if a scene is allowed to point at non-existing groups but that sounds wrong.

marcelveldt commented 2 years ago

I think that's a question to ask Signify ? They are doing a few changes regarding the groups. Not 100% related but maybe this is a side effect? Strange though that it only happend on HA dev and the current 2022.6 release is fine ? I can't reproduce it either btw, I'll test my dev setup later this week.

Mariusthvdb commented 2 years ago

I havent seen this error for some time now, and was under the impression this had fixed it? https://github.com/home-assistant/core/pull/73145

this issue is the only one left open of the long list Nick mentions...

Might be for another reason Paulus mentions though?

marcelveldt commented 2 years ago

@Mariusthvdb have you seen this error again since then ? Can we close this issue ?

Mariusthvdb commented 2 years ago

No, didn't come back. Close!