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.

Unable to establish stable Spotcast connection

See original GitHub issue

Bug Ticket

Describe the bug

I configured a Mini Media Player with a Spotcast shortcut to start a playlist on one of my children’s Echo dots using the Spotify Device ID specific to one of my Spotify Family plan accounts and the Echo. Initially it worked as expected, but within 1-2 days it randomly stopped working giving a generic device not found error when I tap the button:

Failed to call service spotcast/start. http status: 404, code:-1 - https://api.spotify.com/v1/me/player/play?device_id=<THEDEVICEID>: Device not found, reason: None

When I went to verify the Device ID using the same steps as initial setup, I found (1) I had to say “Spotify Connect” and tap the Echo device in my Spotify app to get it to re-establish the connection and make it available for retrieval on the Spotify Developer site and (2) the Spotify Device ID changed.

This repeats every 1-2 days requiring me to retrieve another Spotify Device ID to get it to work again. I’m trying to figure out how to establish a stable Spotcast connection and which device type to use for Spotcast service calls. If it didn’t work for 1-2 days each time I use a new Spotify Device ID, I would assume something is not configured right on my end, but I am able to get it to work, just not reliably and never using the device_name or entity_id.

  • 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

Environment

  • Installation type: HA_OS
  • HA version: 2022.5.5
  • spotcast version: v3.6.29

Configuration

I’ve configured with and without the default account repeated under accounts:

sp_dc: !secret spotcast_family_sp_dc
sp_key: !secret spotcast_family_sp_key
country: US
accounts:
  family:
    sp_dc: !secret spotcast_family_sp_dc
    sp_key: !secret spotcast_family_sp_key 
  dad:
    sp_dc: !secret spotcast_dad_sp_dc
    sp_key: !secret spotcast_dad_sp_key
  child:
    sp_dc: !secret spotcast_child_sp_dc
    sp_key: !secret spotcast_child_sp_key

Service Call

service: spotcast.start
data:
  uri: spotify:playlist:37i9dQZF1EIYtCYWOqKQq0
  device_name: Echo Dot Living Room
service: spotcast.start
data:
  uri: spotify:playlist:37i9dQZF1EIYtCYWOqKQq0
  entity_id: media_player.echo_dot_living_room

Additional context

In the process of troubleshooting, I have tried multiple spotcast.start service calls through the Developer Tools section using the Spotify Device ID or device_name. The entity dropdown indicates “No matching entities found,” but I’m able to manually enter the entity_id. Using any of those three device types, the toast message I get each time is usually “Failed to call service spotcast.start. Unknown error.”

Here’s a debug log for one of the service calls: Logger: homeassistant.helpers.script.websocket_api_script Source: custom_components/spotcast/spotcast_controller.py:187 Integration: Spotcast (documentation, issues) First occurred: 3:34:02 PM (1 occurrences) Last logged: 3:34:02 PM

websocket_api script: Error executing script. Unexpected error for call_service at pos 1: ‘NoneType’ object is not subscriptable

Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 447, in _async_step await getattr(self, handler)() File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 680, in _async_call_service_step await service_task File “/usr/src/homeassistant/homeassistant/core.py”, line 1627, in async_call task.result() File “/usr/src/homeassistant/homeassistant/core.py”, line 1670, in _execute_service await self._hass.async_add_executor_job( File “/usr/local/lib/python3.9/concurrent/futures/thread.py”, line 58, in run result = self.fn(*self.args, **self.kwargs) File “/config/custom_components/spotcast/init.py”, line 190, in start_casting spotify_device_id = spotcast_controller.get_spotify_device_id( File “/config/custom_components/spotcast/spotcast_controller.py”, line 200, in get_spotify_device_id spotify_device_id = self._getSpotifyConnectDeviceId(client, device_name) File “/config/custom_components/spotcast/spotcast_controller.py”, line 187, in _getSpotifyConnectDeviceId for device in devices_available[“devices”]: TypeError: ‘NoneType’ object is not subscriptable

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:17

github_iconTop GitHub Comments

1reaction
Systemediccommented, Jun 4, 2022

Same issue here. I have two spotify (premium) accounts and multiple devices. I have an Aqara button besides my sons bed and when he presses this button an configured playlist has to start playing on his Google nest mini.

This has worked perfect but recently this has stopped working. When I open the android app, select his device and connect to it and then press the button everything works.

Previously I have made the connection in the automation by Entity ID, now I do this by Spotify Device ID but that doesn’t work either.

0reactions
joekaisercommented, Aug 4, 2022

fwiw i ran into this same issue, everything seemed like it was setup correctly but it only started working after i manually enabled the spotify entity/device in home assistant

That solved it for me. Thanks 💚

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spotcast - custom component to start playback on an idle ...
I am specifying a device, though I notice I am using the spotify_device_id (which I thought was the preferred way to do it...
Read more >
Playing on chromecast devices doesn't work #245 - GitHub
Describe the bug I couldn't play to chromecast devices. I set everything up according to the README: spotify integration, spotcast, ...
Read more >
spotcast - Bountysource
spotcast. Home assistant custom component to start Spotify playback on an idle ... ```Logger: homeassistant.components.websocket_api.http.connection
Read more >
Terms and Conditions - SpotCast
The internet is not always stable and predictable – sometimes you might not be able to access the App, your User Data, or...
Read more >
Link sopcast bóng đá liverpool wesham
Link sopcast bóng đá liverpool wesham"Of GOP failed in have was were successful on enforcing ... Russia and other threats and ensure stability,...
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