Switching between Spotify accounts with a list in the dashboard + Chromecast audio

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:

  1. Link your Spotify accounts following the official instructions.

  2. Install Spotcast and follow the instructions to add multiple accounts.

  3. Create an “Input Select” in HA with the names of the previous accounts (Settings/Devices and Services/Helpers/Add/Input Select, or by hand)

  4. 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
  1. 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
  1. 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

Hi Javi,

I’m trying to implement your suggested solution, but I’m wondering if this solves the issue I have. I have a Zeppelin Wireless as my default speaker, and want to start music on it with an automation. One automation for my account, and one for my girlfriend. The problem is that the speaker will ‘remember’ the last connected account, and only play for that account.

When, for example, account 1 was last connected and account 2 runs the automation to start the music it won’t work. The speaker is not found by the second account. Is this helper fixing this problem? I tried to implement it, but it seems that nothing is happening and the issue is still there…

Thanks!

I have the same problem with my Heos speakers.