Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better support for Sonos BEAM 2 #376

Open
6 of 8 tasks
tYn0 opened this issue Feb 10, 2023 · 8 comments
Open
6 of 8 tasks

Better support for Sonos BEAM 2 #376

tYn0 opened this issue Feb 10, 2023 · 8 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed v5 Will be worked on in v5

Comments

@tYn0
Copy link

tYn0 commented Feb 10, 2023

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:

source_list:
  - TV
group_members:
  - media_player.beam
volume_level: 0.33
is_volume_muted: false
media_content_id: x-sonos-htastream:RINCON_542A1BDE55EE01400:spdif
media_content_type: music
media_title: TV
source: TV
shuffle: false
repeat: 'off'
queue_size: 1
device_class: speaker
friendly_name: BEAM
supported_features: 981567

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:

source_list:
  - TV
group_members:
  - media_player.beam
volume_level: 0.33
is_volume_muted: false
media_content_id: >-
  x-sonos-vli:RINCON_542A1BDE55EE01400:2,spotify:c9c9de108d23193635dbdd9a675a83b0
media_content_type: music
media_title: Magyarország
source: Spotify Connect
shuffle: true
repeat: 'off'
queue_size: 1
device_class: speaker
friendly_name: BEAM
supported_features: 981567
media_duration: 238
media_position: 0
media_position_updated_at: '2023-02-10T20:41:25.193519+00:00'
media_artist: Alestorm
media_album_name: Seventh Rum of a Seventh Rum (Deluxe Version)
entity_picture: >-
  /api/media_player_proxy/media_player.beam?token=REDACTED

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:

service: media_player.play_media
data:
  media_content_id: https://open.spotify.com/track/1nsFFVu0kypnIMsJBtIHYT?si=df35a641f223469d
  media_content_type: song
  enqueue: play
target:
  entity_id: media_player.beam

State attributes:

source_list:
  - TV
group_members:
  - media_player.beam
volume_level: 0.33
is_volume_muted: false
media_content_type: music
media_position: 0
media_position_updated_at: '2023-02-10T20:50:46.110373+00:00'
shuffle: true
repeat: 'off'
device_class: speaker
friendly_name: BEAM
supported_features: 981567
media_content_id: x-sonos-spotify:spotify%3atrack%3a1nsFFVu0kypnIMsJBtIHYT?sid=9&flags=8232&sn=2
media_duration: 249
media_title: Bite the Hook Hand That Feeds
media_artist: Alestorm
media_album_name: Seventh Rum of a Seventh Rum (Deluxe Version)
queue_position: 2
queue_size: 2
entity_picture: >-
  /api/media_player_proxy/media_player.beam?token=REDACTED&cache=03cf653118243601

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)

  • Using latest version of spotcast
  • Using latest stable version of Home Assistant
  • I have setup the Spotify integration in Home Assistant
  • I have renewed my sp_dc and sp_key values and restarted Home Assistant (see README)
  • (optional) I have Spotify Premium
  • (optional) I am using multiple accounts
  • (optional) I'm attaching relevant logs with level debug for component spotcast (see README)
  • (optional) I'm using entity_id in the service call and have tried device_name but the issue remains

Environment

  • Installation type: HA_OS
  • HA version: 2023.2.3
  • spotcast version: v3.7.0
@tYn0 tYn0 added the bug Something isn't working label Feb 10, 2023
@fcusson
Copy link
Collaborator

fcusson commented Feb 10, 2023

@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?

@fcusson fcusson added enhancement New feature or request and removed bug Something isn't working labels Feb 10, 2023
@tYn0
Copy link
Author

tYn0 commented Feb 10, 2023

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

@tYn0
Copy link
Author

tYn0 commented Feb 10, 2023

Also, I didn't find a way to transfer current playback to Beam using the method above

@fcusson
Copy link
Collaborator

fcusson commented Feb 11, 2023

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.

@fcusson fcusson added the help wanted Extra attention is needed label Feb 11, 2023
@LZStealth
Copy link

LZStealth commented Mar 14, 2023

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.

@tYn0
Copy link
Author

tYn0 commented Mar 14, 2023

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

@smarthomejunkie
Copy link

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.

@s00500
Copy link

s00500 commented Jul 3, 2024

Related discussion: thlucas1/homeassistantcomponent_spotifyplus#28

@fcusson fcusson added beta Related to the beta program v5 Will be worked on in v5 and removed beta Related to the beta program labels Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed v5 Will be worked on in v5
Projects
None yet
Development

No branches or pull requests

5 participants