spotcast: I get these errors every day and often during the day

Every day i get these errors in the log:

2023-03-22 07:00:08.782 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.playlists_sensor fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 489, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 878, in urlopen
    return self.urlopen(
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 878, in urlopen
    return self.urlopen(
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 878, in urlopen
    return self.urlopen(
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 868, in urlopen
    retries = retries.increment(method, url, response=response, _pool=self)
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.spotify.com', port=443): Max retries exceeded with url: /v1/me/playlists?limit=40&offset=0 (Caused by ResponseError('too many 502 error responses'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/spotipy/client.py", line 264, in _internal_call
    response = self._session.request(
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 556, in send
    raise RetryError(e, request=request)
requests.exceptions.RetryError: HTTPSConnectionPool(host='api.spotify.com', port=443): Max retries exceeded with url: /v1/me/playlists?limit=40&offset=0 (Caused by ResponseError('too many 502 error responses'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 541, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 739, in async_device_update
    raise exc
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/spotcast/sensor.py", line 116, in update
    resp = self.hass.data[DOMAIN]["controller"].get_playlists(
  File "/config/custom_components/spotcast/spotcast_controller.py", line 333, in get_playlists
    resp = client.current_user_playlists(limit=limit)
  File "/usr/local/lib/python3.10/site-packages/spotipy/client.py", line 635, in current_user_playlists
    return self._get("me/playlists", limit=limit, offset=offset)
  File "/usr/local/lib/python3.10/site-packages/spotipy/client.py", line 321, in _get
    return self._internal_call("GET", url, payload, kwargs)
  File "/usr/local/lib/python3.10/site-packages/spotipy/client.py", line 305, in _internal_call
    raise SpotifyException(
spotipy.exceptions.SpotifyException: http status: 429, code:-1 - /v1/me/playlists?limit=40&offset=0:
 Max Retries, reason: too many 502 error responses

Make sure to validate all the elements before submitting the ticket (Exception to the steps marked as optional)

  • [x ] Using latest version of spotcast
  • Using latest stable version of Home Assistant
  • [x ] I have setup the Spotify integration in Home Assistant
  • [x ] I have renewed my sp_dc and sp_key values and restarted Home Assistant (see README)
  • [x ] (optional) I have Spotify Premium
  • (optional) I am using multiple accounts
  • (optional) I’m attaching relevant logs with level debug for component spotcast (see README)
  • (optional) I’m using entity_id in the service call and have tried device_name but the issue remains

Environment

  • Installation type: [HA_OS]
  • HA version: [2022.3.5 ]
  • spotcast version: [latest ]

About this issue

Most upvoted comments

build 34 released

requests.exceptions.RetryError

Missed that error when building the Retry Supervisor. That’s just a question of adding it to the list