While Im fully aware of that documentation of Spotify integration states that Sonos is not supported device in Spotify API and many threads on this forum discuss the same topic, Im wondering if there are any changes to this today? Or workaround that we might use?
I have latest version of HA (0.115.3) and integration with Spotify and Sonos (Sonos Gen 2). Playing playlist or track from Spotify on Sonos triggered by automation is highly desired.
I kinda found a workaround for this today, as I was looking for a solution since yesterday.
What you need is an echo dot (or any other Spotify connect device) and of course sonos speakers.
When I played around with the frontend, I played music via my bathroom echo dot. Randomly I clicked play on my media player for my bedroom sonos one and it picked of right in the middle of the track where the echo dot in the bathroom has stopped. A little try and error with scripts and now Iām able to start specific spotify tracks, albums and playlist (not yet working, but it should in theory ) directly on my Sonos speaker.
sonos_test:
sequence:
- service: media_player.select_source
data:
entity_id: media_player.spotify
# substitute with your spotify connect device name. In my case it's Echo Dot bathroom.
# I guess every Spotify connect device works, currently its only tested on echo dot
source: "Echo Dot bathroom"
- service: media_player.play_media
data:
# This is the spotify integration from the frontend
entity_id: media_player.spotify
# Get the spotify content URI via right-click on the title, playlist or album > share > Copy Spotify URI
media_content_id: "spotify:album:7GoZNNb7Yl74fpk8Z6I2cv"
# Media_content_type is "music" for tracks and apparently "playlist" even for albums and of course playlists
media_content_type: playlist
- service: media_player.media_play
data:
# Enter your sonos device media player here
entity_id: media_player.bedroom
While it is not really elegant, it works - at least for me! This script needs probably a little more work for some cases, e.g. what happens when music is already played on the sonos (need to stop and clear the queue?), the echo dot still shows as playing while there is obviously no sound coming from it.
Any suggestions and improvements are more than welcome
EDIT: it seems that sometimes the ālinkā from Sonos to Spotify is broken and it starts playing in the Echo Dot Bathroom (e.g. when using the native Sonos app to play something in the bedroom) This is easily fixed by creating a ālinkā between Sonos and spotify again by either telling Alexa to play something in the bedroom or using the Spotify App and choosing the Sonos speaker.
Since Sonos One (2. gen) already have Google Assistant support (and I have configured it), Im able to play Spotify tracks on Sonos by talking to Google Assistant. So I might not need another Spotify connect device, like echo dot?
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.
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ā¦
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.
@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
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:
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