Hi folks,
so i have a script that plays a bunch of my son’s baby music, and up until recently its been using my Spotify Account (and thus ruining my recommended playlists). So using a family account he now has his own.
However - When specifying the album or playlist to play I’m not able to specify what Spotify account to utilize - has anyone got a solution to this?
Running this script uses my spotify account, despite both existing in the Spotify Integration.
I checked and the URL above is not unique to the user, just the playlist.
So there must be a user validation step, so hopefully someone smarter than me can figure out how to force an account.
I have multiple spotify accounts as well condigured in HA and through this I get one media_playet.xxx entity for each account.
I think you should use this media players for your service call and have a service cal before that sets the source of the spotify media player to the sonos.
I don’t use Sonos wo I know almost nothing about it, but I see here that you use the sonos as a media player in your service call, so I assume your Sonos System is linked to your specific Spotify account?
You are correct, in the Sonos app i’ve added the additional account - now just need to figure out if there is a way to invoke which account to use when playing through sonos
yes, although the spotify app is linked to my spotify account.
Ah i think i see where you are going. My wife says play ‘X’ on sonos in the living room - Sonos can do 1 of 2 things:
Honor who it came from (to preserve all the meta data for spotifys recommendation engine)
receive the connection from spotify and not care where is came from and just validate a subscription is present and authorized to play the content.
Based on the fact you can skip and forward tracks playing on sonos speakers in the Spotify app - i’m assuming they communicate over API and thus leaning towards #1
so would be fair to assume there is a way to send the info of which account should be used (it just hasnt been implemented yet).
Good, this means what I proposed above should work.
Try if this works in Home Assistant:
Go to your spotify media_player.xxx entity, for the source choose one of the sonos players, choose a song and press play. If you hear music from your sonos device you should be fine. Then try the same with the spotify media_player.xxx of your son (you may need to play something to the sonos device from the spotify app logged in as your son first for HA to see all the sources).
If this works you need to change your automation to something like this:
cbp_more_please:
sequence:
- service: media_player.select_source
data:
entity_id: media_player.xxx <- spotify media player of your son
source: sonosxxx <- name of the sonos player in the source list of the spotify media player
- service: media_player.play_media
data:
entity_id: media_player.xxx <- spotify media player of your son
media_content_id: 'https://open.spotify.com/album/4IjjmD5S292op49x0kc677'
media_content_type: music
Ok so on doing some investigation the ‘sources’ are from sonos directly (which are sonos playlists (or radios). I can browse Spotify music and add them to sonos playlists, which then appear as a source.
However Sonos (when you add multiple accounts) seems to have one spotify account as a ‘primary’ - so for a short term workaround i can leave my sons spotify account as primary for automations, then if i want to play my music (rare - between my wife and my son, I only end up listening in the car lol) I can switch accounts manually.
Just tested and this works in the short term, so I can now have white noise (sonos playlist <> source) and play my own music
I have that same issue… So to browse for new media from a Sonos media_player, it seems to me to pick the same Spotify account everytime, and appears maybe alphabetic? In the UI or Media Browser, have you found a way from a Sonos media_player to select which Spotify account to browse?
I also still can’t get my Spotify integrations to show Sonos as a source, it will show the phone, or web browser, but never pulls down a Sonos device as an available source
Sonos has been removed from Spotify developer API. Simply it’s not supported anymore. I’m still spending time to avoid this “ban”… still without success. If someone knows a way please help me…
I solved this as follows:
Add all the Spotify accounts to HA using the Spotify integration (can link all to the same Spotify developer console btw).
You can then see, that «Browse Media» on the Sonos media player card serves you with all the Spotify accounts linked to HA.
Go to developer tools, events and start listening to «call_service» events. Now from the Sonos browse media, play any song from one spotify account, then play any (or the same) song from another Spotify account. Comparing the two «play_media» events you will notice how the first part of the media uri differs, this is the part that selects the user account.