Continuing the discussion from Sonos and home automation audio:
I did this as well. Here are the steps I used. You need to set up a node server on a computer – which is far easier than it sounds.
-
download node installer from Index of /download/
-
install node
-
download the Sonos HTTP API from from GitHub - jishi/node-sonos-http-api: An HTTP API bridge for Sonos easing automation. Hostable on any node.js capable device, like a raspberry pi or similar.
-
install the sonos discovery code from command line interface (such as in Terminal on OS X), by typing
npm install sonos
-
start node server from command line by going into the folder containing the sonos http api code ( such as /Users/[your user name]/node-sonos-http-api/ and typing
node server.js
At this point, you should see a lot of sones-related information come up within your command line interface. Then, from your browser, enter any of the commands listed (see GitHub - jishi/node-sonos-http-api: An HTTP API bridge for Sonos easing automation. Hostable on any node.js capable device, like a raspberry pi or similar.). When accessing from the computer on which the node server is located, the format is basically http://localhost:5005/[speaker name]/[command]. Here, “http://localhost” sends the http request back to the same computer, “:5005” sends the request to port 5005 (which is the port for the node server), and then the node server receives the command. For example, to play a Sonos favorite playlist called “CurrentFavs” on the Sonos in my kitchen, I enter
http://localhost:5005/kitchen/favorite/CurrentFavs
FYI - This command works on all types of streams and playlists, such as Pandora radio stations or Spotify playlists that you have saved in your Sonos favorites. If you want to invoke the say command, be sure to use %20 in between words instead of a space. For example, if I wanted the kitchen speaker to announce “I am Ultron”, I would enter
http://localhost:5005/kitchen/say/I%20am%20Ultron.
If you want to access the node server from another computer on the same network, then replace “http://localhost” with the network address of that computer, such as 10.0.1.15. This will come in handy if you create a ST SmartApp to send http commands to your node server.
IMO, the coolest function is the ability to send “Presets”, which are predefined groupings of speakers and volumes. An example (from the read me) is:
{
“players”: [
{ “roomName”: “room1”, “volume”: 15},
{“roomName”: “room2”, “volume”: 25}
],
“state”: “stopped”,
“favorite”: “my favorite name”,
“uri”: “x-rincon-stream:RINCON_0000000000001400”,
“playMode”: “SHUFFLE”,
“pauseOthers”: true
}
Hope this helps,
Tony