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

Hi,
Thanks that helped me for alot of things. But now i got another error message. failed to call service script/start_playlist_xmas extra keys are not allowed @data[’ media_content_type’]

media_content_type is not a known parameter for spotcast and your URI looks suspicous. If it doesn’t work try with spotify:spotify:playlist:4Mm14OcrRVHKp7U2zpDp4j (without user: in the string)

I just installed Spotcast, which i’m using with mini-media-player. That allow me to control playlist playback to my Google Home MIni’s.

However, i also spotted the great “transfer current playback” function.

Has anyone made the mockup, for a solution to select between all the possible playback devices? :slight_smile:

Update 2:
After wasting lots of hours, @petro helped me out with a python script. My solution was working, but was both a bit overkill - and too complex.

Thanks to him :slight_smile:

If other need this kind of solution, take a look at the post:

Remember to create the input_select :wink: !

Update of sensor.chromecast_devices is taking over 10 seconds

11.56 main.py (WARNING) - message first occurred at 00.05 and shows up 210 times

I saw another mentions this. I’m not sure if it was on Github, or here. However, it happens quite often.

Are there a solution to fix it? Else, i gues i’m better suited with using another logic, grapping the data from every mediaplayer, or so (which i already has in HA).


Also, would it be possible to implement a “mute” solution, to prevent the “blops”, like mentioned here:

The sensor is slow and I haven’t found a way to speed it up. It is optional though so you don’t need to use it unless you need it.

The blop sound can be muted using a logic found in this topic on this forum. Just search for it.

Hi

I already linked to the post by @Emphyrio (post), if that’s what you 're thinking about :-)? My post was more to make a suggestion, to implement a solution like that, which was build in, in Spotcast, allowing it to be a bit more userfriendly for users, which arn’t that good to the logics and structure behind HA :slight_smile:

If that not the proper post, i would like to see what you’re thinking off :slight_smile:


And, yet another suggestion.

I stumbled across the suggestion about allowing the user to play a random playlist/number, and a solution found here.

Have you considered to implement another solution, which actually picks something randomly :-)? Or, is that all the way to time-consuming? I found this about picking a random track, which looks promising (Well, it’s just an example, to generate a random string for the search-function…). But that could be used in the radio-API.

However, this looks promising, and it would be awesome to see implemented in Spotcast:

Maybe you think the same? I’m not sure :slight_smile: But i would like to mention it.

Another thing could be to pick up a random playlist on v1/browse/featured-playlists, and play that. And, maybe use the data from Home Assistant, to define the country - or allow the user to define that.

curl -X "GET" "https://api.spotify.com/v1/browse/featured-playlists?country=DK&limit=10" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer {TOKENGOESHERE}"

And pick up the ID form playlists.items[{RANDOMID}].id, where RANDOMID could be a random from 0 to 9, or so :slight_smile: (based on the limit value, ofc.)

I know i’m just bringing up a few things and suggestions, but i would just like that feature - and i myself, appreciate both ideas and suggestions.

Maybe you would consider it - maybe not :smiley:

Have a great sunday!

A lot of really good suggestions!

First off, this component is open source and any contributions are welcomed with a warm heart :heart:
Second:

  1. The beep sound is annoying and I guess it could be implemented natively.
  2. The truly random playlist of all spotify playlists can of course also be done but out of your suggested methods which one to choose? I kind of like the idea of not being too random. Maybe keeping it to a genre or play a song and continue with its radio playlist.

What do the others want that uses spotcast?

2 Likes
  1. That would be great! :slight_smile:
  2. I guess you’re right. Maybe it should be based on genre, instead of all the way too random.

Maybe other people in this discussion, have some input?

So this is a free bump, too.

I would love to see both things implemented. Maybe i could help at some time - however, i have just a bit to many projects ongoing currently :smiley:

Hi
after i start the music with spotcast.start

how i stop the music ?

Through a mini-media-player Lovelace card perhaps. Or your Spotify app. Or a media_player service call.

Spotcast is only to meant ti start the playback. The rest is controlled throught the media players in HA

I’ve noticed that music started with Spotcast stops around 30-40 minutes of playtime most of the time. The playlist contains over 80 songs so it’s nowhere near finished. Is this a limitation of the developer API or am I missing something? Also, how do I set the service to repeat a playlist? I’ve tried ‘repeat: playlist’ as service data, but doesn’t seem to work/help.

Are you sure it is not 60 mins? That ia when the token expires. If that is the case it is something which is known and it is very hard to fix. There is an issue about it on github and I would need help with it

It could be that I started it with Spotcast first, then stopped it, started it again. So maybe the token was 60min old. I’ll run a test where I just use Spotcast and won’t touch anything. Thanks for your reply!

Also: what kind of help you need? I have no programming skills (currently at least) but I’m willing to test stuff if you need it :+1:

Thank you for this! Works great with my Hub and Lenovo Smart Clock. It is also really easy to use with a simple automation to start playlists depending on time/events.

1 Like

Thank you for this great custom component. I’ve been happily using it for a few days with Spotify playlist URIs. I’m experiencing an issue with album URIs, but I am not sure whether there is an issue with Spotify itself, or this component, so I was reluctant to open an issue on the GitHub.

When attempting to play a Spotify album, the debug message that is thrown is:

Call-service API error. Error Message: http status: 404, code:-1 - https://api.spotify.com/v1/users/me/playlists/6oraBtHbRj7JwCcmYc1zaE/tracks?limit=100&offset=0:
Not found.

The error message is:

{
“error”: {
“status”: 401,
“message”: “No token provided”
}
}

Does anyone happen to know why this error would occur with album URIs but not playlist URIs?

Many thanks

I had the same problem with repeat not working.

In the Developer Tools > Services > spotcast.start service, it shows:
repeat - Set repeat mode for playback. Available options are track, context and off

“repeat” : “track”

worked for me.

Thanks for all your work on this custom component fondberg. Love it!

1 Like

That seems very weird. The spotify apis are kind if dodgy and it might be something in their side. If you do find the root cause I can help you fix the code but I don’t have much time for debugging myself I’m afraid

The help I need is with programming. The reason is that fixing the token timeout is kind of large and would require adding the functionality in pychromecast after doing a network sniffing if how the spotify client does it and replicating it.

Thanks @fondberg! I’ll be sure to report back if/when I know more.