question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Got the error _http status: 404 [...] Device not found, reason: None_ when trying to call the service to a Spotify Connect device.

See original GitHub issue
  • Using latest version of spotcast
  • I have setup the Spotify integration in Home Assistant
  • I am using multiple accounts
  • Using latest stable version of Home Assistant
  • I have Spotify Premium
  • I’m attaching relevant logs with level debug for component spotcast (see README)
  • I’m using entity_id in the service call and have tried device_name but the issue remains
  • I’m using spotify_device_id but the issue remains

Describe the bug Got the error http status: 404, code:-1 - https://api.spotify.com/v1/me/player/play?device_id=bc89e722-bb6d-4446-bc9f-3b2f3a265895: Device not found, reason: None when trying to call the service to a Spotify Connect device.

Environment (please complete the following information):

  • HA version: [core-2021.11.1]
  • spotcast version: [v3.6.21]

Configuration

 - icon: mdi:television
    type: service
    id: spotcast.start
    data:
      uri: spotify:playlist:37i9dQZF1DXdrln2UyZD7F
      random_song: true
      shuffle: true
      start_volume: 50
      spotify_device_id: bc89e722-bb6d-4446-bc9f-3b2f3a265895

Additional context The device is available within the legacy Spotify app. I looked in the Dev Spotify Console https://developer.spotify.com/console/get-users-available-devices/, it seems that the api doesn’t retrieve my device - is this the same for Spotcast ? After enabled the device through the the legacy Spotify app, this Spotcast service is running fine, and the Spotify api is able to retrieve the device.

Debug logs

Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/spotcast/spotcast_controller.py:272
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 07:39:39 (5 occurrences)
Last logged: 07:50:42
[139838482340016] http status: 404, code:-1 - https://api.spotify.com/v1/me/player/play?device_id=bc89e722-bb6d-4446-bc9f-3b2f3a265895: Device not found, reason: None

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/spotipy/client.py", line 245, in _internal_call
    response.raise_for_status()
  File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 953, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.spotify.com/v1/me/player/play?device_id=bc89e722-bb6d-4446-bc9f-3b2f3a265895

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1534, in _execute_service
    await self._hass.async_add_executor_job(handler.job.target, service_call)
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/spotcast/__init__.py", line 176, in start_casting
    spotcast_controller.play(
  File "/config/custom_components/spotcast/spotcast_controller.py", line 272, in play
    client.start_playback(**kwargs)
  File "/usr/local/lib/python3.9/site-packages/spotipy/client.py", line 1761, in start_playback
    return self._put(
  File "/usr/local/lib/python3.9/site-packages/spotipy/client.py", line 306, in _put
    return self._internal_call("PUT", url, payload, kwargs)
  File "/usr/local/lib/python3.9/site-packages/spotipy/client.py", line 261, in _internal_call
    raise SpotifyException(
spotipy.exceptions.SpotifyException: http status: 404, code:-1 - https://api.spotify.com/v1/me/player/play?device_id=bc89e722-bb6d-4446-bc9f-3b2f3a265895:
 Device not found, reason: None

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
fcussoncommented, Nov 6, 2021

@Luth1ng, can you confirm the usage of entity_id instead of spotify_id works for you?

Never mind, you are using the wrong id. UUID is home assistant specific, you must use the spotify-id, the only way to get it is to follow these instruction readme.md

Personally, I don’t like the workflow of using spotify-id (it’s a personal take so you don’t have to follow my suggestion). It is much simpler and more readable to use entity-id directly (for me at list)

0reactions
dedorscommented, Dec 10, 2021

Hi, I know it’s closed, but I’m facing the same or similar problem when trying to play on a alexa echo dot. The source list only shows my desktop, and starting playback on the echo fails (which also has a UUID style ID). When I click the “connect to a device” icon on the desktop spotify app, the echo devices are first grayed out, but are available within a second. Without clicking on a device, the source list now shows all echo devices and playback with spotcast on the echo also works now. After a short time after stopping playback, the echos will disapear in the source list again.

Is there a way to do a refresh for the connect devices with spotcast before sending the playlist?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to get device id from spotify · Issue #170 - GitHub
Playback using open.spotify.com or the app is working without any ... Device not found, reason: None [281473262000688] http status: 404, ...
Read more >
vscode-spotify NO_ACTIVE_DEVICE - Stack Overflow
I was having the same issue and a workaround this issue is sending the device id with the play request URL.
Read more >
Request failed with status code 404 Playing Tracks
I'm working on a streaming application using the Spotify Web Player API. I'm running into an issue where accounts from the UK and...
Read more >
Spotcast - custom component to start playback on an idle ...
Good news! Using the device name in the service call fixed it. I'm not sure why this works differently than the device ID,...
Read more >
Spotify down? Current status and problems - Downdetector
Spotify is available for multiple platforms including Windows, OS X and Linux as well as iPhone, iPad, Android, Blackberry and Windows Phone. I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found