Solving my Sonos morning alarm problem

I’ve jumped on the Sonos bandwagon a while back and I have a couple of Sonos players around the house. One in the bathroom, one in the kitchen, in the living room etc. I’ve been using them with alarms in the morning (weekdays only) so that the bathroom one tuned in to local radio (streamed of course) at 5.30am, the kitchen one joined in at 6am and then the upstairs one at 6.30am when it’s time to wake the kids. The problem with this setup is that Sonos does not offer a way to let the players join into the same group meaning that eventually / sometimes they will be slightly apart in the streaming of the audio which is really annoying. I’ve been looking for a solution for a while but didn’t find a solution until now.

My solution has been to use the node-sonos-http-api running on a Raspberry Pi and using cron. Very simple really. Basically the node-sonos-http-api offers up a local HTTP server on port 5005 that accepts GET requests to perform actions on players such as playing, tuning in to Tunein stations, joining groups etc. So I have a couple of cron jobs that first thing makes sure the bathroom player leaves any other group it might be in, sets the volume and then tunes into the radio station. Later the kitchen players volume is set and the player joins the bathroom player and so on. Very cool and works like a charm.

The biggest problem turned out to be getting node and npm installed on the Raspberry Pi v.2 I’m using but downloading the binaries manually and installing manually (unzipping really) instead of using apt-get worked like a charm. Then I simply run the node-sonos-http-api server on startup and have cron do the requests using curl chaining multiple requests together using && where necessary i.e. when I need to change volume and join a group in one cron job.