homeassistantcomponent_spotifyplus: Sonos Arc Control Errors (Lukas)
I get this response from my sonos speaker (using a ikea symfonisk):
Failed to call service spotifyplus.zeroconf_device_connect. ZeroconfResponse: SpotifyError=“0” Status=“103” StatusString=“ERROR-UNKNOWN”
While trying to call this service:
service: spotifyplus.zeroconf_device_connect
data:
entity_id: media_player.spotifyplus_lukas
host_ipv4_address: 192.168.1.121
host_ip_port: 1400
cpath: /spotifyzc
username: <canonical>
password: <devicePassword>
Let me know if you have any other ideas… It would be sooo sick getting this to work
Note: using the .31 release from a few hours ago
_Originally posted by @s00500 in https://github.com/thlucas1/homeassistantcomponent_spotifyplus/discussions/22#discussioncomment-9864874_
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 74 (40 by maintainers)
Got it, thank you.
Based on the
getInforesponses, you have 4 Spotify Connect devices: A3Main, LBsRoam, Workroom, and Living Room.The
getInfoJSON response for each indicates atokenType="authorization_code". I have not encountered this token type before in my Spotify Connect Zeroconf protocol research.With that said, what we need to do is to capture the mDNS protocol data flow between the Spotify player (preferably the desktop version so you can Wireshark trace it) and the Sonos device. I need to see what the
addUserrequests look like, and try to mimic the flow.To do this, pick one of the 4 devices (e.g. Workroom). We will use the IP address of that device (e.g. 192.168.1.121) in the steps below.
The following instructions (generic format using my device) can be found on the SpotifyPlus Wiki documents on GitHub.
Spotify Connect Device Tracing
The following walks you through how to trace Spotify Connect activity that takes place between the Spotify player (e.g. Spotify desktop app) and the Spotify Connect device (e.g. Bose Soundtouch, Sonos, Yamaha, etc).
Requirements
The following are required in order to capture Spotify Connect device activity:
Capture Login Flow
Use the following steps to capture the Spotify Connect logon flow.
Ensure that the Spotify desktop application is shut down; once we start it back up, it should re-discover any Spotify Connect devices on the network as well as log them in.
Start the network trace, using your tool of choice (e.g. WireShark, etc). You can limit the trace to the IP addresses of the Spotify Connect device and the Spotify Desktop application, or capture everything and filter the results later.
Issue a disconnect request to the device.
This will cause the device to logout from Spotify, and remove the device from the Spotify player’s active device list. You can use the
curlcommand-line tool to do this, using the Spotify Connect device endpoint URI andaction=resetUsersparameter as a POST request.Example, with response:
Start the Spotify desktop application.
This should re-discover any Spotify Connect devices on the network, as well as log them in.
Stop the network trace, and save the results.
I’m specifically looking for the
addUserrequests and responses. We should be able to mimic these via the SpotifyWebApiPython library to control the device.Hey @thlucas1 !
Yes, all well, thanks for checking in, I might give it a try sometime, currently still using as is, about every day from my streamdeck =D Will update and play with it more when I have time
Greetings! and awesome work!
You’re totally correct, it is using the local queue. I guess this is a lot better than no transfer happening at all, but would love to eventually get “full context” transfer working using Spotify Connect! Thanks for all your hard work on this, I really appreciate it. Let me know if I can help you with development at all!
@andrew-kennedy So to clarify, the playback is transferred FROM the Spotify Mobile app on your phone TO the Sonos Arc device; the track is playing on the Sonos Arc device, but the Spotify Mobile app on your phone indicates it is paused. Is that correct?
If so, it denotes that the Spotify track was transferred to the local queue of the Sonos Arc device and is being played via UPNP - the Spotify track is no longer being played by Spotify Connect. The Sonos Arc device is not using Spotify Connect at that point (it’s using it’s local queue), so the Spotify Mobile app on your phone indicates it (e.g. Spotify Connect) is paused since it is not in use. You can verify this by bringing up the Sonos Desktop app, and checking the status of the “Queue” area - it will indicate a status of “Queue (not in use)” if Spotify Connect is controlling the playback; otherwise, it will indicate a status of “Queue … x songs” if the Sonos device local queue is controlling the playback.
Here is an example of the Sonos App displaying a Spotify track that is playing via Spotify Connect - notice the “Queue (not in use) … x songs” status.
Here is an example of the Sonos App displaying a Spotify track that is playing via the Sonos device Local Queue - notice the “Queue … x songs” status.
At this point, it appears that the Sonos Arc lost its connection to Spotify Connect. The SpotifyPlus integration detected this, and transferred the track to the Sonos Arc’s local queue.
This is currently one of the limitations that I talk about in my Spotify Connect Brand Notes - Sonos document. Unfortunately I cannot get around this limitation until I can figure out how to re-connect the Sonos device to the Spotify Connect music source, so that local queues are not used.
@s00500 Thanks Lukas. I find it unusual that the
ActiveUseris not populated with a username or canonical userid while a Spotify track is playing for the user account.Can you try the following service calls (from the Developer Tools \ Services form) and let me know what the response is that you get? Just change the YOUR_SPOTIFY_PASSWORD to your Spotify password.
I don’t think the
loginidparameter value was specified in the Script Test Connect step. Just wondering if that might make a difference.This one will test the non-canonical username value, along with the loginId value.
This one will test the canonical username value, along with the loginId value.
Thanks
Can you try the following service call (from the Developer Tools \ Services form) and let me know what the response is that you get? Prior to executing the call, there needs to be a Spotify track (or playlist) playing on the 192.168.1.121 Sonos device.
I’m looking to see what it returns for the listed results while a Spotify track is actively being played on the device.
I want to see what it returns for the following properties: (example values listed for my device): … SpotifyError: 0 Status: 101 StatusString: OK ResponseSource: null AccountReq: DONTCARE ActiveUser: xxxxxxxxxxxxxxx Availability: “” ClientId: 79ebcb219e8e4e9a892e796607931810 DeviceId: 30fbc80e35598f3c242f2120413c943dfd9715fe
So I did this by checking in a webbrowser, as this is the only place where I can only see these devices fresh after activation.
the resetUsers certainly worked, the response was weird again though:
Procedure I did:
Can you start a Wireshark trace, run the script, then send me the trace file?
My fear here is that the encrypted blob contains different information when TokenType=“authentication_code”. If that is the case, then I may not have a solution as I don’t know what the Spotify SDK is expecting in that blob value for that token type.
Let me take a look at the trace first though, to see if anything jumps out at me.
UPDATE - I just thought, how are you going to run a trace if you’re not on the HA machine? LOL
Let me do some more searching to see if I can find out what’s in the blob for token type “authentication_code”
Hey @thlucas1, thanks for clear instructions, I have sent you a new capture that contains the addUser response (Meanwhile: big thanks for your amazing response time!!!) Let me know if you need anything else
@s00500 Hi Lukas.
I wrapped up the issue with the other user, and am ready to tackle the issue with your Sonos Arc. With that said, can you please update to the latest SpotifyPlus v1.0.38, and try your test scenario again? There have been a bunch of changes with return-code processing between v1.0.32 and v1.0.38.
Please let me know when you get a minute. Thanks - Todd