Spotify - Help - How add 'source' by default

Hi Everyone,
A very newbie question here
Could someone please advise how l could have ‘source’ automatically applied to the default spotify card?
I have two images
Image#1 shows the current view with no source selected by default
Image#2 show the source after l have manually selected it from the drop-down within the Spotify card

As I only have 1 source, l would like to remove having to manually select the source each time before being able to play music.

If you planning to advise to use the mini-media card instead, could please provide sample yaml configuration that applies the source automatically.

My prefference is the use the default Spotify card if possible

Thanks in advance!

Image1
Image2

What version of HA are you using? I don’t even get the source field in my Spotify media player.

image

I’m also surprised you have an item in your source list at all. Are you trying to add it manually? The spotify media player doesn’t usually populate the source or source_list until you’ve started it on another spotify device or with spotcast.

Hi Jason,

I believe l am running the latest version via my Synology Docker

HA

It would good to simply play music without having to manualy select the source from the drop-down list

The source and source list are normally not populated until the media player is on. In the case of the Spotify media player, that means media is already playing, so the source would already be selected.

Spotify usually “forgets” its source list when it’s been off for a couple of minutes, which means that source select box shouldn’t even be there (see my previous screenshot) when nothing is playing on Spotify. Which also means you can’t preselect a source. When Spotify is playing, the source should obviously already be selected.

image

I have a TV (LG - WebOS) that forgets the source list like Spotify when it turns off so I used it to test the following automation. However, the difference is the TV will populated the source list when it turns on. The Spotify source list is usually only populated with the media player Spotify is playing on, and again, it should already be selected.

This is why I previously asked if you were trying to set the source list manually somewhere in your config. The source you show is pretty weird also - it looks like the device ID or something instead of the media player name.

Anyway, this automation will automatically select the HDMI source when my Bedroom TV is turned on. You can set the entities and source to your Spotify media player and try it out. I don’t think it will work because the Spotify media player must already be playing for the source list to populate.

Example Automation
automation:
  - id: media_player_auto_select_source
    alias: 'Media Player Auto Select Source'
    description: 'Auto select media player source.'
    max_exceeded: silent
    trigger:
      - platform: state
        entity_id: media_player.bedroom_tv
        from:
          - unknown
          - idle
          - 'off'
    action:
      - wait_template: "{{ 'HDMI 1' in state_attr('media_player.bedroom_tv','source_list') }}"
        timeout: 60
        continue_on_timeout: false

      - service: media_player.select_source
        target:
          entity_id: media_player.bedroom_tv
        data:
          source: HDMI 1

Interested to hear how you make out.

I have the same issue and also just one source device.

Once you stop playing Spotify for a few minutes the active session seems to end and the media player says the state is ‘Idle’, the media player UI element stops showing the last played album art and returns to it’s default color. When this happens the ‘source’ also gets deselected. If I try to start playing Spotify from Home Assistant while in this state I get an ugly unhandled error:
“Failed to call service media_player/media_play. No active playback device found”

In order to get it working again I have to click into the player card settings, manually select the source again from the drop-down list (even though it’s the only entry), then return to the player, at which point it works.

This doesn’t seem right.

Screenshots of the problem.

When Spotify goes ‘Idle’ the player card goes into it’s ‘blank’ state. If you try to press ‘Play’ or select any playlist at this point, you get a service error:

In order to be able to play any media, you have to open the card’s options modal:
Spotify2

Then select the source device (even though there is only one, it doesn’t auto-select this):
Spotify3

As soon as you do this, the player card pops back to life and you can play songs or playlist from the card.

What I would want to do is set a ‘default’ source for the Spotify integration, so that when you press play or try to play media, if it doesn’t already have a source selected, it will select the default source instead of simply erroring.

1 Like

Same problem here. I’m surprised this isn’t complained about more.

1 Like

Has anyone found a solution to this problem? I’m also running into the exact same thing and would like to get it fixed.

1 Like

It’s been a while, but this I was still having this problem once Spotify switches to idle (which seems to happen after 10 minutes of being paused). This works for me to wake Spotify up (and not take too long unless it has to). I call this at the top of any script that will play music.

connect_spotify:
  sequence:
    - condition: or
      conditions:
        - condition: template
          value_template: '{{ state_attr("media_player.spotify", "source") != "mini"  }}'
        - condition: template
          value_template: '{{ states("media_player.spotify") == idle }}'
    - service: media_player.select_source
      continue_on_error: true
      target:
        entity_id: media_player.spotify
      data:
        source: "mini"
    - delay: "00:00:10"
    - service: homeassistant.update_entity
      continue_on_error: true
      data: {}
      target:
        entity_id: media_player.spotify
    - if:
        - condition: template
          value_template: '{{ state_attr("media_player.spotify", "source") != "mini"  }}'
      then:
        - delay: "00:00:25"
        - service: media_player.select_source
          target:
            entity_id: media_player.spotify
          data:
            source: "mini"

Same ‘problem’ here and i’m also suprised there is no solution found for this yet.

@bryand @fmon @Matrox1983 @BigIron @supersebbo @jazzyisj @Fade2Gray
FYI - I created a SpotifyPlus integration that allows you to set a default device, provides near real-time UI updates (using smart polling), a ton of custom services, and much more. Check out the links below for more information.

Hope it helps!

More Information Links

3 Likes

I’m replying to myself because the workaround that I posted mysteriously stopped working. Trying to select a source from a script now yields a “service not supported” error; trying to select it manually does nothing and yields no error.

Edit: I installed @thlucas’ integration and now everything works great!

2 Likes