Core: Spotify' object has no attribute 'playlist'

Created on 7 Feb 2020  ·  39Comments  ·  Source: home-assistant/core

The problem

Environment

  • Home Assistant release with the issue: 105.1
  • Last working Home Assistant release (if known): 104.x and below, old spotify integratoon
  • Operating environment (Hass.io/Docker/Windows/etc.): Home Assistant
  • Integration causing this issue: Spotify
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/spotify/

Problem-relevant configuration.yaml

spotify:
  client_id: !secret spotify_id
  client_secret: !secret spotify_secret

Traceback/Error logs

2020-02-07 11:29:48 ERROR (MainThread) [homeassistant.helpers.entity] Update for media_player.spotify fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 461, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/spotify/media_player.py", line 83, in wrapper
    result = func(self, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/components/spotify/media_player.py", line 338, in update
    self._playlist = self._spotify.playlist(current["context"]["uri"])
AttributeError: 'Spotify' object has no attribute 'playlist'
spotify

All 39 comments

@frenck , can you have a look at it, not urgent :-)

Hey there @frenck, mind taking a look at this issue as its been labeled with a integration (spotify) you are listed as a codeowner for? Thanks!

@pergolafabio have you followed the documentation and activated your account?

I'm having similar issues with the new integration. Rolling back the old integration still works as expected. I even created a new application on Spotify Dev to no avail.

@pergolafabio have you followed the documentation and activated your account?

Yeah, folllwed new installation steps, all is working and authorized with new callback url...
Everything also works as expected, just my log file is flooding when I am listening to spotify

@pergolafabio on which device are you playing the music? Please describe the problem more thoroughly and add it to the issue.

I am playing it on a Denon receiver with Spotify connect

i now tried the spotify webplayer, as soon as a start playing on my laptop, the error mesagges are beginning

Pffffff,

El dom., 9 de feb. de 2020, 3:51 a. m., pergolafabio <
[email protected]> escribió:

i now tried the spotify webplayer, as soon as a start playing on my
laptop, the error mesagges are beginning


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/home-assistant/home-assistant/issues/31582?email_source=notifications&email_token=AKU5V2POKYACSFKNS3UX343RB67XXA5CNFSM4KRMFV62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELGGMMI#issuecomment-583820849,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AKU5V2IPG7CV5DAECNJL64LRB67XXANCNFSM4KRMFV6Q
.

Thanks for reporting this in guys. I'll take a look if I can see what is going on.

Thnx in advance, am I the only one with issue? Since no one else is reply ing

I also have this issue, however it only affects one of my accounts, the other one works fine

I'm also having this issue. Spotify is sometimes not available and when its available would say it's idle, even though it's currently playing.

grafik

spotify: Error on device update! Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 304, in _async_add_entity await entity.async_device_update(warning=False) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 461, in async_device_update await self.hass.async_add_executor_job(self.update) File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/usr/src/homeassistant/homeassistant/components/spotify/media_player.py", line 83, in wrapper result = func(self, *args, **kwargs) File "/usr/src/homeassistant/homeassistant/components/spotify/media_player.py", line 338, in update self._playlist = self._spotify.playlist(current["context"]["uri"]) AttributeError: 'Spotify' object has no attribute 'playlist'

The problem for me right now, is that I'm unable to reproduce this.

I've tried the following:

  • Set up an integration with a premium account
  • Start a (private) playlist on the desktop client
  • Start a (public) playlist on the desktop client
  • Start an album on the desktop client
  • Start Spotify radio on the desktop client

I've repeated the above for the following as well:

  • Using a free Spotify account
  • Using a Sonos Beam
  • Using a Google Home
  • Using the webplayer
  • Using the mobile client
  • Using a playback initiated on a remote device
  • Using private & non-private sessions

(and a bunch of combinations from above).

my testings are with a premium account, testing when i start a playlist from chrome or if i use the receiver

what can i do to test or provide you more info ?

@frenck i'm not sure if my problem is related however i can't get the new integration to work either.
I end up getting this error everytime i start playback from a device

Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 424, in _async_add_entity await entity.async_update_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 284, in async_update_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 327, in _async_write_ha_state attr.update(self.state_attributes or {}) File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 793, in state_attributes for attr in ATTR_TO_PROPERTY File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 794, in <dictcomp> if getattr(self, attr) is not None File "/usr/src/homeassistant/homeassistant/components/spotify/media_player.py", line 160, in media_content_id return self._currently_playing.get("item", {}).get("name") AttributeError: 'NoneType' object has no attribute 'get'

No that is not related, @Waseh. Please don't stack things in a single issue. Please open up a separate issue for that. 👍

AttributeError: 'Spotify' object has no attribute 'playlist'

This error made me think. playlist is not an attribute to the Spotify object, but a method. So that message makes no sense. The only reason why Python would throw that error is when the methods & attributes both don't exist.

But that makes no sense, since well.. the method is hardcoded in the codebase, and thus cannot be missing.

This method, however, was introduced in Spotipy (the library used) 2.6.0+. The current version used by the integration is 2.7.1. The previous version of the integration did have an older version, which indeed does not have the playlist method.

So, that makes me think, do you guys have a possibly older version?
Are you using a custom component or integration that does something with Spotify? Maybe an issue with a virtual environment (if used)?

Are you using a custom component or integration that does something with Spotify?

I did. I also just recently installed the spotify-playlist-sensor.
I uninstalled it but now the integration doesn't list an entity to integrate.

grafik

I'm using Home Assistant via Docker running on Ubuntu 18.04.

I am going to unload the custom and try again this evening, keep you posted...

But maybe if I comment the sensor, maybe the spotipy will not update?

This custom component: https://github.com/dnguyen800/spotify-playlist-sensor
Will cause these issues for sure.

Uninstalled the custom component and also the two lovelace cards that @pergolafabio also used. Restarted Home Assistant a few times, reinitiated the integration a few times. But even with spotify-playlist-sensor removed I still got the error message from the beginning.

AttributeError: 'Spotify' object has no attribute 'playlist' in the logs.

media_player.spotify stuck in unavailable state

@holnburger If you are on Home Assistant Supervised or Operating System (previously called Hass.io), you will need to rebuild the core container to get rid of it.

hassio ha rebuild from the SSH add-on console.

I don't think that is the issue in my case. I'm running in docker and pip show spotipy outputs this

bash-5.0# pip show spotipy 
Name: spotipy
Version: 2.7.1
Summary: A light weight Python library for the Spotify Web API
Home-page: http://spotipy.readthedocs.org/
Author: @plamere
Author-email: [email protected]
License: LICENSE.md
Location: /usr/local/lib/python3.7/site-packages
Requires: six, requests
Required-by: 

I will try the custom component, with a changed requirement manually to new spotipy, that should resolve also?

@roflcoopter
pip show spotipy-homeassistant ? That would be the conflicting package.

@pergolafabio The problem is that the original spotipy-homeassistant might still be installed at that point.

Ok, I will try and keep you posted...
But that custom one should be updated with new requirement anyway? I'll create an issue there then

@roflcoopter
pip show spotipy-homeassistant ? That would be the conflicting package.

@pergolafabio The problem is that the original spotipy-homeassistant might still be installed at that point.

Bingo, Recreated my container and now it works

Still with that custom installed?

@holnburger If you are on Home Assistant Supervised or Operating System (previously called Hass.io), you will need to rebuild the core container to get rid of it.

hassio ha rebuild from the SSH add-on console.

This did solve it! It's working again! Thank you

/edit: Uninstalled the custom components before rebuilding.

i did a rebuild, it was succesfull
allthough issie is still happening

i cant do a pip ... , running hassos here, pip not found

what are my best steps?
unload the custom, restart hassos, rebuid, then load custom again?

You can't use the custom @pergolafabio, it will break things.

Crap, what needs to be done at the custom component to not have those errors then?

Contact the custom component creator? This is really out of scope for me and/or Home Assistant.
We don't support custom integrations in general.

Ok, Will do

Thnx in advance for the feedback

@frenck maybe off-topic, but isn't it possible maybe with the new integration you created to retrieve the playlists from Spotify, that's what the custom does... So then maybe we don't need the custom anymore at all

Was this page helpful?
0 / 5 - 0 ratings