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

I just tried out the custom spotify playlist card but I have no sources to choose from.
Do I need to configure something else? thanks!

edit: i made a button to play a specific playlist and i can’t tell you how much i love this!!
to bad speaker groups are not supported :frowning:

Speaker groups would be awesome. If someone knows how to debug that in pychromecast it would be great

My gut feeling tells me it’s either Spotify themselves that block casting to groups or spotipy that’s the culprit here. I made a simple librespot/icecast/liquidsoap docker container and casting the broadcast url to groups with pychromecast using blocking mode works. (latest github version).

1 Like

Maybe you are right but it would be interesting to trace the traffic when starting casting from chrome. I don’t have time now but if someone traces I can add the functionality in relevant libs (spotipy or pychromecast)

Hi @fondberg, first of all big thanks for this wonderful custom component, it works amazingly well in combination with the spotify-card :slight_smile:

Would it somehow be possible to create multiple instances with different Spotify accounts for each instance?
I created different lovelace spotify-cards for my family members, each with a different Spotify client-id.
However each card starts playing from my Spotify account if I select a (spotcast) source in the card.
Just wondering :slight_smile:

Thanks! It would be quite simple if we agree on a way to send some identifier in the call to the service. The components configuration would.of course also need to be changed to be able to take multiple account username/password pairs. Can you think of a way to add this without breaking backwards compatability?

Thanks! This is exactly the only thing that was still missing from my HA. My life is perfect now :ok_hand:.

1 Like

Just to clarify for others. Upgrading to 0.92 did solve the errors! Thanks!

I’ve released a new non breaking version which has some configuration schema checks and support for multiple spotify accounts (@QkulleQ ).

3 Likes

To get rid of any misconceptions; this component only supports the new style of declaring dependencies (introduced in 0.92) using the manifest.json. Not the old way which declared the dependencies in a field called REQUIREMENTS in the actual python file.

Thanks @fondberg for the multi-account update! That was super quick :slight_smile:

  1. Unfortunately the component still plays everything from the main account.
    I don’t get any API errors for the extra attribute “account”, so that part works.
    Could the typos (see below) maybe ended up in the code too?

Multiple accounts

Add accounts dict to the configuration and populate with a list of accounts to be able to initiate playback using diffferent accounts than the default.

spotcast:
  username: !secret spotify_primary_password (should be spotify_primary_username)
  password: !secret spotify_primary_password 
  accounts:
    niklas:
      username: !secret spotify_niklas_password (should be spotify_niklas_username)
      password: !secret spotify_niklas_password
    ming:
      username: !secret spotify_ming_password  (should be spotify_ming_username)
      password: !secret spotify_ming_password
  1. Could the spotify-card possibly make use of the new multi-account functionality too? That would be really awesome!

Weird because it worked for me. What typos are you referring to?

Regarding the spotify card I can add a config parameter to tell it to use an account to start playback in an idle chromecast device if that is what you need

On the github page under configuration it says:

username: !secret spotify_primary_password (this should be spotify_primary_username)

and:

username: !secret spotify_niklas_password (this should be spotify_niklas_username)

and:

username: !secret spotify_ming_password (this should be spotify_ming_username)

It would be awesome to have different spotify-cards on each family member page, showing the playlists of that member’s account. And when you click on a playlist in that card, it plays with the corresponding spotify account. That way each family member has his/her own spotify page in HA. Something like that :smiley:

The typos are only in documentation. Are you missing the new property in the service call?

When you say one card per page, do you mean with the same browser on 1 device or multiple devices?

When I do a service call like this, it does play but it still uses my spotify account instead of Anneke’s:


I’m happy to further do tests whatever you want.
Regarding the spotify-card I meant this:



Hope I made things a little more clear, if it’s too much work don’t bother.
PS. I need to login with Anneke’s account in Windows to be able to show her spotify-card.

Another theory regarding groups would be the way SpotifyController in pychromecast handles launching of the app (or app id) on multiple chromecasts. I’ve been looking into this a little bit. But Im far from comfortable with python. It would be nice if you could first off see what app id is launched when you start casting from the Spotify app on your phone. Might be a different one than CC32E753? Are there any debugging tools for chromecast? The official one only seems to let you debug your own chromecast applications?

After some testing with the spotify example on pychromecast github I noticed that it “sometimes” launches the app on one device in the group. Starting a cast to a to a group device_id that’s already known by Spotify also works (ofc).

I’ve tried snooping a bit with wireshark but didnt really find anything useful here yet.

I think I’ll have to withdraw my statement that Spotify blocks casting to groups. :slight_smile:

@Phr0z Seems the appid is the same, CC32E753. I think the best way is to open an issue in pychromecast efter testing that it doesn’t work from the https://github.com/balloob/pychromecast/blob/master/examples/spotify_example.py.

Added a question to Erik and the pychromecast crew here https://github.com/balloob/pychromecast/issues/292.

Would it be possible if someone lifted this and created a ticket in the spotcast repo?

1 Like

@QkulleQ I see, I still don’t understand if it is on the same device the tabs are to be clicked or on different devices. If you want the users to use the same browser on the same device I think it will be difficult because of shared cookies et.c.

edited: found the bug. pushed the change, can you test?

Sorry @fondberg, it’s still playing from my account only.
I reinstalled the component and tried 2 different accounts, but they are both playing with my spotify account after the service call.
Because you mentioned cookies I also tried it from the different Windows accounts of my relatives, where the official spotify app is connected to their accounts. Same thing,

About the ‘member tabs with spotify-cards’, I wouldn’t mind if the tab is only working when the member is logged on his/her own device or windows account.
Of course it would be preferable if it would work regardless of the device or account, but if that’s technically not possible no big deal.

Lets move this to github https://github.com/fondberg/spotcast/issues/4
If you want to continue the dicussion for the card open a ticket in that repo (https://github.com/custom-cards/spotify-card). But my last 5 cents is that you should try it out with the following limitations:

  1. Several cards have hard time co-existing in the same browser session on the same device
  2. It is not possible, yet, to initiate playback from another account than the default account.
    But with that said it would be good to test it before implementing functionality for initiating playback on a non-default account