hklages / node-red-contrib-sonos-plus

A set of Node-RED nodes to control SONOS player in your local network.
MIT License
76 stars 14 forks source link

group.queue.urispotify throws a upnp 800 error #142

Closed ghassansalloum closed 3 years ago

ghassansalloum commented 3 years ago

Description

Trying to set the queue to this album for example: spotify:album:6gificznvuk0ddZK9dmv3T (I tried other albums, tracks, playlists, all return this error. It never worked for me, I've been trying for 4 days.) I get this error "Sonos error on AddURIToQueue UPnPError 800 (undefined)"

Stack trace:

31 Mar 02:34:04 - [error] [sonos-universal:b2795f47.6fddc] group.queue.urispotify:Sonos error on AddURIToQueue UPnPError 800 (undefined) :: Details: {"stack":"SonosError: Sonos error on AddURIToQueue UPnPError 800 (undefined)\n at AVTransportService.handleErrorResponse (/home/pi/.node-red/node_modules/@svrooij/sonos/lib/services/base-service.js:231: 23)\n at runMicrotasks ()\n at processTicksAndRejections (internal/process/task_queues.js:97:5)\n at async AVTransportService.handleRequestAndParseResponse ( /home/pi/.node-red/node_modules/@svrooij/sonos/lib/services/base-service.js:204:15)\n at async AVTransportService.SoapRequestWithBody (/home/pi/.node-red/node_modules/@svrooi j/sonos/lib/services/base-service.js:97:16)\n at async AVTransportService.AddURIToQueue (/home/pi/.node-red/node_modules/@svrooij/sonos/lib/services/av-transport.service.js:6 4:41)\n at async SonosDevice.AddUriToQueue (/home/pi/.node-red/node_modules/@svrooij/sonos/lib/sonos-device.js:90:16)\n at async Object.groupQueueUriFromSpotify [as group. queue.urispotify] (/home/pi/.node-red/node_modules/node-red-contrib-sonos-plus/src/sonos-universal.js:1334:5)","message":"Sonos error on AddURIToQueue UPnPError 800 (undefined)" ,"Action":"AddURIToQueue","FaultCode":"s:Client","Fault":"UPnPError","UpnpErrorCode":800,"name":"SonosError"}

What node/command (topic)/state (payload)

node: Universal command: group.queue.urispotify state: Trying to set the queue to this album for example: spotify:album:6gificznvuk0ddZK9dmv3T (I tried other albums, tracks, playlists, all return this error) I get this error "Sonos error on AddURIToQueue UPnPError 800 (undefined)"

In case of a bug: Are you able to reproduce the error

Yes

Versions and Infrastructure

what system: RaspberryPi node-red-contrib-sonos-plus version: 5.0.3 Node-RED version: v1.2.9 NodeJS version: v12.21.0

see: [https://flows.nodered.org/flow/a5c42641bf33dd0da9bfd4426a06950a]

image

hklages commented 3 years ago

Strange. When I use the same spotify:album:6gificznvuk0ddZK9dmv3T payload 9 songs from Nena are inserted into the queue and I don't get any error message.

Looking at the screen shot: Looks fine.

What about the config node? When you re-deploy all flows, is there any error message like - ip not found - for the universal node. How does configuration "kitchen" looks like?

ghassansalloum commented 3 years ago

This is what I see when I deploy: 'ok ready', and most other topics execute successfully (e.g. group.get.volume), but I haven't tested all of them. Here's an example:

image

Odd that it works flawlessly for you. I'll be happy to run some additional debugging on my side, and would appreciate some pointers into where to start looking.

I already looked up the Upnp '800' status and the upnp official spec states that this is a custom error code (which Sonos the company would have defined), so that wasn't very helpful.

The speaker in question has this config: Sonos OS: S2 Version: 13.0 (build 62186220) Hardware version: 1.20.1.6-1.1 Series ID: A200 IP Address: 192.168.xxx.xxx

hklages commented 3 years ago

Ok - so the basics work. That's good to know.

Could you please use the official SONOS app (apple, android, desktop) and go to browse, Spotify and select a Spotify album. Are you able to play that on the SONOS player? If not: Check your Spotify set up for Sonos If yes: Please add that Album to My Sonos (hamburger menu) and try mysonos node (mysonos.item.export) and universal node (group.play.export). Does that work?

Debugging: You can set the ENV variable DEBUG in your system DEBUG=nrcsp:* That will log a lot.

ghassansalloum commented 3 years ago

Exporting a MySonos-saved Spotify album that way and playing it on the speaker worked. image

Now onto debugging adding a Spotify URi directly to the Universal node without going through the route of adding the albums to My Sonos first. (my use case is one where the list of albums I want to play is not known prior to entering the node-red flow, so I can't go through the route of adding them to My Sonos first)

hklages commented 3 years ago

OK. In what country do you live? Hope not in New Zealand. Spotify needs the right region. Please compare the outcome of the export metadata with your playlist shortcut.

On Wed, Mar 31, 2021, 18:24 GusS @.***> wrote:

Exporting a MySonos saved spotify album that way worked. [image: image] https://user-images.githubusercontent.com/9168276/113177657-9e65e580-9202-11eb-9bff-7feb1ae4ae62.png

Now onto debugging adding a Spotify URi directly to the Universal node without going through the route of adding the albums to My Sonos first. (my use case is one where the list of albums I want to play is not known prior to entering the node-red flow, so I can't go through the route of adding them to My Sonos first)

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/hklages/node-red-contrib-sonos-plus/issues/142#issuecomment-811204841, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEDZCH22KFRS42SC4QBXRKTTGNEEDANCNFSM42DNGPBA .

ghassansalloum commented 3 years ago

I'm in the US, and have a Spotify Premium subscription (in case it matters at all).

The Uri that I am (unsuccessfully) playing on the speaker has the very simple format like you saw: spotify:album:<identifier>

The output of the MySonos export is a bit more involved:

uri: "x-rincon-cpcontainer:1004206cspotify%3aalbum%3a6KrB8Sf5g2WpCcWUOE9CpE?sid=12&flags=8300&sn=1" metadata: "<DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/&quot; xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:r="urn:schemas-rinconnetworks-com:metadata-1-0/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"><item id="1004206cspotify%3aalbum%3a6KrB8Sf5g2WpCcWUOE9CpE" parentID="10052064spotify%3aartist%3a0YLo7NrjjafYk8rbapwCZk" restricted="true"><dc:title>Her New Orleans Music</dc:title><upnp:class>object.container.album.musicAlbum</upnp:class><desc id="cdudn" nameSpace="urn:schemas-rinconnetworks-com:metadata-1-0/">SA_RINCON3079_X_XXXXXXXXXXXX</desc></item></DIDL-Lite>"

URL-decoding the above uri, for readability, I get: uri: "x-rincon-cpcontainer:1004206cspotify:album:6KrB8Sf5g2WpCcWUOE9CpE?sid=12&flags=8300&sn=1"

ghassansalloum commented 3 years ago

Also, when you say set the ENV variable DEBUG in your "system", and having never done that before myself, is the "system" here referring to NodeJS? NodeRed? or the NRCSP node-module itself? Thanks for educating me.

hklages commented 3 years ago

It seemed to be the region. Default is Europe 2311, yours seemed to be 3079.
Please send me the original output of mysonos.export.item - it is a json with uri, metadata and processingType. Use the <> to paste it a code (see formatting line).

I will try to create a template based on that.

hklages commented 3 years ago

ENV or env

ghassansalloum commented 3 years ago

This is the output of an mysonos.export.item instance:

{"_msgid":"577d389d.127488","payload":{"uri":"x-rincon-cpcontainer:1004206cspotify%3aalbum%3a6KrB8Sf5g2WpCcWUOE9CpE?sid=12&amp;flags=8300&amp;sn=1","metadata":"&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:r=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;&lt;item id=&quot;1004206cspotify%3aalbum%3a6KrB8Sf5g2WpCcWUOE9CpE&quot; parentID=&quot;10052064spotify%3aartist%3a0YLo7NrjjafYk8rbapwCZk&quot; restricted=&quot;true&quot;&gt;&lt;dc:title&gt;Her New Orleans Music&lt;/dc:title&gt;&lt;upnp:class&gt;object.container.album.musicAlbum&lt;/upnp:class&gt;&lt;desc id=&quot;cdudn&quot; nameSpace=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot;&gt;SA_RINCON3079_X_#Svc3079-0-Token&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;","queue":true},"nrcspCmd":"mysonos.export.item"}

Is this what you're looking for? It does not have processingType...

hklages commented 3 years ago

Let try this:

Import the flow into your system and modify the config node - enter one of your players. The first inject will fail and hopefully the others will work. Now its bedtime here - good night.

[{"id":"fc4246df.bd2ef8","type":"inject","z":"55805384.a4695c","name":"Example 1","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"spotify:album:6gificznvuk0ddZK9dmv3T","payloadType":"str","x":120,"y":1280,"wires":[["a5631e5b.0e258"]]},{"id":"a5631e5b.0e258","type":"switch","z":"55805384.a4695c","name":"album?","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"spotify:album:","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":380,"y":1280,"wires":[["6134d059.c9e49"]]},{"id":"2b9e69b6.2096a6","type":"inject","z":"55805384.a4695c","name":"illegal - missing identifier","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"spotify:","payloadType":"str","x":170,"y":1240,"wires":[["a5631e5b.0e258"]]},{"id":"e4d3ee70.96efd","type":"debug","z":"55805384.a4695c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":914,"y":1327,"wires":[]},{"id":"6134d059.c9e49","type":"change","z":"55805384.a4695c","name":"extract id","rules":[{"t":"set","p":"payload","pt":"msg","to":"$substringAfter(payload, 'spotify:album:')\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":1280,"wires":[["1552be7c.376a72"]]},{"id":"1552be7c.376a72","type":"template","z":"55805384.a4695c","name":"template with region us","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n    \"uri\": \"x-rincon-cpcontainer:1004206cspotify%3aalbum%3a{{payload}}?sid=12&amp;flags=8300&amp;sn=1\",\n    \"metadata\": \"&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:r=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;&lt;item id=&quot;1004206cspotify%3aalbum%3a{{payload}}&quot; parentID=&quot;&quot; restricted=&quot;true&quot;&gt;&lt;dc:title&gt;&lt;/dc:title&gt;&lt;upnp:class&gt;object.container.album.musicAlbum&lt;/upnp:class&gt;&lt;desc id=&quot;cdudn&quot; nameSpace=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot;&gt;SA_RINCON3079_X_#Svc3079-0-Token&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;\",\n    \"queue\": true\n}\n","output":"json","x":720,"y":1280,"wires":[["e4d3ee70.96efd","12cf8e7b.637b72"]]},{"id":"653bc433.91995c","type":"inject","z":"55805384.a4695c","name":"Example 2","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"spotify:album:6KrB8Sf5g2WpCcWUOE9CpE","payloadType":"str","x":120,"y":1320,"wires":[["a5631e5b.0e258"]]},{"id":"12cf8e7b.637b72","type":"sonos-universal","z":"55805384.a4695c","confignode":"88e9fa70.4a53e8","command":"group.play.export","state":"","stateType":"str","name":"","x":954,"y":1280,"wires":[[]]},{"id":"4054890c.2e9118","type":"comment","z":"55805384.a4695c","name":"↓modify","info":"Modify the config file and enter a valid player ip address. ","x":963,"y":1253,"wires":[],"icon":"font-awesome/fa-edit"},{"id":"88e9fa70.4a53e8","type":"sonos-config","name":"kitchen","serialnum":"","ipaddress":"192.168.178.37"}]
ghassansalloum commented 3 years ago

Thank you very much for going through all this trouble this late at night! This workaround worked. Thanks again.

hklages commented 3 years ago

You are welcome - and thanks for the Cappuccini - enjoyed them in the morning :-)

If you need a template for songs, playlist - let me know and send for each one an export witht he US data.

jonathananolan commented 2 years ago

Hi! I live in Australia and this work around solved the problem - I'm wondering is there a playlist version? @hklages Thanks so much it's such a great project!

hklages commented 2 years ago

Hi Jonathan. Right now there isn't a flow for playlists. Together we can create it. Just send me the JSON output of mysonos.export.item for one of your playlist. (After having added them to My Sonos with the Sonos app)

Cheers, Henning.

jonathananolan commented 2 years ago

That sounds great! Sorry for the long delay - was busy with another project. Here is the JSON...

&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:r=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;&lt;item id=&quot;0006002cspotify%3aplaylist%3a37i9dQZEVXcQlP8IZUt6iP&quot; parentID=&quot;spotify%3aview%3asection0JQ5DAnM3wGh0gz1MXnu3I&quot; restricted=&quot;true&quot;&gt;&lt;dc:title&gt;Discover Weekly&lt;/dc:title&gt;&lt;upnp:class&gt;object.container.playlistContainer#playlistItem&lt;/upnp:class&gt;&lt;desc id=&quot;cdudn&quot; nameSpace=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot;&gt;SA_RINCON3079_X_#Svc3079-0-Token&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;

It would be also interesting to know if it could be set to a random position in a random song - at the moment I achieve that by changing queue mode then clicking next track, but that introduces a 3-4 second delay.

hklages commented 2 years ago

... I am on a short trip to Barcelona and will work on it later this week.

On Sat, Apr 23, 2022, 10:00 jonathananolan @.***> wrote:

That sounds great! Sorry for the long delay - was busy with another project. Here is the JSON...

<DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/&quot; xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:r="urn:schemas-rinconnetworks-com:metadata-1-0/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"><item id="0006002cspotify%3aplaylist%3a37i9dQZEVXcQlP8IZUt6iP" parentID="spotify%3aview%3asection0JQ5DAnM3wGh0gz1MXnu3I" restricted="true"><dc:title>Discover Weekly</dc:title><upnp:class>object.container.playlistContainer#playlistItem</upnp:class><desc id="cdudn" nameSpace="urn:schemas-rinconnetworks-com:metadata-1-0/">SA_RINCON3079X#Svc3079-0-Token</desc></item></DIDL-Lite>

It would be also interesting to know if it could be set to a random position in a random song - at the moment I achieve that by changing queue mode then clicking next track, but that introduces a 3-4 second delay.

— Reply to this email directly, view it on GitHub https://github.com/hklages/node-red-contrib-sonos-plus/issues/142#issuecomment-1107421595, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEDZCHYP74S2TALKPFYQ6RDVGOU3HANCNFSM42DNGPBA . You are receiving this because you were mentioned.Message ID: @.***>

hklages commented 2 years ago

Hi. Could you please test the attached flow with different playlists and let me know the result.

Random song: I dont have a spotify account and therefore can not test it. You can set the queue in "SHUFFLE" mode. Did you try 'group.set.queuemode', payload either 'SHUFFLE' 'SHUFFLE_NOREPEAT' 'SHUFFLE_REPEAT_ONE' ? Does that work for Spotify queues/playlists?

Random position: That could be achieved just by adding a group.seek.delta at the end.

[{"id":"d5110830eb65f4a6","type":"inject","z":"4c80366e30b8d83c","name":"Example 1","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"spotify:playlist:37i9dQZEVXcQlP8IZUt6iP","payloadType":"str","x":100,"y":920,"wires":[["cd35d35fb1a3fc3d"]]},{"id":"cd35d35fb1a3fc3d","type":"switch","z":"4c80366e30b8d83c","name":"playlist?","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"spotify:playlist:","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":247,"y":920,"wires":[["d2e75e1d9705ea93"]]},{"id":"d2e75e1d9705ea93","type":"change","z":"4c80366e30b8d83c","name":"extract id","rules":[{"t":"set","p":"payload","pt":"msg","to":"$substringAfter(payload, 'spotify:playlist:')\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":394,"y":920,"wires":[["3dbac7708a578772"]]},{"id":"3dbac7708a578772","type":"template","z":"4c80366e30b8d83c","name":"template playlist with region us","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n \"uri\": \"x-rincon-cpcontainer:1004206cspotify%3aplaylist%3a{{payload}}?sid=12&amp;flags=8300&amp;sn=1\",\n \"metadata\": \"&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:r=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;&lt;item id=&quot;1004206cspotify%3aplaylist%3a{{payload}}&quot; parentID=&quot;&quot; restricted=&quot;true&quot;&gt;&lt;dc:title&gt;&lt;/dc:title&gt;&lt;upnp:class&gt;object.container.playlistContainer#playlistItem&lt;/upnp:class&gt;&lt;desc id=&quot;cdudn&quot; nameSpace=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot;&gt;SA_RINCON3079_X_#Svc3079-0-Token&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;\",\n \"queue\": true\n}\n","output":"json","x":611,"y":920,"wires":[["46f80d41f1601609","2ddfd5a7e12e3e8f"]]},{"id":"46f80d41f1601609","type":"sonos-universal","z":"4c80366e30b8d83c","confignode":"5a07e409.17a1ec","command":"group.play.export","state":"","stateType":"str","avoidCheckPlayerAvailability":false,"name":"","x":905,"y":920,"wires":[[]]},{"id":"70139fae7dd95db7","type":"comment","z":"4c80366e30b8d83c","name":"↓modify","info":"Modify the config file and enter a valid player ip address. ","x":910,"y":888,"wires":[],"icon":"font-awesome/fa-edit"},{"id":"5a07e409.17a1ec","type":"sonos-config","name":"yourPlayer","serialnum":"","ipaddress":"192.168.178.51"}]
sumnerboy12 commented 2 years ago

Hi there, I am in NZ (just wondering why you said above "Hope you are not in NZ!"...) and your workaround flow works (using US region). Is this something you could add as an optional input for the group.queue.urispotify message, i.e. specify the region so your node can build the correct payload without needing this workaround?

hklages commented 2 years ago

Hi

just wondering why you said above "Hope you are not in NZ!"...

That's outdated - there were rumors that NZ/Australia have their own "region" but so far all use the US region

My node is base on node-sonos-ts. Let me check with them. If that packages supports it will implement it.

sumnerboy12 commented 2 years ago

That's outdated - there were rumors that NZ/Australia have their own "region" but so far all use the US region

Phew!! And it things seem to be working with US region so I guess that confirms that. Thanks for having a look, and thanks for a great node!

hklages commented 2 years ago

Currently sonos-ts does not support to set the region. I send a request to change that: spotify region and will let you know when there is a change.

sumnerboy12 commented 2 years ago

Great, thanks for the update and thanks for the great work with this node.

hklages commented 2 years ago

Hi sumnerboy :-) Please check the new release 6.4.0.

Put the following line process.env.SONOS_REGION_SPOTIFY = "3079" at the top (before module.exports) of your settings.js file in your user node-red directory.

6.4.0 uses the beta 2.5.1-beta.1 of sonos-ts, which supports regions for spotify, apple, ...

You may test the existence of the ENV variable with the change node ($env)

Does it work for you?

sumnerboy12 commented 2 years ago

Works like a charm - thanks you very much - brilliant!!

hklages commented 2 years ago

Great. Thanks for the feedback. Appreciate that.

If you like you can also test the "group.queue.uri" - that should also work with spotify. The urispotify only tests the syntax in addition but uses the same methods.

sumnerboy12 commented 2 years ago

Yeah nice, that works well!

cholzer79 commented 1 year ago

So I am in Europe and run node red in a docker on Ubuntu. I ran into the exact same error message as ghassansalloum when I tried to queue a spotify playlist.

I then used your playlist flow hklages where I changed the region ID in that flow to 2311 - that works nicely!

Put the following line process.env.SONOS_REGION_SPOTIFY = "3079" at the top (before module.exports) of your settings.js file in your user node-red directory.

I then put process.env.SONOS_REGION_SPOTIFY = "2311" above module.exports in my settings.js, restarted the node red container, made sure that the settings.js change survived the restart but i still get the error.

The only way for me to queue a spotify playlist is with your flow.

hklages commented 1 year ago

Hi. The default region is Europe - so you don't need the work around or to set the ENV variable.
You link (hklages) does not show the flow - but only the home page of my github.

Please export the 2 flows and send them to me: