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

You probably have some extra characters or similar.
Click the three dots in upper right corner, remove the action and create it again from scratch.
If you still get errors, send new screenshots or copy/paste of both config and error message.

1 Like

Great work happening here, I love what I see and am a new user trying to pick up some skills and tricks from you guys.

I can get the playlists casting to my Google Home devices fine using the custom card,
When I add spotcast.play to a script that is started by clicking a button, my Google device won’t start and I get an error.

SCRIPT:

service: spotcast.start
data:
  uri: 'spotify:playlist:2OMDoS3EeIbJ2omad64QeL'
  random_song: true
  shuffle: true
  entity_id: media_player.kantoor

Error:

Logger: homeassistant.components.websocket_api.http.connection.140553252739200
Source: custom_components/spotcast/init.py:445
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 4:29:33 PM (1 occurrences)
Last logged: 4:29:33 PM
Could not find device with name Google Kantoor

Any tips or advice from the combined brains here?

Is the name for the cast device “Google Kantoor”? Typically it is best to use device_name instead of entitiy_id because otherwise it will assume the name is exactly that of the the entitiies friendly name.

1 Like

That did the trick! Thank you.

This is script now works for me:

I didn’t get it to work with uri: ‘spotify:playlist:2OMDoS3EeIbJ2omad64QeL’, when i i uses the whole URL from spotify i got it to work.

Like this: uri: ‘https://open.spotify.com/playlist/5UUo28NbRH0xsCa3XS2Q

Maybe you could try that?

Same problem. I used the following now:

service: spotcast.start
data:
  uri: 'https://open.spotify.com/playlist/2OMDoS3EeIbJ2omad64QeL'
  random_song: true
  shuffle: true
  device_name: Google Kantoor

I even deleted the script and recreated it just now but the error remains. Also tried with any of the other Google Home devices that I have and the error is the same.
When I try to address these devices with the script in this post, it works flawlessly:

Awesome! Glad you got it working. :slight_smile:

What is the current error message? If it’s related to device_name:
I’ve noticed the device_name needs to be spelled 100% correctly including uppercase/lowercase etc.
So might be wise to verify that.

I also had the stumbling block of the device name and entity I’d not working.
What I found in my case is that the device name isn’t necessarily correct in HA. I had to open the (google) Home app on my phone and use the name listed in there before I could get this to work.
I renamed my chromecast in the home app then restarted HA and it worked after that.

1 Like

Brilliant! That did the trick. I had renamed the Google device in HA but it was called ‘Kantoor’ in the Google app. Working like a charm now. Much appreciated Dan,

Hi all
I just installed spotify integration and the spotcast component which is super helpful
Thanks!

I have one problem though. I can start the spotcast service from a script but after 50-60 minutes the chromecast turns off by itself. Is there something I can do?

Another issue not related to spotcast is that I don’t know how I could move to the next song of a playlist. Is there a way?

1 Like

Thanks. I see that there is no solution for this. Is this happening to all users? (I guess yes)

Yes it happens to us all

1 Like

Maybe I should write a script… if chromecast stop turn it on… I must think of a condition though…

I was always wondering if one might be able to create an on the fly scene, stop Spotify, then activate the scene again. Perhaps you can find out? :wink:

I tried to make a scene or a start the service cast but it is not working. What is needed is too choose the media player from the lovelace card but I don’t know if this is possible or how to do it.
At least in my case when the spotcast stops all I have to do is to choose the chromecast player from the picture below.

103930

This used to work for me, but now I’m getting this error when calling the service:

‘ChromecastInfo’ object has no attribute ‘services’

Any idea what might be causing this? Since it wasn’t working I updated the cookies in my secrets.yaml to be current, but still received the same error.

Maybe post your code?

I think Spotify and Google Cast are having some issues btw. Having issues streaming since yesterday. Also Google Home to Spotify directly had issues, so can’t be spotcast/HA itself.

Replaced tokens twice (log mentioned expired tokens first). After a while suddenly worked (but sometimes hiccups when skipping songs). Now again issues, also from Google Home > Spotify directly.


Logger: homeassistant.core
Source: custom_components/spotcast/__init__.py:452 
First occurred: 11:01:13 (2 occurrences) 
Last logged: 11:03:05

Error executing service: <ServiceCall spotcast.start (c:48e40fd4105711eba8212755870ff66b): entity_id=media_player.multispeakers_cast, uri=spotify:playlist:37i9dQZEVXcQorVlmdOh35, random_song=True, shuffle=True, force_playback=False, repeat=true, offset=0>
Error executing service: <ServiceCall spotcast.start (c:8b36271a105711eba646ef90cbb687b4): entity_id=media_player.multispeakers_cast, random_song=True, repeat=playlist, force_playback=True, offset=0, shuffle=False>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1351, in catch_exceptions
    await coro_or_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1374, in _execute_service
    await self._hass.async_add_executor_job(handler.func, service_call)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/spotcast/__init__.py", line 302, in start_casting
    spotify_cast_device.startSpotifyController(access_token, expires)
  File "/config/custom_components/spotcast/__init__.py", line 452, in startSpotifyController
    sp.launch_app()
  File "/usr/local/lib/python3.8/site-packages/pychromecast/controllers/spotify.py", line 88, in launch_app
    raise LaunchError(
pychromecast.error.LaunchError: Timeout when waiting for status response from Spotify app

@fondberg do you perhaps have the same experience?

Edit: also trying to cast from Spotify app to Chromecast speakers (thirdy party and Google mini’s) have issues. Either my network is messed up, or Spotify > Google Cast is having issues. Spotify Connect works fine.

Edit 2: casting other sources like online radio streams to Google Cast speakers works fine.

Edit 3: seems a widespread issue: https://community.spotify.com/t5/Android/Spotify-and-Nest-Mini-can-t-cast-or-play-on-device/td-p/5054694

I figured I’d share all this info and findings so others know Google Cast is having issues, not spotcast.

1 Like

I just wanted to say thanks for this great component! I’ve been using Spotcast in combination with room presence detection to have my Spotify music follow me around my home. I’ve written a guide on how to get it set up if anyone else is interested.

1 Like