Data update failed, Bad Gateway
Closed this issue · 4 comments
Version of the custom_component
v1.4.0
Bestway device
Lay-z Spa Dominica Hydrojet
https://www.bestwaycorp.com/Product/Item?id=1060165XXX23
Describe the bug
I am currently investigating why my Home Assistant is constantly crashing:
In this process I am visiting the home-assistant.log.1 regularly and find the log includes errors from the Bestway integration (see below). This error repeats every few hours.
Maybe this log entries are totally unrelated to my HA crashes. However, I want to report here the issue for further investigation.
FYI: Otherwise updating and controlling my Bestway device with the integration works quite well. No issues I was aware of until now.
Logs
2024-02-13 23:00:47.171 ERROR (MainThread) [custom_components.bestway.coordinator] Data update failed
Traceback (most recent call last):
File "/config/custom_components/bestway/bestway/api.py", line 74, in _raise_for_status
api_error = await response.json()
^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/aiohttp_client.py", line 71, in json
return await super().json(*args, loads=loads, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1166, in json
raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8', url=URL('https://euapi.gizwits.com/app/bindings')
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 138, in refresh_bindings
device.device_id: device for device in await self._get_devices()
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/bestway/bestway/api.py", line 143, in _get_devices
api_data = await self._do_get(f"{self._api_root}/app/bindings")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/bestway/bestway/api.py", line 430, in _do_get
await _raise_for_status(response)
File "/config/custom_components/bestway/bestway/api.py", line 76, in _raise_for_status
response.raise_for_status()
File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1060, in raise_for_status
raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 502, message='Bad Gateway', url=URL('https://euapi.gizwits.com/app/bindings')
2024-02-13 23:00:47.202 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')
I'm also seeing this.
"Bad Gateway" is a server-side error, and not something the integration can do anything about. This sort of thing normally sorts itself out within a matter of hours, sometimes a few days.
FYI: I could track down the crash-causing component. It was not ha-bestway. :-)
Something else is going on here I believe. I have not been able to get this working at all after installing. The App is working fine but the integration is complaining. Has the App ID changed perhaps?
Edit: Added alternative user agent to default headers and now no longer getting bad gateway errors. Is Bestway blocking the default home assistant user agent? I'll raise a new issue for this.