Let me introduce my idea to you.
I have a switch (integrated via Homeassistant and Nodered) and SONOS. If I press the button on the Switch then either the next playlist should be played or a random one should be selected.
I use for controlling SONOS this: https://github.com/jishi/node-sonos-http-api