Play Spotify track on echo dot

Hello community, I’m trying to play a simple doorbell ringtone from spotify (as far I know, is not possibile for local mp3 file), but I’m failing.
I already intregated hassio with spotify and alexa so I can see both media player. I followed this guide for Spotify:

And this is the automation. But when I press the switch (Aqara one) nothing happen:

- id: divano_test_spotify
  alias: Divano test Spotify
  trigger:
    platform: event
    event_type: deconz_event
    event_data:
      id: divano_switch_7
      event: 1001
  action:
    service: media_player.play_media
    data:
      entity_id: media_player.echo_dot_sala
      media_content_id : "spotify:track:6jjDlCdxxxU6xxg2"
      media_content_type: "SPOTIFY"

Could someone help pelase? Thank you
Lucas

1 Like

Remove the space between media_content_id and :

In addition change media_content_type to music

media_content_type: "music"

Thank you for reply, with “spotify” the echo dot says: “Sorry I cannot find track 6jjDlCdxxxU6xxg2” obviously I double checket it and it works on browser if I use the long link like:
https://open.spotify.com/track/6jjDlCdxxxU6xxg2

If I use music, alexa says something like “I cannot use TTS…” :frowning:

Ok, here is the right sintax:

  action:
    service: media_player.play_media
    data:
      entity_id: media_player.spotify
      media_content_type: "music"
      media_content_id: "spotify:track:6jjDlCd8d5qBWTFU6t11g2"

The problem is that I have to activate a specific echo dot, it means I have to go to Spotify, select the echo dot, and then it works. Otherwise I got :

spotipy.client.SpotifyException: http status: 404, code:-1 - https://api.spotify.com/v1/me/player/play:
 Player command failed: No active device found

How can I specify to Hassio on which echo should play the song?
If I use this one, it doesn’t work:

entity_id: media_player.echo_dot_sala

Ah I see now, I somehow overread that you are using media_player.echo_dot_sala instead of media_player.spotify.

You need to add another action before your “play media” action, that selects the source in the spotify media player. Something like this:

  action:
    - service: media_player.select_source
      data:
        entity_id: media_player.spotify
        source: "Name of your echo dot in the spotify sources"
    - service: media_player.play_media
      data:
        entity_id: media_player.spotify
        media_content_type: "music"
        media_content_id: "spotify:track:6jjDlCd8d5qBWTFU6t11g2"

The name of the source can be found when you click on the spotify media player:

image

4 Likes

Thank you very much, it works perfect!!!

Glad that it works now :slight_smile: Please mark the post that helped you solve your problem as the solution, this way other people in the future will find the solution quickly.

Hi,
I have try the media_player.select_source with a Google Home Mini and does not work.
Any one with experience?

  • service: media_player.select_source
    data:
    entity_id: media_player.spotify_vacarsa
    source: media_player.sala_speaker

You can use the Spotcast custom component.

I need some help
I’ve sent this to developers tools/services:

service: media_player.select_source
data:
  entity_id: media_player.spotify
  source: media_player.first_floor
service: media_player.play_media
data:
  entity_id: media_player.spotify
  media_content_type: "music"
  media_content_id: "spotify:track:37i9dQZF1DX5Flpl98I3He"

and I get a long voice message from alexa:
"sorry text to speach can only be called with a notify dot alexa underscore media service…

Hi Guys,
do you know how to set up the script to play playlist but songs random?

Try with this ( you need to complete it with data from your integration)

  - service: media_player.shuffle_set
    data:
      entity_id: media_player.spotify_SOMETHING
      shuffle: true
  - service: media_player.play_media
    data:
      entity_id: media_player.spotify_SOMETHING
      media_content_type: playlist
      media_content_id: PLAYLIST URL

Hi could u please help me with this problem? I’m absolutely new with Home Assistant:
When my Amazon Echo Dot goes into idle than the automation in Home Assistant don’t work.

This is the code that Im trying to get worked:

-service: media_player.select_source
      data:
        entity_id: media_player.spotify
        source: "Andreas' 2. Echo Dot"
    - service: media_player.play_media
      data:
        entity_id: media_player.spotify
        media_content_type: spotify://playlist
        media_content_id: spotify:playlist:01Vmn16TNw7s5tYBEpKLOc


service: media_player.play_media
target:
  entity_id: media_player.spotify_spotifybad
data:
  media_content_id: spotify:playlist:01Vmn16TNw7s5tYBEpKLOc
  media_content_type: spotify://playlist
metadata:
  title: Andi
  thumbnail: >-
    https://mosaic.scdn.co/640/ab67616d0000b27312bb749b18499d0abded3f63ab67616d0000b2735c34d7a87663652675cf3264ab67616d0000b273d14cd6c24470c6de13265d0aab67616d0000b273f5768db89dd8ac30fd0e414f
  media_class: playlist
  children_media_class: track
  navigateIds:
    - {}
    - media_content_type: spotify://current_user_playlists
      media_content_id: current_user_playlists
    - media_content_type: spotify://playlist
      media_content_id: spotify:playlist:01Vmn16TNw7s5tYBEpKLOc


Sorry if this is absolutely wrong.