Question

Play current queue automatically

  • 22 October 2016
  • 5 replies
  • 707 views

Badge +20
Hardly advanced but cannot see any means to do this automatically.

I want to play from an existing queue, at a set time each day for an hour. The alarm would be the obvious tool but it does not allow playing from the existing queue. It has to be the existing queue as I want to continue playing from a very large playlist that is set on repeat and want to continue where it stopped on the previous day.

Any bright ideas?

This topic has been closed for further comments. You can use the search bar to find a similar topic, or create a new one by clicking Create Topic at the top of the page.

5 replies

Userlevel 4
Badge +14
If you basically just want to invoke "Play" on a fixed time, the simplest form would be to mimic the Play command towards the Player (or coordinator, if grouped), with something like curl:

https://gist.github.com/jishi/ed4fc7b154ab23308a0badc27226e984

With powershell (3.0 or newer)
https://gist.github.com/jishi/4399000fa2aebeef801c25d37eb17e5b
The -OutFile is required for it not to return error code because of an non-standard encoding response, the request goes through though.

(It was impossible to inline the commands without the communitysystem fucking everything up with smileys and links even in a code block, sigh)



You need to replace the IP address in above examples with the IP of the player (or coordinator).

If course, this doesn't handle any non golden cases very well. If grouping has changed, or the player has switched to radio, this would either not do anything, or start playing the radio (not the queue). You can of course combine it with multiple commands to restore queue etc as well, but it becomes kind of hard to maintain.

Another suggestion would be to look into pre-made 3rd party libraries that might handle this for you. I'm of course biased, but for this specific scenario the http api that I've made would help out significantly. I actually use a similar setup myself, where I apply a preset each morning to restore what was playing last time my system was grouped, including a pre-defined grouping as well as volume levels. See https://en.community.sonos.com/advanced-setups-229000/simplified-http-api-nodejs-6737571

The pre-made raspberry pi image simplifies the installation a lot, if you want to invest in a pi. You could also create the scheduled task within the raspberry pi as well, making it completely standalone.

Other options for controlling it would be Soco https://github.com/SoCo/SoCo, which seems well-maintained. That of course requires some programming experience.
Badge +20
Many thanks for this, I have a spare Pi (B) ... goes off looking for a PSU and SD card.

Although quite overkill for a simple play command which the alarm should be able to do.
Userlevel 4
Badge +14

Although quite overkill for a simple play command which the alarm should be able to do.


Sure, agreed. It is weird why they yet haven't introduced a scene/preset functionality given how useful it is. There are some indications in the API that they at some point actually have worked on it, but apparently they didn't think it was good enough (or useful enough).

But in all fairness, you will probably realize that you just don't want to "play", applying a preset for your whole system has all kind of upsides 🙂
Userlevel 5
Badge +11
Saving your queue as a Sonos Playlist enables it in Alarms.
Biu...I would imagine that would start at the beginning each time.
Badge +20
Saving your queue as a Sonos Playlist enables it in Alarms.
Biu...I would imagine that would start at the beginning each time.


Correct, just starts from the beginning each time.