Unable to establish stable Spotcast connection
See original GitHub issueBug 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:
- Created a year ago
- Comments:17
Top GitHub Comments
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.
That solved it for me. Thanks 💚