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

Shuffle Playlist Issue #251

Closed neildsb closed 1 year ago

neildsb commented 1 year ago

Really sorry for the trivial issue (google everwhere), how do I shuffle a sonos playlist, I have the following flow, but it always plays the 1st track on the playlist.

image

[{"id":"2b3c81c52b448e45","type":"server-state-changed","z":"6bb02410a6c00eeb","name":"Ensuite light on","server":"15a32798.84b678","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.ensuite","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":400,"y":4700,"wires":[["c096cc66e2647889"],["9a8b645305d5102a"]]},{"id":"599acdca0a58402d","type":"sonos-universal","z":"6bb02410a6c00eeb","confignode":"273acd37c66af568","command":"group.play.tunein","state":"s266113","stateType":"str","avoidCheckPlayerAvailability":false,"name":"Virgin","x":1570,"y":4620,"wires":[[]]},{"id":"9a8b645305d5102a","type":"sonos-universal","z":"6bb02410a6c00eeb","confignode":"273acd37c66af568","command":"group.pause","state":"","stateType":"str","avoidCheckPlayerAvailability":false,"name":"","x":610,"y":4760,"wires":[[]]},{"id":"c096cc66e2647889","type":"time-range-switch","z":"6bb02410a6c00eeb","name":"7:30am & 8pm","lat":"","lon":"","startTime":"07:30","endTime":"20:00","startOffset":0,"endOffset":0,"x":620,"y":4700,"wires":[["ae72844c091e5074"],[]]},{"id":"ae72844c091e5074","type":"api-current-state","z":"6bb02410a6c00eeb","name":"Entertaining on","server":"15a32798.84b678","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.entertaining","state_type":"str","blockInputOverrides":false,"outputProperties":[],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":820,"y":4680,"wires":[[],["3ac7df5488331972"]]},{"id":"3ac7df5488331972","type":"sonos-universal","z":"6bb02410a6c00eeb","confignode":"273acd37c66af568","command":"household.separate.group","state":"","stateType":"str","avoidCheckPlayerAvailability":false,"name":"Ensuite only","x":1010,"y":4680,"wires":[["ff5fdf2e7fb5d9ed"]]},{"id":"ff5fdf2e7fb5d9ed","type":"random","z":"6bb02410a6c00eeb","name":"","low":1,"high":"3","inte":"true","property":"payload","x":1220,"y":4680,"wires":[["9c1f92e49a0a0f6b"]]},{"id":"9c1f92e49a0a0f6b","type":"switch","z":"6bb02410a6c00eeb","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"3","vt":"num"}],"checkall":"true","repair":false,"outputs":3,"x":1370,"y":4680,"wires":[["599acdca0a58402d"],["994909aaa5d0ac49"],["e840c7312d5772e5"]]},{"id":"e840c7312d5772e5","type":"sonos-universal","z":"6bb02410a6c00eeb","confignode":"273acd37c66af568","command":"group.play.sonosplaylist","state":"Rammstein","stateType":"str","avoidCheckPlayerAvailability":false,"name":"Rammstein","x":1590,"y":4740,"wires":[[]]},{"id":"994909aaa5d0ac49","type":"sonos-universal","z":"6bb02410a6c00eeb","confignode":"273acd37c66af568","command":"group.play.sonosplaylist","state":"Neil Playlist","stateType":"str","avoidCheckPlayerAvailability":false,"name":"Neil Playlist","x":1590,"y":4680,"wires":[[]]},{"id":"15a32798.84b678","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true},{"id":"273acd37c66af568","type":"sonos-config","name":"Ensuite","serialnum":"54-2A-1B-F8-6F-B6:7","ipaddress":"192.168.20.187"}]

hklages commented 1 year ago

Hi. Shuffle is a property of the SONOS-Queue. It works for playlist, albums etc. So you should use the command group.set.queuemode. Full description is in the Wiki:

https://github.com/hklages/node-red-contrib-sonos-plus/wiki/A.1-Universal-Node#groupsetqueuemode

Does it work for you?

neildsb commented 1 year ago

wow, thanks for the quick reply, i have just read the doc and found this object, do you have an example pictorial flow you can share, as i am not sure how to inset this into my flow, and do i configure it like this?

image

neildsb commented 1 year ago

I think, i have figured it out, is this an effect way of using it?

image

hklages commented 1 year ago

You can use it with an inject node in a separate flow as it is persistant. The only restriction is that the queue must not be empty.

hklages commented 1 year ago

I think, i have figured it out, is this an effect way of using it?

image

That also works. You can change to shuffle mode in the app or via command. It keeps that setting until you change it.

neildsb commented 1 year ago

you're a rock star, thanks!! I have gone with the following -

image

hklages commented 1 year ago

:-) That also works!