siku2 / hass-weatherlink

Home Assistant integration for Davis Instruments' WeatherLink and AirLink
MIT License
26 stars 7 forks source link

Failed to get current conditions #19

Closed dhover closed 2 years ago

dhover commented 2 years ago

Now and then I get an error "failed to get current conditions ..." including a stack trace. Maybe it is a suggestion to remove the stack trace from the logfile or move the stack trace to the debug log level.

2022-03-18 11:34:44 WARNING (MainThread) [custom_components.weatherlink] failed to get current conditions, error 1 / 3
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 986, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore[return-value] # noqa
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1056, in create_connection
raise exceptions[0]
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1041, in create_connection
sock = await self._connect_sock(
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 955, in _connect_sock
await self.sock_connect(sock, address)
File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 502, in sock_connect
return await fut
File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 537, in _sock_connect_cb
raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('192.168.xxx.xxx', 80)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/config/custom_components/weatherlink/__init__.py", line 97, in __fetch_data
conditions = await self.session.current_conditions()
File "/config/custom_components/weatherlink/api/rest.py", line 73, in current_conditions
return await self._request(CurrentConditions, EP_CURRENT_CONDITIONS)
File "/config/custom_components/weatherlink/api/rest.py", line 68, in _request
async with self.session.get(self.base_url + path, params=params) as resp:
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 535, in _request
conn = await self._connector.connect(
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 542, in connect
proto = await self._create_connection(req, traces, timeout)
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 907, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection
raise last_exc
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 992, in _wrap_create_connection
raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 192.168.xxx.xxx:80 ssl:default [Connect call failed ('192.168.xxx.xxx', 80)]
siku2 commented 2 years ago

This really isn't meant to happen which is why the stack trace is included in the first place, but I think the weatherlink device is just too weak to handle all requests. I'm fine with dropping the log level for these intermediary errors down a notch.

siku2 commented 2 years ago

Reduced the clutter in v0.5.3.