Spotify playback device is inactive in automation but can be selected in entity

It took a while to even get this to work because I hadn’t noticed it was failing due to “no active playback device”. If I choose the playback device on my mobile or even from the entity listed in the Spotify integration it then works but always plays back on the last selected device and not the one I want it to.

Is there a way to activate a Spotify playback device? As you can see I have a bunch of devices Spotify is “aware” of.

I have created a script (in the “Automations and Scenes/Scripts” section) as follows:

alias: Play Spotify Daily Mix 1
sequence:
  - service: media_player.volume_set
    data:
      volume_level: 0.33
    target:
      entity_id: media_player.marantz
  - service: media_player.select_source
    data:
      source: Marantz
    target:
      entity_id: media_player.spotify_ha_app
  - service: media_player.play_media
    target:
      entity_id: media_player.spotify_ha_app
    data:
      media_content_type: playlist
      media_content_id: >-
        https://open.spotify.com/playlist/37i9dQZF1E373YlSZIUfcn?si=fb3a3e177104449a
mode: single
icon: mdi:spotify

I thought at first this was a Denon HEOS issue but it failed the same when selecting “R2D2” (my Echo Dot 2 sitting inside my 3D printed R2D2 :slight_smile: ) as the source.

I have not pursued the Spotcast plugin thing as I am not using Google or a Chromecast (which is what it seems to be for). I don’t want to install a whole lot of plugins/integrations I don’t need while I’m trying to figure this Home assistant thing out (only been using it for 1 month).