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.

2 Likes

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

@thlucas the link to the HACS installation is giving a 404 ://

@thebarnidentity
Thanks Brandon, fixed the HACS link. It looks like they updated their site, and all of their links changed. Thanks for bringing this to my attention.

I’m a little late to reply on this topic, but thought it was worth a quick follow up post because I ended up down a few rabbit holes trying to solve. My Spotify automations using Node Red stopped working correctly some time ago, possibly due to issues or changes that others have also experienced. I spent some time on it, and I was able to get the default Spotify integration setting source and starting consistently, even when idle, by using the following:

description: ""
mode: single
triggers:
  - trigger: webhook
    allowed_methods:
      - POST
      - PUT
    local_only: true
    webhook_id: "-XXXXXXXXXXXXXX"
conditions: []
actions:
  - action: media_player.select_source
    target:
      entity_id: media_player.spotify_myaccount
    data:
      source: Everywhere
  - delay:
      hours: 0
      minutes: 0
      seconds: 3
      milliseconds: 0
  - action: media_player.play_media
    target:
      entity_id: media_player.spotify_myaccount
    data:
      media_content_id: https://open.spotify.com/playlist/XXXXXXXXXXX
      media_content_type: playlist
alias: Test Spotify Start

It looks similar to some of the other yaml in this thread that were stated not to work, but maybe there have been some recent updates to the integration to fix. I’ve used this several times in the last few days and it seems to work fine now.