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.03k stars 30.55k forks source link

Errors Started Appearing with Hue Bridge #70086

Closed gcoupe closed 2 years ago

gcoupe commented 2 years ago

The problem

I have a Philips Hue Bridge connected to HA with the Philips Hue integration. While the Bridge and HA are on 24/7, the Bridge is connected to a network switch that powers off at midnight and powers on at 08:00am (together with AV equipment that is on the same mains feed). Up until recently, this has not been an issue - naturally I get errors in the HA logs reporting loss of connectivity, but these can be ignored.

However, recently, new errors are being reported, and these have the effect of disabling the Hue integration, and I need to restart HA every day to get the integration working again. Something seems to have changed in recent HA builds to cause these errors.

I suspect it is the second error (see below) that is causing the integration to fail...

What version of Home Assistant Core has the issue?

core-2022.4.1 (but it has been present with recent builds also)

What was the last working version of Home Assistant Core?

No response

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

Screenshot 2022-04-15 121256

Example YAML snippet

No response

Anything in the logs that might be useful for us?

There are two errors. The first:

Logger: homeassistant.config_entries
Source: helpers/entity_component.py:172
First occurred: 08:00:05 (5 occurrences)
Last logged: 08:00:05

Error unloading entry Philips hue for binary_sensor
Error unloading entry Philips hue for light
Error unloading entry Philips hue for scene
Error unloading entry Philips hue for sensor
Error unloading entry Philips hue for switch
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 474, in async_unload
    result = await component.async_unload_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/binary_sensor/__init__.py", line 173, in async_unload_entry
    return await component.async_unload_entry(entry)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 172, in async_unload_entry
    raise ValueError("Config entry was never loaded!")
ValueError: Config entry was never loaded!

and the second:

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

Unknown error connecting to Hue bridge
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/yarl/_url.py", line 170, in __new__
    port = val.port
  File "/usr/local/lib/python3.9/urllib/parse.py", line 178, in port
    raise ValueError(message) from None
ValueError: Port could not be cast to integer value as ':eeb5:faff:fe84:b17d'

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 422, in _request
    url = self._build_url(str_or_url)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 356, in _build_url
    url = URL(str_or_url)
  File "/usr/local/lib/python3.9/site-packages/yarl/_url.py", line 172, in __new__
    raise ValueError(
ValueError: Invalid URL: port can't be converted to integer

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 241, in fetch_full_state
    full_state = await self.request("get", "clip/v2/resource")
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/__init__.py", line 165, in request
    async with self.create_request(method, path, **kwargs) as resp:
  File "/usr/local/lib/python3.9/contextlib.py", line 181, in __aenter__
    return await self.gen.__anext__()
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/__init__.py", line 207, in create_request
    async with self._websession.request(method, url, **kwargs) as res:
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 1138, in __aenter__
    self._resp = await self._coro
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 424, in _request
    raise InvalidURL(str_or_url) from e
aiohttp.client_exceptions.InvalidURL: https://fd00::eeb5:faff:fe84:b17d/clip/v2/resource

Additional information

No response

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)

marcelveldt commented 2 years ago

Hmm, it seems it want to use the IPv6 address somehow. First time I've seen that happening. First of all I don't know if the bridge is even IPv6 ready and secondly the address is wrongly formatted, there should be brackets around it.

Question is where does this IPv6 address come from ?

gcoupe commented 2 years ago

Here's the connectivity error message, perhaps a clue here?

Logger: aiohue.v2[192.168.178.146].events Source: /usr/local/lib/python3.9/site-packages/aiohue/v2/controllers/events.py:239 First occurred: 00:17:41 (16 occurrences) Last logged: 07:27:05

120 Attempts to (re)connect to bridge failed - This might be an indication of connection issues. 130 Attempts to (re)connect to bridge failed - This might be an indication of connection issues. 140 Attempts to (re)connect to bridge failed - This might be an indication of connection issues. 150 Attempts to (re)connect to bridge failed - This might be an indication of connection issues. 160 Attempts to (re)connect to bridge failed - This might be an indication of connection issues.

gcoupe commented 2 years ago

My home network is setup using a Fritz!Box 7530. I'm not using IPv6 in the network (although the 7530 can handle it). I have got the Fritz!Box integration for HA installed. Perhaps something has changed there?

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

balloob commented 2 years ago

Both the SSDP and Zeroconf steps in the Hue config flow will update existing entries when a discovery comes in.

balloob commented 2 years ago

I wonder if the hub will adopt an IPv6 IP because it is unable to reach the DHCP server / it doesn't update it's mDNS/SSDP broadcasts right away with it's new IP.

gcoupe commented 2 years ago

Even though the switch continues to be powered down each night, the past couple of days have been error-free (apart from the expected connectivity errors when the switch is powered down), and the Hue Integration continues to be up and running. I have no idea why the new errors have stopped...

gcoupe commented 2 years ago

And... the errors are back again...

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

Unknown error connecting to Hue bridge
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/yarl/_url.py", line 170, in __new__
    port = val.port
  File "/usr/local/lib/python3.9/urllib/parse.py", line 178, in port
    raise ValueError(message) from None
ValueError: Port could not be cast to integer value as ':eeb5:faff:fe84:b17d'

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 422, in _request
    url = self._build_url(str_or_url)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 356, in _build_url
    url = URL(str_or_url)
  File "/usr/local/lib/python3.9/site-packages/yarl/_url.py", line 172, in __new__
    raise ValueError(
ValueError: Invalid URL: port can't be converted to integer

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 241, in fetch_full_state
    full_state = await self.request("get", "clip/v2/resource")
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/__init__.py", line 165, in request
    async with self.create_request(method, path, **kwargs) as resp:
  File "/usr/local/lib/python3.9/contextlib.py", line 181, in __aenter__
    return await self.gen.__anext__()
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/__init__.py", line 207, in create_request
    async with self._websession.request(method, url, **kwargs) as res:
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 1138, in __aenter__
    self._resp = await self._coro
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 424, in _request
    raise InvalidURL(str_or_url) from e
aiohttp.client_exceptions.InvalidURL: https://fd00::eeb5:faff:fe84:b17d/clip/v2/resource