[SOLVED] Trying to play a Spotify playlist on an Echo device

I’m trying to have a card to lets me select a playlist and play that on a selected Echo device.
My first card with TuneIn works, but now with Spotify I keep getting the following error in the logfiles:

Error doing job: Task exception was never retrieved
15:48:39 – (ERROR) components/spotify/media_player.py

Play Spotify on Alexa : Error executing script. Error for call_service at pos 3: No active playback device found
15:48:39 – (ERROR) Script

HTTP Error for PUT to https://api.spotify.com/v1/me/player/play with Params: {} returned 404 due to Player command failed: No active device found
15:48:39 – (ERROR) components/spotify/media_player.py

I tried several example scripts here (like Spotify Playlist Player) but I can’t find what I’m doing wrong.
The script:

alias: "Play Spotify on Alexa "
sequence:
  - service: media_player.select_source
    data:
      entity_id: media_player.spotify_parki
      source: >
        {%if is_state("input_select.radio_speaker","Kitchen")%}
        media_player.kitchen        {%elif
        is_state("input_select.radio_speaker","Bathroom")%}
        media_player.bathroom {%elif
        is_state("input_select.radio_speaker","Office Robby")%}
        media_player.office_robby {%elif
        is_state("input_select.radio_speaker","Office Cindy")%}
        media_player.office_cindy {%endif%}
  - service: media_player.volume_set
    data:
      entity_id: >
        {%if is_state("input_select.radio_speaker","Kitchen")%}
        media_player.kitchen {%elif
        is_state("input_select.radio_speaker","Bathroom")%}
        media_player.bathroom {%elif
        is_state("input_select.radio_speaker","Office Robby")%}
        media_player.office_robby {%elif
        is_state("input_select.radio_speaker","Office Cindy")%}
        media_player.office_cindy {%endif%}
      volume_level: "{{ states(\"input_number.radio_volume\") }}"
  - service: media_player.play_media
    data:
      entity_id: media_player.spotify_parki
      media_content_type: playlist
      media_content_id: >
        {% if is_state("input_select.spotify_playlist", "Joris + Parki") %}
        https://open.spotify.com/playlist/37i9dQZF1EJx1tpPWBMceb?si=6ca4f78fb3ae46af
        {% elif is_state("input_select.spotify_playlist", "Robby Dinner Mix") %}
        https://open.spotify.com/playlist/37i9dQZF1EIebqo6QcTy88?si=776115f763184651
        {% elif is_state("input_select.spotify_playlist", "Davy Dinner Party")
        %} 
        https://open.spotify.com/playlist/2HhCmAPo05NhMU5VtF4jpR?si=07d02df425494576 
        {% elif is_state("input_select.spotify_playlist", "Op het gemak") %}
        https://open.spotify.com/playlist/5aNq093MGZWd2ZkYPjs4n4?si=6a1a2b29e2b34d2d
        {% elif is_state("input_select.spotify_playlist", "Weakend") %}
        https://open.spotify.com/playlist/37i9dQZF1DX7CfwQr5vk7g?si=9691523bcb564278 
        {% elif is_state("input_select.spotify_playlist", "Favorieten") %}
        https://open.spotify.com/playlist/1ANEWrD6Z1u1RhPQEN7nwP?si=3cabd2442d264385 
        {% elif is_state("input_select.spotify_playlist", "Dansbaar na twee")
        %} 
        https://open.spotify.com/playlist/4qbJdHcFLjVnOsxywc6qfk?si=3fa7958ad92b4d2f
        {% endif %}
  - service: media_player.shuffle_set
    data:
      entity_id: media_player.spotify_parki
      shuffle: ‘true’
mode: single

Anybody got an idea what could be causing this error?

Found the problems:
I have to put the spotify player as the target and the source needs to be from the Spotify source list, not a media player:

- service: media_player.select_source
  target:
    entity_id: media_player.spotify_parki
  data:
    source:
      '{%if is_state("input_select.radio_speaker","Kitchen")%} Kitchen
      {%elif is_state("input_select.radio_speaker","Bathroom")%} Bathroom
      {%elif is_state("input_select.radio_speaker","Office Robby")%} Office Robby
      {%elif is_state("input_select.radio_speaker","Office Cindy")%} Office Cindy
      {%endif%}
      '

- service: media_player.play_media
  target:
    entity_id: media_player.spotify_parki
  data:
    media_content_type: playlist
    media_content_id:
      '{% if is_state("input_select.spotify_playlist", "Joris + Parki") %} https://open.spotify.com/playlist/37i9dQZF1EJx1tpPWBMceb?si=6ca4f78fb3ae46af
      {% elif is_state("input_select.spotify_playlist", "Robby Dinner Mix") %} https://open.spotify.com/playlist/37i9dQZF1EIebqo6QcTy88?si=776115f763184651
      {% endif %}
      '
1 Like