Open tYn0 opened 1 year ago
@tYn0 Sonos has it's own very proprietary and unconventional way of connecting to Spotify. The Sonos integration is supposed to work out of the box with Spotify (don't know, don't have Sonos product). His there a reason you are trying to use Spotcast specifically with it?
That's the last mode I was describing - using media_player.play_media - this plays the requested Spotify song/playlist but it is not synchronized to Spotify Connect at all so it is not possible to control the volume/song etc. via Spotify apps or via media_player.spotify entity
Also, I didn't find a way to transfer current playback to Beam using the method above
ok I see. Saddly, not having a sonos device, it's impossible for me to work on it. I'll mark your ticket has help wanted, but this would probably imply integrating the Sonos API in the project, so I don't know how quick someone would arrive with a PR for that.
I may be able to provide some additional info on this.
As @tYn0 did mention, using Sonos this doesn't 'link' with Spotify and essentially copies the playlist to Sonos keeping it separate.
I've been trying to integrate with my Sonos:1 also allowing me to transfer music around my house, but this will only succeed when using the deviceID (this should allow it to be transferred to your Beam... sometimes). It appears that only devices noted as 'Google Cast' can be played to using the name (or at least in my testing).
With this, the deviceID for the Sonos can only (easily) be found by using a browser version of Spotify by inspecting the network, which is then presented with a URL like below.
This is triggered by changing the target device to the Sonos and should give a URL something like the below.
https://gew1-spclient.spotify.com/connect-state/v1/connect/transfer/from/<device1>/to/<sonosdevice>
However while this works. It has had one issue which I've experienced from time to time. If the device has not been used within the past 3 devices it will not play and the device has to be re-discovered by a Spotify client, meaning you might as well just open Spotify. As a side note this has not occurred when just transferring the music around my house so may also appear to be partly session based, I will need to test more to confirm this.
The issue I've come down to so far is around Spotify device discovery and this past 3 device thing, which may be bypassable by running a device search from HA. How to do that currently? I don't know is the short answer, but hope this helps.
In my experience using Spotcast to transfer playback to BEAM only works when the soundbar is already in the "Spotify Connect" mode - Play song on desktop app, change source via desktop app to BEAM (this sets it to Spotify Connect mode - second one I was describing in the original post).
Now you can transfer playback via Spotcast to any device including BEAM but only until BEAM is in this mode - if you start watching TV BEAM switches to TV mode and you can no longer use Spotcast to transfer playback or play music on BEAM
In my experience using Spotcast to transfer playback to BEAM only works when the soundbar is already in the "Spotify Connect" mode - Play song on desktop app, change source via desktop app to BEAM (this sets it to Spotify Connect mode - second one I was describing in the original post).
Now you can transfer playback via Spotcast to any device including BEAM but only until BEAM is in this mode - if you start watching TV BEAM switches to TV mode and you can no longer use Spotcast to transfer playback or play music on BEAM
Same experience here.
Related discussion: https://github.com/thlucas1/homeassistantcomponent_spotifyplus/issues/28
Bug Ticket
Describe the bug
Not sure if this is a bug or just needs to be better supported but here is what I found regarding Spotcast and Sonos BEAM 2 support. Beam has 3 modes in which it operates:
TV mode: As Beam is a soundbar it can play sounds from TV via HDMI. When Beam is used in this mode it is not registered on Spotify Connect so it is not shown in available devices on Web Spotify Player but it is shown under available devices in desktop Spotify app. Spotcast can't play music on Beam when Beam is in this mode.
State attributes:
Spotify Connect mode: In this mode Beam works great with Spotcast. It is displayed in available devices on the Web Client and desktop app as well. Only way to switch Beam to this mode is to use desktop app.
State attributes:
Sonos Spotify Connect mode This is a weird one. To switch to this mode you have to use media_player.play_media service. In this mode Beam is not registered on Spotify Connect (not shown under devices on Web Player but is shown on desktop app) and it is not synchronized with Spotify at all - no current track, no volume level synchronization etc. Spotcast can't play music on Beam when Beam is in this mode
Service call:
State attributes:
Conclusion: The main takeaway is that the Beam is always shown under availalble devices in desktop app irregardless of the mode in which Beam currently is and the only way to switch Beam to Spotify Connect mode is to use the desktop app which is rather cumbersome. As Beam is always shown in the desktop app there must be a way to switch Beam Spotify Connect mode via code.
Troubleshooting
Make sure to validate all the elements before submitting the ticket (Exception to the steps marked as optional)
sp_dc
andsp_key
values and restarted Home Assistant (see README)Environment