Spotcast - custom component to start playback on an idle chromecast device

I installed using the Chrome Devtools Method and as far as I can see, expiration is 1 year from when you got the cookie values

1 Like

I updated Home Assistant to 2022.8.7 yesterday. Since then Spotcast is not functioning. I’ve checked and reapplied the spotify tokens and also completely reinstalled the Spotify plugin. No joy… I have two instances I’ve tried on and have the same result. Spotcast is broken. No log errors that I can see. Anyone else? Thanks!

This seems to be related to a change in Spotify rather than HA.

It’s been reported here, so you are not alone. You could add your thumbs up to the report on GitHub.

1 Like

Thank you!! I had just assumed since I updated HA that it was the culprit.

Does this work for non premium account to cast to google mini ?

It says the component need the official Spotify intefgration.
But on the official integration I see: A premium is not required, but recommended. Premium accounts can be controlled (pause, play, next, etc.), while free accounts can only be used for browsing and current playback status.

Integrations seems to work on my computer but I can only play in my browser, so I am wondering if I did something wrong.

No. I’m a cheapskate and it works fine.

Thanks for the clarification!

I finally was able to start a playlist on a specific device, but are you also able to pause, play next/previous from custom:spotify-card ?

Can’t do previous. With a free account.

I have a Samsung Galaxy Tab tablet running the Fully Kiosk browser. Using the Fully Kiosk HA integration creates a HA media player for the tablet.
I can’t seem to get spotcast to cast to it using the HA media player entity ID. Is it possible? If so, how?

Hey guys, maybe someone can help me out here.
I installed everything and it worked. I set an automation, that ends in triggering Spotcast.
It work a few times, then i updated my HA Core and it stopped working ("Could not get spotify token). Ich pasted the secrets (that didn’t change) and it didn’t help. I reinstalled Spotify Connect and it worked again… exactly one time.
And then, again:

Stopped because an error was encountered at October 21, 2022 at 1:11:15 PM (runtime: 0.02 seconds)

Could not get spotify token.

I am out of ideas here. Everything is setup as intended and it worked several times and suddelny, without any change, it stopped. It worked for months a year back, and then i reinstalled HA and didn*t use/install spotcast until yesterday.

Thank you!

Edit: Now it works again. Could it be, that there is some kind of restriction on how many casts you can start in a specific amount of time?

Is it possible to start a playlist with ‘Enhanced’ mode on?
This is a functionality in Spotify to add related tracks to the playlist that is played.

Did it just start working by itself? Im having the same issue.

Spotcast is amazing.
Two things I’m missing:

I am getting an error failed to get device id from Spotify. Has been working for me for a week or two now not sure what could have changed.

here’s the service call I am using to call spotcast.

service: spotcast.start
data:
  entity_id: media_player.all_speakers

error 1
websocket_api script: Error executing script. Error for call_service at pos 1: Failed to get device id from Spotify

error 2

  • No device with id “Axxxxxxxxxxxxx” known by Spotify
  • Known devices: [{‘id’: ‘Bxxxxxxxxxxx’, ‘is_active’: True, ‘is_private_session’: False, ‘is_restricted’: False, ‘name’: ‘Web Player (Firefox)’, ‘type’: ‘Computer’, ‘volume_percent’: 51}]

Hi all, had spotcast working flawlessly for a few weeks and randomly it stoped working. Im getting this error.

Error executing service: <ServiceCall spotcast.start (c:01GJWGMT5MG2KSXPJ7D802KJQY): entity_id=media_player.archer_s_speaker, uri=spotify:playlist:2Mr0haZIw1xAK8zsjkrueO, account=archer, start_volume=40, limit=20, force_playback=False, ignore_fully_played=False, shuffle=False, random_song=False, offset=0, repeat=off>
Error executing service: <ServiceCall spotcast.start (c:01GJWGNFYXP5TW4CR2X67F6K8P): start_volume=40, account=archer, uri=spotify:playlist:2Mr0haZIw1xAK8zsjkrueO, entity_id=media_player.archer_s_speaker, limit=20, force_playback=False, ignore_fully_played=False, shuffle=False, random_song=False, offset=0, repeat=off>
Error executing service: <ServiceCall spotcast.start (c:01GJWH42VM882C82EVV3QG38KS): entity_id=media_player.archer_s_speaker, uri=spotify:playlist:2Mr0haZIw1xAK8zsjkrueO, account=archer, start_volume=40, limit=20, force_playback=False, ignore_fully_played=False, shuffle=False, random_song=False, offset=0, repeat=off>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1762, in catch_exceptions
    await coro_or_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1787, in _execute_service
    await self._hass.async_add_executor_job(
  File "/usr/local/lib/python3.10/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 240, in get_spotify_device_id
    spotify_cast_device.startSpotifyController(access_token, expires)
  File "/config/custom_components/spotcast/spotcast_controller.py", line 95, in startSpotifyController
    sp.launch_app()
  File "/config/custom_components/spotcast/spotify_controller.py", line 104, in launch_app
    raise LaunchError(
pychromecast.error.LaunchError: Timeout when waiting for status response from Spotify app

The only thing I’ve changed recently is adding PiHole to my server which HA is running from. Even after reverting the settings (disabling pihole and setting my DNS back to normal) I still get the same results. Ive tried power cycling the devices in case it was an IP issue but no success.

I can see the cast devices, they turn blue when I run the automations but never actually start playing. Any help would be greatly appreciated.

I am getting the exact same error as @jsv93 (same traceback). It started happening about 28 hours ago, even though I don’t believe I’ve made any changes to my configuration.

I have this set to start Spotify with my alarm and it didn’t work the morning of November 26, even though it was working the night before.

The Chromecast audio devices make the “connect” sound and they go idle, but then the music never plays. If I use the Spotify app on Windows or iOS and manually start the music on my speaker group, it works.

Edit:
The code changes suggested here fixed the problem for me:

Yay!

Thanks Dan for reporting the link to this fix here. And thanks to Gramatus for the proposed fix!
Great community as always ! :slight_smile:

Is it possible to add a feature to Spotcast to simply set the Spotify connect device without starting playback? I’d love to have that option in one of my automations!

Did you get rid of that error?