cyberjunky / home-assistant-garmin_connect

The Garmin Connect integration allows you to expose data from Garmin Connect to Home Assistant.
MIT License
239 stars 35 forks source link

status update raises ConfigEntryNotReady #73

Open giachello opened 1 year ago

giachello commented 1 year ago

Hi there so I get this error. Apparently async_update calls Login, which raises ConfigEntryNotReady which I think only can be raised during component setup, not during an update. You may want to raise a different error in that case.

2023-03-14 19:30:56.236 ERROR (MainThread) [custom_components.garmin_connect] Connection error occurred during Garmin Connect login request: 520 Server Error:  for url: https://connect.garmin.com/modern/
2023-03-14 19:30:56.238 ERROR (MainThread) [custom_components.garmin_connect] Unexpected error fetching garmin_connect data: 520 Server Error:  for url: https://connect.garmin.com/modern/
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/garminconnect/__init__.py", line 71, in get
    response.raise_for_status()
  File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 520 Server Error:  for url: https://connect.garmin.com/modern/

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

Traceback (most recent call last):
  File "/config/custom_components/garmin_connect/__init__.py", line 70, in async_login
    await self.hass.async_add_executor_job(self._api.login)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.10/site-packages/garminconnect/__init__.py", line 251, in login
    return self.login_session()
  File "/usr/local/lib/python3.10/site-packages/garminconnect/__init__.py", line 273, in login_session
    response = self.sso_rest_client.get("login", params=params)
  File "/usr/local/lib/python3.10/site-packages/garminconnect/__init__.py", line 83, in get
    raise GarminConnectConnectionError(err) from err
garminconnect.GarminConnectConnectionError: 520 Server Error:  for url: https://connect.garmin.com/modern/

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 239, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/garmin_connect/__init__.py", line 109, in _async_update_data
    if not await self.async_login():
  File "/config/custom_components/garmin_connect/__init__.py", line 81, in async_login
    raise ConfigEntryNotReady from err
homeassistant.exceptions.ConfigEntryNotReady: 520 Server Error:  for url: https://connect.garmin.com/modern/
2023-03-14 19:37:27.152 ERROR (MainThread) [custom_components.garmin_connect] Connection error occurred during Garmin Connect login request: 520 Server Error:  for url: https://connect.garmin.com/modern/
2023-03-14 19:37:27.156 ERROR (MainThread) [custom_components.garmin_connect] Unexpected error fetching garmin_connect data: 520 Server Error:  for url: https://connect.garmin.com/modern/
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/garminconnect/__init__.py", line 71, in get
    response.raise_for_status()
  File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 520 Server Error:  for url: https://connect.garmin.com/modern/

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

Traceback (most recent call last):
  File "/config/custom_components/garmin_connect/__init__.py", line 70, in async_login
    await self.hass.async_add_executor_job(self._api.login)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.10/site-packages/garminconnect/__init__.py", line 251, in login
    return self.login_session()
  File "/usr/local/lib/python3.10/site-packages/garminconnect/__init__.py", line 273, in login_session
    response = self.sso_rest_client.get("login", params=params)
  File "/usr/local/lib/python3.10/site-packages/garminconnect/__init__.py", line 83, in get
    raise GarminConnectConnectionError(err) from err
garminconnect.GarminConnectConnectionError: 520 Server Error:  for url: https://connect.garmin.com/modern/

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 239, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/garmin_connect/__init__.py", line 109, in _async_update_data
    if not await self.async_login():
  File "/config/custom_components/garmin_connect/__init__.py", line 81, in async_login
    raise ConfigEntryNotReady from err
homeassistant.exceptions.ConfigEntryNotReady: 520 Server Error:  for url: https://connect.garmin.com/modern/
2023-03-14 19:44:29.445 ERROR (MainThread) [custom_components.garmin_connect] Connection error occurred during Garmin Connect login request: 504 Server Error: Gateway Time-out for url: https://connect.garmin.com/modern/
2023-03-14 19:44:29.449 ERROR (MainThread) [custom_components.garmin_connect] Unexpected error fetching garmin_connect data: 504 Server Error: Gateway Time-out for url: https://connect.garmin.com/modern/
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/garminconnect/__init__.py", line 71, in get
    response.raise_for_status()
  File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 504 Server Error: Gateway Time-out for url: https://connect.garmin.com/modern/

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

Traceback (most recent call last):
  File "/config/custom_components/garmin_connect/__init__.py", line 70, in async_login
    await self.hass.async_add_executor_job(self._api.login)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.10/site-packages/garminconnect/__init__.py", line 251, in login
    return self.login_session()
  File "/usr/local/lib/python3.10/site-packages/garminconnect/__init__.py", line 273, in login_session
    response = self.sso_rest_client.get("login", params=params)
  File "/usr/local/lib/python3.10/site-packages/garminconnect/__init__.py", line 83, in get
    raise GarminConnectConnectionError(err) from err
garminconnect.GarminConnectConnectionError: 504 Server Error: Gateway Time-out for url: https://connect.garmin.com/modern/

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 239, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/garmin_connect/__init__.py", line 109, in _async_update_data
    if not await self.async_login():
  File "/config/custom_components/garmin_connect/__init__.py", line 81, in async_login
    raise ConfigEntryNotReady from err
homeassistant.exceptions.ConfigEntryNotReady: 504 Server Error: Gateway Time-out for url: https://connect.garmin.com/modern/
cyberjunky commented 1 year ago

Good point, will have to investigate...