Hi, it’s taken me a few days to get to be able to switch between multiple users’ Spotify account with a list on dashboras, and also send the music to the Chromecast. As I have managed it, so I leave it here in case it is of interest to anyone and as a copy for me.
Switching users is relatively simple, but the chomecast gets hooked to the first user and gives error when switching. With a script to call Spotcast and an automation I have achieved it.
I am Spanish and my interface is in Spanish, so I do not know the exact names of the menus in the English interfaces, keep this in mind if the name does not match exactly.
Finally, I’m very new at this, so if you see any errors or possible improvements in the procedure, I’ll be happy to read you.
I don’t get involved anymore, I leave you the steps:
-
Link your Spotify accounts following the official instructions.
-
Install Spotcast and follow the instructions to add multiple accounts.
-
Create an “Input Select” in HA with the names of the previous accounts (Settings/Devices and Services/Helpers/Add/Input Select, or by hand)
-
Create a script to start the Chomecast with the chosen account:
alias: Start Chrome audio account
sequence:
- service: spotcast.start
data:
limit: 20
force_playback: true
random_song: false
repeat: "off"
shuffle: false
offset: 0
ignore_fully_played: false
device_name: Audio Pincho # Your audio device name. You can use another list here to choose between audio devices
country: EN # Change if you want
account: "{{ states('input_select.spotify_accounts_list')|lower }}" ### Your list created in 3) ###
mode: single
icon: mdi:google-chrome
- Create an automation to change the above script if the account changed:
alias: Change Chromecast audio account
trigger:
- platform: state
entity_id:
- input_select.spotify_accounts_list ### Your list created in 3) ###
condition: []
action:
- service: script.activate_chromeaudio ### Your script created in 4) ###
data: {}
mode: single
- Create a vertical stack on the dashboard with the list and Spotify accounts put into a conditional entity (obviously, the visual part is a matter of taste, I leave you how I have did it):
type: vertical-stack
cards:
- type: entities
entities:
- entity: input_select.spotify_accounts_list ### Your list created in 3) ###
state_color: false
- type: vertical-stack
cards:
- type: conditional
conditions:
- entity: input_select.spotify_accounts_list ### Your list created in 3) ###
state: name1 ### Name of your principal Spotify account ###
card:
type: media-control
entity: media_player.spotify_name1 ### The Spotify media player of User1 ###
- type: conditional
conditions:
- entity: input_select.spotify_accounts_list ### Your list created in 3) ###
state: name2 ### Name of other Spotify account ###
card:
type: media-control
entity: media_player.spotify_name2 ### The Spotify media player of User1 ###
- type: conditional
conditions:
- entity: input_select.spotify_accounts_list ### Your list created in 3) ###
state: name3 ### Name of other Spotify account ###
card:
type: media-control
entity: media_player.spotify_name2 ### The Spotify media player of User2 ###
I hope this is useful (and I didn’t forget any step).
Regards