cdpuk / ha-bestway

Home Assistant integration for Bestway / Lay-Z-Spa hot tubs
MIT License
59 stars 15 forks source link

Data update failed #33

Closed woopstar closed 10 months ago

woopstar commented 11 months ago

I'm getting this error a lot lately:

2023-08-02 14:16:31.324 ERROR (MainThread) [custom_components.bestway.coordinator] Data update failed
Traceback (most recent call last):
  File "/config/custom_components/bestway/bestway/api.py", line 392, in _do_get
    response = await self._session.get(url, headers=headers)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 560, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 899, in start
    message, payload = await protocol.read()  # type: ignore[union-attr]
                       ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 616, in read
    await self._waiter
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/bestway/coordinator.py", line 36, in _async_update_data
    await self.api.refresh_bindings()
  File "/config/custom_components/bestway/bestway/api.py", line 140, in refresh_bindings
    device.device_id: device for device in await self._get_devices()
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/bestway/bestway/api.py", line 147, in _get_devices
    api_data = await self._do_get(f"{self._api_root}/app/bindings", headers)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/bestway/bestway/api.py", line 391, in _do_get
    async with async_timeout.timeout(_TIMEOUT):
  File "/usr/local/lib/python3.11/site-packages/async_timeout/__init__.py", line 129, in __aexit__
    self._do_exit(exc_type)
  File "/usr/local/lib/python3.11/site-packages/async_timeout/__init__.py", line 212, in _do_exit
    raise asyncio.TimeoutError
TimeoutError
2023-08-02 14:16:31.328 ERROR (MainThread) [custom_components.bestway.coordinator] Error fetching Bestway API data: Error communicating with API: 
2023-08-02 14:20:31.572 ERROR (MainThread) [custom_components.bestway.coordinator] Data update failed
Traceback (most recent call last):
  File "/config/custom_components/bestway/coordinator.py", line 36, in _async_update_data
    await self.api.refresh_bindings()
  File "/config/custom_components/bestway/bestway/api.py", line 140, in refresh_bindings
    device.device_id: device for device in await self._get_devices()
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/bestway/bestway/api.py", line 147, in _get_devices
    api_data = await self._do_get(f"{self._api_root}/app/bindings", headers)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/bestway/bestway/api.py", line 393, in _do_get
    response.raise_for_status()
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1005, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 502, message='Bad Gateway', url=URL('https://euapi.gizwits.com/app/bindings')
2023-08-02 14:20:31.573 ERROR (MainThread) [custom_components.bestway.coordinator] Error fetching Bestway API data: Error communicating with API: 502, message='Bad Gateway', url=URL('https://euapi.gizwits.com/app/bindings')
cdpuk commented 10 months ago

502 Bad Gateway indicates an error at the server side. Unfortunately there's nothing the integration can do about that.

woopstar commented 10 months ago

Unfortunately there's nothing the integration can do about that.

At least maybe handle the Python exception? Is there any reason to print the whole stack trace into the log if you cannot do anything anyway?