Make hass.io speaker/device for Spotify via command

Hi, I’m using Hass.IO on a raspberry with the Spotify connect plugin.

Following this tutorial: Spotify - Home Assistant I managed to connect to Spotify and control the player, IF hass.io is selected as a player in spotify.

But if that is not the case, because I maybe listened to spotify on my phone or PC in betwwen, I get this error:

Failed to call service media_player/media_play_pause. http status: 404, code:-1 - https://api.spotify.com/v1/me/player/play: Player command failed: No active device found

Is there a way to tell spotify to use hass.io as a player via a command/service/event, before sending a playlist command?

I have the same problem and im trying to figure out why is happening. I will let you know if I found something.

1 Like

fixed it, there is a select source service that you can add to the automation before hitting the play button :slight_smile:

 - data:
      source: Hass.io
    entity_id: media_player.spotify_simatao
    service: media_player.select_source
  - data:
      entity_id: media_player.spotify
      media_content_id: spotify:user:spotify:playlist:[enter playlist id here]
      media_content_type: playlist
    entity_id: media_player.spotify_simatao
    service: media_player.media_play

Hello, where can I insert this code to hard select the source? Is this an automation?
I want to hard set the source for spotify to my iPad. Hope it works that way…

2 Likes

@simatao your solution it’s what I need too.
I’m pretty new to the HA world, would you mind to explain where to put the YAML configuration you posted?
I tried to add an automation that call the service select source, but I somehow can’t trigger it when I hit the play button on the media player card.
Thanks for the support :slight_smile: