Open rwjack opened 3 months ago
Hey there @frenck, @joostlek, 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!
(message by CodeOwnersMention)
spotify documentation spotify source (message by IssueLinks)
Logger: spotipy.client Source: components/spotify/media_player.py:415 First occurred: 12:30:00 (1 occurrences) Last logged: 12:30:00
HTTP Error for GET to https://api.spotify.com/v1/me/player with Params: {'market': None, 'additional_types': [<MediaType.EPISODE: 'episode'>]} returned 401 due to None
Same happens to me, started few days ago without having made any changes, I am on HA 2024.7.3
same, on HA 2024.7.4
Same here with 2024.7.4
Spotify is phasing out old username/password authorisation. Maybe this issue is related https://github.com/librespot-org/librespot/issues/1308#issuecomment-2276196094
Spotify is phasing out old username/password authorisation. Maybe this issue is related librespot-org/librespot#1308 (comment)
@erkr but i followed the config flow of integration page and use client id and secret, then I would say as a rookie why would username/password changes affect this?
Just depends if this integration used librespot.
@erkr No idea I just use the build in spotify integration of HA core
@erkr we use Spotify. I'm not sure where this comes from tbh. I'm assuming that this is because of a flakey service at Spotify
I not know if helps but at me at same time when I get the same error message as the OP I also get this error message
Logger: homeassistant.helpers.entity Source: helpers/entity.py:944 First occurred: 11:10:34 (18 occurrences) Last logged: 17:43:06
Update for media_player.spotify_sesamemadness_2 fails Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/spotipy/client.py", line 271, in _internal_call response.raise_for_status() File "/usr/local/lib/python3.12/site-packages/requests/models.py", line 1024, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.spotify.com/v1/me/player?additional_types=episode
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/spotify/media_player.py", line 98, in wrapper result = func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/spotify/media_player.py", line 415, in update current = self.data.client.current_playback( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/spotipy/client.py", line 1757, in current_playback return self._get("me/player", market=market, additional_types=additional_types) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/spotipy/client.py", line 323, in _get return self._internal_call("GET", url, payload, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/spotipy/client.py", line 293, in _internal_call raise SpotifyException( spotipy.exceptions.SpotifyException: http status: 401, code:-1 - https://api.spotify.com/v1/me/player?additional_types=episode: None, reason: None
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 944, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1298, in async_device_update await hass.async_add_executor_job(self.update) 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/media_player.py", line 106, in wrapper raise HomeAssistantError(f"Spotify error: {exc.reason}") from exc homeassistant.exceptions.HomeAssistantError: Spotify error: None
It's the same
@joostlek librespot is impacted by removal of username/password logins in Spotify (used by e.g music assistant). You are using spotipy, which seems to use Oauth, which should be fine, so ignore my remark 🫣
@erkr we use Spotify. I'm not sure where this comes from tbh. I'm assuming that this is because of a flakey service at Spotify
Not sure if flaky or just no longer valid. Logs have been filling up for every SPotify account in my HA with the following:
2024-08-12 07:59:52.507 ERROR (SyncWorker_44) [spotipy.client] HTTP Error for GET to https://api.spotify.com/v1/me/player with Params: {'market': None, 'additional_types': [<MediaType.EPISODE: 'episode'>]} returned 401 due to None
and
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.spotify.com/v1/me/player?additional_types=episode
looks like something might have changed around episodes?
It's not specifically episodes, that's just us telling to the API we support podcasts in the response.
I'm seeing this error as well -- if it helps, I've only started seeing this error after upgrading from HA 2024.1.6 to 2024.8 (I'm running the container, in Docker, on Debian 12).
It doesn't seem to be a fatal error, or at least, it doesn't seem to impact most of my Spotify usage -- I have an automation that plays a playlist, and an automation that plays a song, and they both seem to generally be working fine.
Please let me know if there's any additional information that might help.
One other thing I've noticed is that all of these errors that I've seen always seem to be in relation to Sonos, and particularly this media_player.spotify_sonos
entity, e.g.:
2024-08-12 09:55:59.326 ERROR (SyncWorker_2) [spotipy.client] HTTP Error for GET to https://api.spotify.com/v1/me/player/devices with Params: {} returned 401 due to None
2024-08-12 09:55:59.327 ERROR (MainThread) [homeassistant.components.spotify] Error fetching Sonos Devices data:
2024-08-12 09:59:59.297 ERROR (SyncWorker_2) [spotipy.client] HTTP Error for GET to https://api.spotify.com/v1/me/player with Params: {'market': None, 'additional_types': [<MediaType.EPISODE: 'episode'>]} returned 401 due to None
2024-08-12 09:59:59.298 ERROR (MainThread) [homeassistant.helpers.entity] Update for media_player.spotify_sonos fails
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/spotipy/client.py", line 271, in _internal_call
response.raise_for_status()
File "/usr/local/lib/python3.12/site-packages/requests/models.py", line 1024, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.spotify.com/v1/me/player?additional_types=episode
I have ~10 Sonos speakers integrated with HA and Spotify, and they all seem to be working in my testing, it's just this media_player.spotify_sonos
entity that I'm seeing these errors for.
not sure if there were any changes, but I stopped getting this Error
not sure if there were any changes, but I stopped getting this Error
Same here. I haven't seen any of these errors since August 13th, and I have not made any changes on my side in the meantime (same HA container image version, in fact, I haven't even recreated the container since then).
The errors are back again, and it's worse, this time it is not possible to control the player anymore. Logs say: "No active device found". I even tried resetting the homeassistant Spotify integration (deleted it, set it up new).
Logger: spotipy.client
Quelle: components/spotify/media_player.py:318
HTTP Error for PUT to https://api.spotify.com/v1/me/player/pause with Params: {} returned 404 due to Player command failed: No active device found
Logger: homeassistant.components.websocket_api.http.connection
Quelle: components/websocket_api/commands.py:241
Integration: Home Assistant WebSocket API ([Dokumentation](https://www.home-assistant.io/integrations/websocket_api), [Probleme](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+websocket_api%22))
Erstmals aufgetreten: 18:27:12 (1 Vorkommnisse)
Zuletzt protokolliert: 18:27:12
[140349711566304] Unexpected exception
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 241, in handle_call_service
response = await hass.services.async_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2763, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2806, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 999, in entity_service_call
single_response = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1071, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 822, in async_media_pause
await self.hass.async_add_executor_job(self.media_pause)
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/media_player.py", line 105, in wrapper
raise HomeAssistantError("No active playback device found") from None
homeassistant.exceptions.HomeAssistantError: No active playback device found
I'm now seeing HTTP Error for GET to https://api.spotify.com/v1/me/player/devices returned 401 due to Permissions missing
in the logs.
This seems to be related to application scopes.
I removed the service and re-added it, and now I have the following in the logs:
spotify: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 724, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1302, in async_device_update
await hass.async_add_executor_job(self.update)
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/media_player.py", line 98, in wrapper
result = func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/spotify/media_player.py", line 411, in update
current = self.data.client.current_playback(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Spotify.current_playback() got an unexpected keyword argument 'additional_types'
This is running HA 2024.9.3 on supervisor 2024.9.1 with HAOS 13.1
Please try again in 2024.11 as last release contained a major refactor
The problem
Unsure what caused this. Regular music playback seems to work.
What version of Home Assistant Core has the issue?
core-2024.8.0
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
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response