I love my SONOS devices. Problem is that the integration between SmartThings/WebCoRE and SONOS leaves a lot to be desired. Enter jishi’s node-sonos-http-api. A cool and simple NODE.JS that allows you to really fully control SONOS via WebCoRE.
I’ve installed node-sonos-http-api onto a Raspberry Pi, and it acts as a much needed bridge between WebCoRE and SONOS. WebCoRE can send simple URL requests like
http://sonoscontrol/study/play
And trigger specific the Study to play. No big deal right? Well, how about
http://sonoscontrol/study/join/kitchen
This is where things get really useful for me. SmartThings and WebCoRE really don’t have a good way to join SONOS speakers together. Some other commands that node-sonos-http-api offer which SmartThings and WebCoRE don’t have natively include
- Setting the Speaker to use LineIn (TV)
- Track Seek
- Group Mute
- Isolate a Speaker/Room
- Play Favorite
- Play Playlist
- Repeat/Shuffle/Crossfade
- Clear Queue
And the big one for me is
- Text-To-Speech using Microsoft Azure Cognitive Services, (plus some other ones including Google) but something other than Amazon Polly
So how? This post will get you up and running quickly on a Raspberry Pi.
You will need:
A Raspberry pi B/B+, 2 and version 3 connected via Ethernet with DHCP
An SD Card
An application such as Win32 Disk Image Writer
An application to extract a gz file
Instructions
Go to http://jishi.github.io/node-sonos-http-api/
Download the image for Raspberry Pi.
Expand the file and get the img
Use the Disk Image Writer to write the img to the SD Card
Insert the SD card into the Raspberry Pi
Plug the Raspberry Pi into the same network segment as your SONOS devices
Log in (root/with no password)
Determine the IP address
Go to http://%5BIP Address]:5005 and see if you get the following page
If so, you’re done. Some helpful commands to get you started
http://[IP address]:5005/zones
will list all your available zones
http://[IP address]:5005/[Room Name]/state
will give you the state of a particular room in JSON. Not you can use $response and JSON values to get information (i.e. $response.currentTrack.uri gives you current track info)