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

After updating to HassOS 4.13 and HA 0.115.1 it appears Spotcast has dissapred from my HACS - I also cannot find it in HACS when I search. Has anyone else experienced this?

Hi! I’ve been trying Spotcast for the past week and already have it integrated with my premium account, chromecast and google mini speakers… but, I’ve been having an issue where if I try to start spotify from idle state (a couple of hours on idle) on my Chromecast I always get this error

Logger: spotipy.client
Source: /usr/local/lib/python3.8/site-packages/spotipy/client.py:256
First occurred: September 20, 2020, 11:26:53 PM (3 occurrences)
Last logged: 1:07:02 PM

HTTP Error for GET to https://api.spotify.com/v1/me/player/devices returned 401 due to The access token expired
HTTP Error for PUT to https://api.spotify.com/v1/me/player/play returned 404 due to Player command failed: No active device found

And if I try again, just a couple of seconds after the error, the music starts without any issues…

Is there a way to solve this and just start playing right away at the first try?

Hello,
This is REALLY cool and exactly what I was looking for!
Right now if I switch from one chromecast to the other, I get a loud “sorry, your music stopped because your spotify account is used on another device”.
Is there a way to stop playing on the first before casting on the next one, to prevent this from happening?

what you should do is use force playback which will transfer the audio to the new device. In the chrome cast world it doesnt always work but give it a try

Hello,

This is a great component! I just found out about it and was able to install it. I have two spotify accounts (family plan) and was able to add both properly. I have created two cards - one with ‘account: default’ and one with ‘account: my_account_name’, which works. However is there any way to have a button that would switch between the accounts in the card, so I don’t need 2 on my dashboard? Thanks!

Is here anyone with HA on RPi3b/Dietpi/Debian system and can confirm this component can be installed with HACS with no errors (aka Requirements for spotcast not found: [‘spotify_token==1.0.0’]) ?
What requirements are needed?
EDIT:
spotify-token, libxml2-dev, libxslt-dev was missing…
now works!

Unfortunately it doesn’t change the issue: The playback transfers fine, but the first chromecast says "“sorry, your music stopped because your spotify account is used on another device”

I really don’t know what I’m doing wrong, but I cannot use my chromecast as a device for playing spotify by using Spotcast… If I try to execute the service via Developer it tells me that it cannot find the Chromecast (neither by name or entity_id), even if it is correctly displayed both in the entity list and the Google Cast integration page:




1-1

If you go to open.spotify.com in your browser, are you able to see your chromecast?

1 Like

Im not very good at this so does someone have a guide how to use spotcast?
I have got as far as I can see spotcast.start under developer tools,
I can also type in the text below and call service and it starts playing music on one of my google homes.
entity_id: media_player.google_koket
“uri” : “spotify:playlist:76gDgSsWVnL0Gd1svOfjTc”

But what do I do now? Do I have to go to developer tools every time to use this?

Hello! Im been at this for a while now :sweat_smile: :rofl:

I mange to start Spotify whit the help of Spotcast, all fine and well. But now i want to use the service in a script, to be able to use it in an automation. I want o trigger a song with the button click/ state from off to on.

In developer tools it works.

In the script editor im trying the same thing, but it doesn’t work:

I get this error message: “Failed to call service script/spotcast. value should be a string for dictionary value @ data[‘entity_id’]”

Any thoughts or ideas? Am grateful for every little bit of help!

Hi
Change the URI like this:

uri: 'spotify:playlist:xxxxxxx'

If you have issues with the entity_id you can also try to use “device_name” together with the friendly name instead, like this:

device_name: Bathroom speaker

The “Developer tools” -> “Services” is good to test/experiment.
Now that you have made it work, you can use it in automations, scripts and however you like.

If you don’t know how to do it, you should read up on some of the documentation, as this is more related to how Home Assistant work in general, and not related to this custom component.

You can in example to try to create an automation with the action type “call service”.

1 Like

Thanks very much for the quick reply. I still does not execute the script.
I still get the same error:
“Failed to call service script/spotcast. value should be a string for dictionary value @ data[‘entity_id’]”

I really dont know what to do.

Remove entity_id when using device_name, you only need one of them.

ok, thanks.

Tried that as well, get the same error again :crazy_face:

My frustration is quite high right now, it works in developer tools but not in the script editor…

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: