Spotify - Playlists are not retrieved/displayed

Hello :blush:

I have a problem with the Spotify integration.
I was able to set everything up, can play music from Spotify on my Alexas etc.
However, my playlists are not retrieved/displayed and I get the following info:

Screenshot 2024-03-27 101857

Have you checked the log files for any errors? (Settings > System > Logs)

Logger: homeassistant.components.websocket_api.http.connection
Quelle: components/spotify/util.py:24
Integration: Home Assistant WebSocket API (Dokumentation, Probleme)
Erstmals aufgetreten: 26. März 2024 um 19:55:16 (9 Vorkommnisse)
Zuletzt protokolliert: 19:54:32

[140196148944192] Error handling message: Unknown error (unknown_error) Zuhause from 127.0.0.1 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36)
[140196523020096] Error handling message: Unknown error (unknown_error) Zuhause from 127.0.0.1 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36)
[140196225029824] Error handling message: Unknown error (unknown_error) Zuhause from 127.0.0.1 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36)
[140196414963520] Error handling message: Unknown error (unknown_error) Zuhause from 127.0.0.1 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36)
[140196055834176] Error handling message: Unknown error (unknown_error) Zuhause from 127.0.0.1 (Mozilla/5.0 (Linux; Android 14; SM-F936B Build/UP1A.231005.007; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/122.0.6261.119 Mobile Safari/537.36 Home Assistant/2024.1.5-12102 (Android 14; SM-F936B))
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 1310, in websocket_browse_media
    payload = await player.async_browse_media(media_content_type, media_content_id)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/spotify/media_player.py", line 472, in async_browse_media
    return await async_browse_media_internal(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/spotify/browse_media.py", line 225, in async_browse_media_internal
    response = await hass.async_add_executor_job(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/spotify/browse_media.py", line 390, in build_item_response
    item_payload(item, can_play_artist=can_play_artist)
  File "/usr/src/homeassistant/homeassistant/components/spotify/browse_media.py", line 439, in item_payload
    browse_media.thumbnail = fetch_image_url(item)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/spotify/util.py", line 24, in fetch_image_url
    return item.get(key, [])[0].get("url")
           ~~~~~~~~~~~~~~~~~^^^
TypeError: 'NoneType' object is not subscriptable

I use the “normal” Spotify integration of Home Assistant.
Can this integration retrieve the playlist natively, without further settings?

I read something about Spotcast, do I need that?

AFAIK, it should pull back playlists in the media browser (when launcher from a media player card). I’m not sure what’s up with the error messages. I’m assuming you setup your developer account successfully?

I use a Spotify premium subscription and I can see all my playlists, so I’m not sure what’s going on there.

@Psicrow925 @code-in-progress
FYI - I created a SpotifyPlus integration that has built-in media browser support, provides near real-time UI updates (using smart polling), a ton of custom services (including playlist retrieval), and much more. Check out the links below for more information.

As for your problem … based on the logs you provided, it appears that one or more of your playlists are missing a cover image; the fetch_image_url method is failing because it assumes there is an item at the zero index position, and there is not (proven by the TypeError: 'NoneType' object is not subscriptable exception).

Hope it helps!

More Information Links

1 Like

@code-in-progress @thlucas

Thank you very much for your answers and for supporting me with this problem.

Thanks for the hint with the covers, this could be the solution.
I have created some playlists, but no songs in them yet and therefore no cover picture.
I will test this right away.

I’ll have a look at your Spotify Plus integration, thanks for the tip.

2 Likes

@Psicrow925
Glad I could help.

FYI … I just verified that was the issue. I created an empty playlist with no cover image, and the built-in Spotify integration returned the “Unknown Error” dialog and the TypeError: 'NoneType' object is not subscriptable log message.

I wanted to make sure my SpotifyPlus integration could handle it (and it did). :smiley:

1 Like

The missing covers were the problem.
Many thanks for your help :blush:

1 Like