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.56k stars 30.74k forks source link

Ambient Weather integration won't load after upgrading to 2023.3.5 #89834

Closed W7RZL closed 1 year ago

W7RZL commented 1 year ago

The problem

After updating from 2023.2.4 to 2023.3.5, the Ambient Weather integration is failing to load. From the traceback, it looks like a problem establishing a websocket connection.

What version of Home Assistant Core has the issue?

core-2023.3.5

What was the last working version of Home Assistant Core?

core-2023.2.4

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Ambient Weather

Link to integration documentation on our website

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

Diagnostics information

Stack trace below - I didn't want to upload logs that contain my API keys.

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2023-03-16 18:06:25.052 INFO (MainThread) [aioambient] Attempting WebSocket connection to wss://rt2.ambientweather.net/socket.io/?api=1&applicationKey=<redacted>&transport=websocket&EIO=3
2023-03-16 18:07:51.913 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry 406c9da82f96 for ambient_station
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 383, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/ambient_station/__init__.py", line 76, in async_setup_entry
    await ambient.ws_connect()
  File "/usr/src/homeassistant/homeassistant/components/ambient_station/__init__.py", line 195, in ws_connect
    await self.websocket.connect()
  File "/usr/local/lib/python3.10/site-packages/aioambient/websocket.py", line 156, in connect
    await self._sio.connect(
  File "/usr/local/lib/python3.10/site-packages/socketio/asyncio_client.py", line 109, in connect
    await self.eio.connect(url, headers=headers,
  File "/usr/local/lib/python3.10/site-packages/engineio/asyncio_client.py", line 111, in connect
    return await getattr(self, '_connect_' + self.transports[0])(
  File "/usr/local/lib/python3.10/site-packages/engineio/asyncio_client.py", line 306, in _connect_websocket
    ws = await self.http.ws_connect(
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 779, in _ws_connect
    resp = await self.request(
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 536, in _request
    conn = await self._connector.connect(
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 540, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 901, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore[return-value]  # noqa
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1060, in create_connection
    sock = await self._connect_sock(
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 969, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 501, in sock_connect
    return await fut
asyncio.exceptions.CancelledError

Additional information

No response

home-assistant[bot] commented 1 year ago

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

Code owner commands Code owners of `ambient_station` 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 ambient_station` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


ambient_station documentation ambient_station source (message by IssueLinks)

bachya commented 1 year ago

I'm not seeing this—I just upgraded to 2023.3.5 and my Ambient PWS integration loaded fine. Here's a screenshot from a moment ago:

CleanShot 2023-03-17 at 16 45 16@2x

Can you confirm that your weather station console is connected to your network (and transmitting data)?

W7RZL commented 1 year ago

Thanks for taking a look... my weather station is online and is updating regularly: https://ambientweather.net/dashboard/93bfe873a1e4e396a3210b15c7eafdcb

Anything else I can try to troubleshoot?

bachya commented 1 year ago

The next step would be to enable debug-level logging for both the Ambient integration and the underlying library:

logger:
  default: info
  logs:
    homeassistant.components.ambient_station: debug
    aioambient: debug

Then, restart HASS. If the issue occurs again, paste the logs back here and I can investigate further.

W7RZL commented 1 year ago

Uh, hmmm - now it is working. I've been rebooting, restarting, etc. since the problem started and nothing changed. This morning, after restarting, it works. How very strange...

2023-03-18 09:21:13.376 INFO (MainThread) [aioambient] Attempting WebSocket connection to wss://rt2.ambientweather.net/socket.io/?api=1&applicationKey=...&transport=websocket&EIO=32
2023-03-18 09:21:14.994 INFO (MainThread) [aioambient] WebSocket connection accepted with {'sid': '57l7Y1-x0C9G81JLBCvD', 'upgrades': [], 'pingInterval': 25000, 'pingTimeout': 20000}
2023-03-18 09:21:14.994 INFO (MainThread) [aioambient] Engine.IO connection established
2023-03-18 09:21:15.035 INFO (MainThread) [aioambient] Sending packet PING data None
2023-03-18 09:21:15.035 INFO (MainThread) [aioambient] Received packet MESSAGE data 0
2023-03-18 09:21:15.058 INFO (MainThread) [aioambient] Namespace / is connected
2023-03-18 09:21:15.058 INFO (MainThread) [aioambient] Emitting event "subscribe" [/]
2023-03-18 09:21:15.058 INFO (MainThread) [aioambient] Sending packet MESSAGE data 2["subscribe",{"apiKeys":["..."]}]
2023-03-18 09:21:15.058 INFO (MainThread) [aioambient] Watchdog triggered – sleeping for 900 seconds
2023-03-18 09:21:15.125 INFO (MainThread) [aioambient] Received packet PONG data None
2023-03-18 09:21:15.125 INFO (MainThread) [aioambient] Received packet MESSAGE data 2["subscribed",{"devices":[ ... good data ...],"method":"subscribe"}]
2023-03-18 09:21:15.148 INFO (MainThread) [aioambient] Received event "subscribed" [/]

I removed the debug logging, restarted and all is still good. Thanks for your attention!

bachya commented 1 year ago

Strange! Perhaps some flakiness in their cloud. Glad it's resolved. 👍🏻