core
core copied to clipboard
Spotify integration works unreliable and often becomes "Unavailable"
The problem
I added integration with Spotify this morning, according to https://www.home-assistant.io/integrations/spotify/
It worked for a few hours without any issues, but now it became Unavailable at no particular moment, while I was playing a playlist from my mobile phone on my Pioneer X-HM36
Despite this it changes image of currently playing track.
Also it allows for playlist browsing without any issues.
Restarting the integration, nor reloading HA, nor restarting whole Raspberry Pi hardware running fixes the problem for now.
I am aware of issue #73319 but solutions provided there also do not work for me.
What version of Home Assistant Core has the issue?
core-2023.2.3
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
Spotify
Link to integration documentation on our website
https://www.home-assistant.io/integrations/spotify/
Diagnostics information
spotify_loogbook.txt spotify_loogbook_2.txt
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response
Hey there @frenck, mind taking a look at this issue as it has been labeled with an integration (spotify) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of spotify can trigger bot actions by commenting:
@home-assistant closeCloses the issue.@home-assistant rename Awesome new titleChange the title of the issue.@home-assistant reopenReopen the issue.@home-assistant unassign spotifyRemoves the current integration label and assignees on the issue, add the integration domain after the command.
(message by CodeOwnersMention)
spotify documentation spotify source (message by IssueLinks)
Anything in the logs when it happens?
Nothing more than what I included unfortunately... In that period of time I had debug logging not enabled... I enabled it now to see what is going on and no errors. Also no Spotify related errors in the log since I added the integration. Or maybe I am looking at wrong log files?
In that period of time I had debug logging not enabled...
The connection issue will still be logged, no debug logs are needed for that.
Or maybe I am looking at wrong log files?
Should show up in home-assistant.log
There are some entries but they are post-issue. spotofy_log_full.txt The issue happened at:
Became unavailable 6:38:48 PM - 2 hours ago
As referred to: spotify_loogbook.txt
Another observation. Now I stopped a playback controlled from my phone, and about 30 minutes later:
Changed to Idle 9:03:39 PM - 22 minutes ago
So I tried to set output to my HiFi (which is powered on and connected) and:
Became unavailable triggered by service media_player.select_source 9:23:05 PM - 2 minutes ago - Piotr Rzeszut
UPDATE:
Now the sequence is following:
- 9:33:09 PM -> tried to select an output device
- 9:37:09 PM -> started playback on my mobile phone
Changed to Idle 9:47:39 PM - 2 minutes ago Became unavailable 9:37:09 PM - 12 minutes ago Changed to Idle 9:33:09 PM - 16 minutes ago Became unavailable triggered by service media_player.select_source 9:23:05 PM - 26 minutes ago - Piotr Rzeszut Changed to Idle 9:03:39 PM - 1 hour ago
Nothing new spotify-related in .log file...
Update: In the morning it started responding again. As I started playback on the phone it detected new source and I was able to control it.
Then I switched using phone to my HiFi. It did not detect the source (select was empty). As I clicked next track it executed the command (track changed) but then it become unavailable again...
A little addition here, as I am (most probably) having the same issue. It started a few days ago.
I have a script that runs when my (silent) alarm on my phone goes off. Each time the spotify integration becomes available when triggering the script. It also sometimes happens when playing music on another device, but not always.
4 occurences
Wake up script triggered by alarm:
Spotify changed to Idle 09:06:35 - Yesterday Spotify became unavailable triggered by service script.wake_up 08:55:22 - Yesterday - Glivmo Spotify changed to Paused triggered by service script.wake_up 08:55:05 - Yesterday - Glivmo
Started playback in the car at 08:54, stopped at 09:08:
Spotify changed to Idle 09:08:39 - 9 hours ago Spotify became unavailable 08:54:09 - 9 hours ago
Started playback on my phone at 17:27, stopped at 17:47:
Spotify changed to Idle 17:47:41 - 21 minutes ago Spotify became unavailable 17:27:41 - 41 minutes ago
Manually turned on the wake_up script
Spotify became unavailable triggered by service script.turn_on 17:54:55 - 13 minutes ago - Glivmo Spotify changed to Paused triggered by service script.turn_on 17:54:39 - 14 minutes ago - Glivmo
The only error in the logs I could find was the following:
logs
2023-02-11 23:39:39.212 ERROR (MainThread) [homeassistant.helpers.entity] Update for media_player.spotify_glenn fails
Traceback (most recent call last):
File "~/homeassistant/helpers/entity.py", line 548, in async_update_ha_state
await self.async_device_update()
File "~/homeassistant/helpers/entity.py", line 746, 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 "~/homeassistant/components/spotify/media_player.py", line 89, in wrapper
result = func(self, *args, **kwargs)
File "~/homeassistant/components/spotify/media_player.py", line 359, in update
).result()
File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 458, in result
return self.__get_result()
File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
raise self._exception
File "~/homeassistant/helpers/config_entry_oauth2_flow.py", line 496, in async_ensure_token_valid
new_token = await self.implementation.async_refresh_token(self.token)
File "~/homeassistant/helpers/config_entry_oauth2_flow.py", line 92, in async_refresh_token
new_token = await self._async_refresh_token(token)
File "~/homeassistant/helpers/config_entry_oauth2_flow.py", line 182, in _async_refresh_token
new_token = await self._token_request(
File "~/homeassistant/helpers/config_entry_oauth2_flow.py", line 209, in _token_request
resp.raise_for_status()
File "/usr/local/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 1004, in raise_for_status
raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 503, message='Service Unavailable', url=URL('https://accounts.spotify.com/api/token')
Not sure if it helps, but thought I'd share as well.
Left the integration with debug mode for a day - will filter and include logs soon.
Hi, my spotify have become unavailable since I have updated from 20231.7 to 2023.2.4 (never happened in the last 2 years) , I cannot say if it's the same problem, I'm running HA on a RPi4 4gb with HA OS. Below the log from registry
I will try to uninstall the integration and install it again :( I know it will be a pain in the ars..
nothing changed after reinstall the integration (easier authentication anyway :) )
I have the same problem. It was running flawlessly for last few years but this morning it became unavailable ( niedostępna ) as soon as I do any action ( for example choose a source ). After a while it goes back to inactive ( nieaktywny ).
I have updated HA from 2023.2.3 to 2023.2.4 4 days ago, and now I'm on a 2023.2.5 and issue still persists.
I have tied to reinstall the integration with creating new Spotify app in developer page - no success.

Integration shows unavailable state, but when I have started Spotify app on my mobile, source list was updated with this device and some logs appeared: home-assistant_2023-02-18T11-37-20.369Z.log
It shows that integration is connected with Spotify but there is a problem with its state update.
Noticed now it works OK, but sometimes it get Unavailable for a second or two...
Also noticed, that when browsing history only limited number of tracks on playlist are visible (74 or 75 first ones for my very long playlist containing more than a 100...)
Logs from the time I faced issues: home-assistant_spotify_2023-02-18T13-03-35.822Z.log
Sadly, I'm still facing the issue.
@piotrva did You take any steps to resolve it or it just fixed itself ?
And it just had crashed in exactly same way...
Steps I took:
- Everything was working -> playback on Pioneer device
- Stopped playback using mobile
- Started playback using mobile -> in HA Spotify indicated that there is a playback
- Clicked on ... to see options
- Device select drop-down has an empty item selected
- Opened drop-down and selected Pioneer
- Playback stopped
- Pressed play button
- Became Unavailable
Became unavailable triggered by service media_player.media_pause
1:57:05 PM - 4 minutes ago - Piotr Rzeszut
Changed to Playing triggered by service media_player.select_source
1:57:02 PM - 4 minutes ago - Piotr Rzeszut
Changed to Idle
1:30:47 PM - 30 minutes ago
Changed to Paused
1:25:17 PM - 36 minutes ago
Unfortunately didn't have enabled debug enabled for spotify and there are literally no debug entries covering the time in log file...
I'm piggybacking here. The Spotify device becomes unavailable as soon as music starts playing. Integration worked fine before. The device will come back to Idle at some point if I stop playing music, but then will become unavailable again as soon as music starts playing. The device will not be available if there is anything playing/paused. Unfortunately the debug logs don't capture this.
It sounds like my issue is similar to @zollek. Did you ever find a solution?
My workaround here: https://github.com/fondberg/spotcast/issues/378#issuecomment-1445146707
It started to work today until I have tried to change the music and the source player on the mobile app. After that Spotify integration become alunavaible.
I'm thinking that the only solution will be moving to the Music Assistant :/
I am also having issues with spotify no longer working. I am running HA via docker and as soon as I upgraded to version 2022.3.x my spotify integration showed the same behaviour originally reported here (status showing as unavailable and no player commands e.g play/pause/next track). However the album art of the currently playing track was updating as usual and I am still able to browse my spotify media. Since this happened, I have rolled back my instance to 2023.1.x and it is all working fine again with no issues.
Is there any prospect of this getting fixed do we think? Liking the look of the new UI improvements in 2023.3 and would like to upgrade but the Spotify integration is fairly central to my setup...
I am also having issues with spotify no longer working. I am running HA via docker and as soon as I upgraded to version 2022.2.x my spotify integration showed the same behaviour originally reported here (status showing as unavailable and no player commands e.g play/pause/next track). However the album art of the currently playing track was updating as usual and I am still able to browse my spotify media. Since this happened, I have rolled back my instance to 2022.1.x and it is all working fine again with no issues.
Is there any prospect of this getting fixed do we think? Liking the look of the new UI improvements in 2022.3 and would like to upgrade but the Spotify integration is fairly central to my setup...
This is the same issue I'm having. I've downgraded to 2023.1.7 and it solved my problem.
I have just seen version 2023.3.1 have been release, no mention about a solution on this issue. I have disabled Spotify integration because often doesn't initialise and stop following integrations to be loaded. I am using Node red Spotify API as well and it looks like I don't have a reply sometimes. Maybe an API/Spotify dev login problem? Finger crossed for next update.
@frenck any thoughts on this? Did something happen after 2023.1.7 that might have affected the Spotify API?
Hello all,
I have the same problem. If I start via Spotify it works. If I want to switch shortly thereafter, it no longer works and it shows with not available. I wait about 15min, it works again. With version 2023.1.7 everything works fine. I have reinstalled and set up everything out of desperation. Without success.
Just want to bump this issue.
Still happening on 2023.4.0; as mentioned, playing from somewhere else fixes it
Spotify xxx xxx became unavailable triggered by service script.chill_tracks
2023-04-05 22:06:58.168 ERROR (SyncWorker_0) [spotipy.client] HTTP Error for GET to https://api.spotify.com/v1/playlists/0IpRnqCHSjun48oQRX1Dy7 with Params: {'fields': None, 'market': None, 'additional_types': 'track'} returned 404 due to Not found.
I did a downgrate to 2023.3.7 -> no more problems, Spotify works perfectly again!
I did a downgrate to 2023.3.7 -> no more problems, Spotify works perfectly again!
I assume you mean 2023.1.7? 2023.3.7 doesn't exist.
@frenck just wanted to ping you again, since this is a confirmed issue.
sorry, my mistake. - I mean 2023.1.7 of course.
Since Spotify is often unreliable I am using in my dashboard spotify API inside Node Red to show a track cover, it seems updating and working fine while the spotify entity is not available inside HA.
Check your playlists- the format seems to have changed for the link as have the identifiers for many of long-time playlists. This fixed it for me. It's no longer
spotify:playlist:longrandomstring but instead the raw version of what you get from "copy playlist link" works:
https://open.spotify.com/playlist/longrandomstring
Edit: the random strings are also different and... longer.
It looks to me like when I select a source, Spotify loses connection and goes into "Unavailable" mode
Is this the same for you?
Does anyone have experience with this and have a workaround?
Home Assistant 2023.4.6 Supervisor 2023.04.1