Error while setting up platform spotify
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform
await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
return fut.result()
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/spotify/media_player.py", line 111, in setup_platform
token_info = oauth.get_cached_token()
File "/srv/homeassistant/lib/python3.6/site-packages/spotipy/oauth2.py", line 132, in get_cached_token
token_info = json.loads(token_info_string)
File "/usr/local/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.6/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Any hint?
edit: changed the title to reflect my current state, as wrote in this post
Are you using SSL? if so you need to change http to https.
Which version of home assistant are you using?
At which step did you get this error? You created an app in Spotify Developer, added the config to your configuration.yaml and then you received this error after restart?
digging down into the error I found that it was triggered when oauth in media_player.py takes the cached token as input.
I don’t understand where the .spotify-token-cache file is saved, so I modified media_player.py at line 43 in this way: DEFAULT_CACHE_PATH = ".spotify-token-cache_MODIFIED"
Then it went through the normal authorization process, but the output I get is this one:
INVALID_CLIENT: Failed to get client
You can’t just change the path for the spotify token cache file. The token file will be in the main configuration path and the file is called “.spotify-token-cache”, so if you change this the app will not be able to find the file and therefore it will not be able to authorize.
There has never been a .spotify-token-cache in /home/homeassistant/.homeassistant
In my previous testing I tried also to completely reset the app’s secrets, and it started giving the JSONDecodeError: my guess was that the information relative to the previous app’s secrets was cached somewhere, so I tried to point media_player.py to another, non-existent, cache file, and that worked because I was able to repeat the normal procedure from scratch.
After doing that I undid the modification, I’m staying with my current app’s secrets, but I don’t see a file called .spotify-token-cache anywhere, and I get the “INVALID_CLIENT: Failed to get client” error as mentioned above.
Normally this file will be generated once you do the authorization process in home assistant. That’s why it seems strange to me taht you get this error before you even start the authorization process.
hmm version .106 installed on Feb 26 2020 seems to cause some problems with bot ring and spotify. Spotify was working before but stopped to do so, log indicates a platform setup, bit it is not im my config.
Ring eems to be working normal with the same error
## Log Details (ERROR)
Logger: homeassistant.components.media_player
Integration: Media player ([documentation](https://www.home-assistant.io/integrations/media_player), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+media_player%22))
First occured: 4:47:59 PM (1 occurences)
Last logged: 4:47:59 PM
The spotify platform for the media_player integration does not support platform setup. Please remove it from your config.
I have he same issue as well. I upgraded to 2022.8, got the warning, removed the line from YAML. Tried installing Spotify app and got this as warning every time.
Steps I tried:
remove app from spotify dev and re-create it
remove home assistant from apps in your normal account.
looked for .spotify-token-cache and media_player.py but could not find them.
There are instructions for installing terminal and ssh here:
Only difference is that home assistant changed some things/location. Go to settings, add-ons, add-ons store, look for terminal & ssh and install it. After install click open web-ui. Then follow the instructions I made already.