Media browser, Spotify, select output device?


How Can i Select output device when i chose yo play a playlist in Spotify with media browser (ha 0.115).
I’ve many Google home mini, n’est mini, group …

Thx !


I have the same issue, I also have several Google devices and a Sonos device but I can’t select them.

I understood that it is possible to play locally stored media in the media folder and in the right corner of the media card you can select the player which is integrated in HA

Here is a solution for you using the excellent SpotCast integration.

I added this on my dashboard


First install SpotCast using HACS.

I have four Chromecast Audio devices and a group called Flat. Each one has the room in the title (e.g. the Study cast entity is called media_player.study_audio_cast).

So I created an input_select drop-down list with the five human readable names and then wrote an automation to change to the correct casting device when changed in the drop-down list.

YAML from my dashboard

  - entity: media_player.spotify_john_tunnicliffe
    type: media-control
  - type: entities
      - entity: input_select.chromecast_audio
      - entity: script.spotify_start
show_header_toggle: false
type: vertical-stack

YAML from my spotify.yaml file in my config/packages directory.

  client_id: !secret spotify_client_id
  client_secret: !secret spotify_client_secret

  sp_dc: !secret spotify_sp_dc
  sp_key: !secret spotify_sp_key
    name: Chromecast Audio
      - "Study"
      - "Flat"
      - "Lounge"
      - "Kitchen"
      - "Bedroom"
    icon: mdi:cast-audio

- id: spotify_device_selected
  alias: 'Spotify: Device Selected'
  description: 'Starts music playing on the selected Chromecast Audio device'
  - platform: state
    entity_id: input_select.chromecast_audio
  condition: []
  - service: spotcast.start
      entity_id: >
        {% set selected_device = states('input_select.chromecast_audio').lower() %}
        {{ 'media_player.' + selected_device + '_audio_cast' }}      
      force_playback: true
  mode: single

  # Spotify Start Playback
    alias: 'Spotify: Start Playback'
    - service: spotcast.start
        entity_id: "{% set selected_device = states('input_select.chromecast_audio').lower()\
          \ %} {{ 'media_player.' + selected_device + '_audio_cast' }}     \n"
        force_playback: true
    mode: single
    icon: mdi:spotify

Note: The Spotify Start Playback script solves the problem of when you have nothing playing, but the drop-down has the correct player selected.


Thx !!

I try this right away !!

That’s it, it works! thank you so much !!

1 Like

Hi John,

Thanks for the script - got it all going but no sound out of any of the Chromecast devices. The spotify clientid/secret I am using are the one that I use to talk to my deloper account per the prerequisites for getting the Spotify Integration working. Spotify working flawlessly. Got your script all customised to my devices. Any ideas apprecaited

Did you install SpotCast? If not, the scripts will not work. Use HACS as per my instructions

Yeah I did - I think I’m on the right track - I can use the developer tools to send to the entity name of the spotcast.start service but not the device_name (friendly name). I’ll continue to troubleshoot

I know this has been marked solved, but I have the same question and would like to see if there is a way to do this with something that isn’t a google cast media player.

Anyone have any other ideas?

1 Like

Didn’t get this working, the friendly name wasn’t rewritten correctly to the entity-id as I use space in my names. And Spotcast was asking for the device_name. Ended up with this, which is even easier anyway:


# Spotify Start Playback
  alias: 'Spotify: afspelen'
    - service: spotcast.start
        device_name: "{{ states('input_select.speakers') }}"
        force_playback: true
  mode: single
  icon: mdi:spotify

And automation:

# Muziek
- id: spotify_device_selected
  alias: 'Spotify: Device Selected'
  description: 'Starts music playing on the selected Chromecast Audio device'
  - platform: state
    entity_id: input_select.speakers
  condition: []
  - service: script.turn_on
    entity_id: script.spotify_start
  mode: single

Instead of having the script in the Lovelace GUI, I have playlists + radio available in a input_select, with a button to play the selected music to the selected speaker.

1 Like

I am using a docker install and I cant find the spotify.yaml and/or the config/packages directry? Can anyone help?

It’s because he has split his configuration into packages. You can just put “spotify:”, “spotcast:” and “input_select:” in your configuration.yaml, “automation:” in your automations.yaml and “script:” in your scripts.yaml

Thank you, I was just reading about splitting packages and you are %100 spot on.

Logger: homeassistant.components.hassio
Source: components/hassio/
Integration: (documentation, issues)
First occurred: 14:02:33 (1 occurrences)
Last logged: 14:02:33

Invalid config for [script]: [spotify_start] is an invalid option for [script]. Check: script->script->script->spotify_start. (See /config/configuration.yaml, line 10). Invalid config for [automation]: [automation] is an invalid option for [automation]. Check: automation->automation. (See /config/configuration.yaml, line 9).

Nearly there but get this? Any ideas?

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

These are configuration.yaml lines 9,10 etc??


Some questions:

  • If you start a song on for ex google hub 1 and you want to start a second song onf google hub 2… will that stop the first song played or not?
  • I love your solution, but i got sonos devices too, can i integrate that too in the same way so i can chose the correct mediaplayer (google device or sonos device)

There is a service “plex.play_on_sonos” which I presume you can use.

Huh? i don’ t have plex.
I want the same spotify source to play on sonos… too as like with the google home devices using the spotcast

Unfortunately this exact solution will not work for Sonos, as neither Spotcast or the Spotify component supports Sonos.

Sonos is of course supported by Home Assistant, and you will get your Sonos Devices as media players, however you will not be able to target them directly from Spotify which is what Spotcast makes possible for Chromecast devices. However there should be some other ways to initiate playback, but that should probably be discussed in a separate thread.