Playing Spotify playlist on Sonos triggered by automation

I don’t know about Google Assistant as I’m using Alexa - but somehow the integration in Sonos is different as you cannot cast or stream music to the Smart Assistant functionality but only to Sonos directly. So yes - you need a different (true) Spotify Connect device in my opinion.

Ok, I will give it a try and see how it goes first.

I don’t know if this is what you’re after… but you can add Spotify playlists to “My Sonos” via the Sonos app and the according playlists will show up as a source on the Sonos media_player. Those can be called very easily from automations, scripts etc…

2 Likes

This works only to a certain extent as the “My Sonos” favorite section is limited to ~80 playlists
I reached the limit when I wanted a random audiobook player (over 200 audio books) from spotify and tried adding all of them to My Sonos.

But yes, for only a few playlists this is the easiest solution!

Thanks, that is better then nothing. But still limits different use cases using media player and the new Tags support where Im planning to create a jukebox game, where random track is played and people must guess artist and song (for example). Or just playing random track based on the mood.

I have added the ability to play Spotify URIs to the Sonos integration, will be in Home Assistant 0.117.

You can try it out with HACS now, see Trying to play Spotify album on Sonos.

1 Like

@amelchio I have installed Sonos Beta integration in HACS (master-branch version), but when calling the service below, I get following error message in logs:

Logger: custom_components.sonos.media_player
Source: custom_components/sonos/media_player.py:461
Integration: Sonos ([documentation](https://www.home-assistant.io/integrations/sonos))
First occurred: 12:46:05 AM (1 occurrences)
Last logged: 12:46:05 AM

Error on play_media with UPnP Error 800 received: from 192.168.0.14

(this is the IP of Sono One)

Service call:

- service: media_player.play_media
  data:
    entity_id: media_player.sonos_stue_1
    media_content_id: 'https://open.spotify.com/album/1bt6q2SruMsBtcerNVtpZB'
    media_content_type: music

Please try with a URI that you create yourself to make sure the music is available in your region.

I tried creating my own URI, both “Playlist link” and “Spotify URI”. The error that appears in my log is:

'Logger: homeassistant.components.sonos.media_player
Source: components/sonos/media_player.py:461
Integration: Sonos (documentation, issues)
First occurred: 18:52:38 (2 occurrences)
Last logged: 19:12:55

Error on play_media with UPnP Error 714 received: Illegal MIME-Type from 192.168.50.143’

I did “Copy Album Link” but still receiving the same error message. Do I need to delete existing Sonos Integration before installing the Sonos (Beta) Integration through HACS maybe?

A side note: Since HA can´t automatically discover my Sonos One speakers I have following configuration:

sonos:
  media_player:
    hosts:
      - 192.0.0.14
      - 192.0.0.15

What does “UPnP Error 800” mean?

I think this means that you did not install the beta Sonos integration. It is in 0.117.

If it is not due to an invalid URI, I don’t know what it means.

1 Like

How about my second question?

Do I need to delete existing Sonos Integration before installing the Sonos (Beta) Integration through HACS maybe?

You don’t have to delete it.

Why is that?

Forget it! Just some missunderstanding from my side! I figured out that Sonos Integration actually did manage to automatically discover my Sonos player, so I no longer need to configure the IPs manually. But still receiving the same error message :frowning:

@amelchio Just checking if it is required to add the Spotify playlist in Sonos App before calling the media_player.play_media service?

That is not required.

@ismarslomic, did you ever figure this out? I’m getting the same thing.

Not yet, but I have created issue at Github which you could follow and contribute to: https://github.com/home-assistant/core/issues/42538

This issue has been fixed in HA 0.118