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

I’m have some trouble to install Spotcast. I installed it through HACS, latest release 2.4.
When I try to add this to my config.yaml the file seems to be corrupted and is not valid

spotcast:
  username: [email protected]
  password: mysecretspotifypassword

I even cannot find the spotcast service into the dev section.

I’m running Home Assistant 0.100.2

any suggestion ?

Awesome, thanks so much.

This component works perfectly, thank you!

Hello, today, I’ve installed this component. It’s something I’ve been looking for for a long time. At first, it worked!
But in the evening, when I wanted to experiment with some automations, it stopped working :frowning:. When I try to launch the script manually, I get this error: ‘NoneType’ object has no attribute ‘find’.

What is wrong? Also, I’m new to HA, so sorry if some information is missing. Code of the script bellow.

play_music_on_speakers:
  sequence:
    - alias: Spustit hudbu v obýváku
      service: spotcast.start
      data:
        device_name : "Speakers"

EDIT: I’ve just found out that if I start music on my phone (the liked songs “playlist”) and let it play, the scripts starts working and transfers the music from the phone to Chromecast. Is there any way of just transferring the stopped music to my Chromecast?

This works great and was something I was doing for casting other things before I found out that on SOME chromecast devices you can completely turn off the bleep blop sound. I was able to turn it off on 2 chromecast audio dongles but not my soundbar with chromecast audio built in, or my home minis. It’s a setting for the device in the google home app called playback sounds.

1 Like

Is it possible to use this component to play a random spotify playlist similiar to this

[edit] works fantastically

Hi,

I have just set up my first hassio. Its running at my synology nas.
what i’m trying to accomplish is to start a spotify playlist on either when i press a button or automatically on event. I have tried both on my bluesound, chromecast and google home.
But nothing happens. I managed to get custom: spotify-card to work but it drops all devices without hassio, web player (chrome) and local-computer.

The spotcast service is up running.

I use this script:
script:
  start_playlist_xmas:
    - service: spotcast.start
      data_template:
        device_name: google vardagsrum
        uri: spotify:user:spotify:playlist:4Mm14OcrRVHKp7U2zpDp4j
        media_content_type: playlist

Sat Nov 30 2019 08:50:06 GMT+0100 (Central European Standard Time)

Could not find device google vardagsrum from hass.data, falling back to pychromecast scan

Connection lost. Reconnecting…

Yes this is possible. It is undocumented right now. You just pass “random” as string as URI and spotcast will start playback of a random playlist

Device name is case sensitive.

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