Skip to main content
Headliner II
March 5, 2013

Sonos with node.js, my attempt!

INFO

Source code here: https://github.com/jishi/node-sonos-http-api
Sonos Web Controller draft (work in progress!): https://github.com/jishi/node-sonos-web-controller
Sonos IR control (requires lircd and IR reciever): https://github.com/jishi/node-sonos-remote-control

==============================================================


I know that there already is an attempt at this by this guy: http://forums.sonos.com/showthread.php?t=32643, but I found it to be a bit lacking in functionality so I decided to write up my own.

I have created a simple web-based API using what I have, which could be useful for integrating stuff with other applications. This web based API is inspired by other RESTful APIs, however I don't think it follows the correct guidelines to be called a REST API.

IT supports most basic features like:

play, pause, seek, next, prev, volume, mute, setAVTransportURI

It also supports these advanced fatures:

State of player as JSON, zone info as JSON, Play favorite item, presets (grouping, volume, avTransportURI)

You can read more in the README for each project.

To run it as a service under linux, I suggest using pm2 (https://github.com/Unitech/pm2). You need to run it in forked mode (-x)!

For Windows, you might try Winser http://jfromaniello.github.io/winser/

Cheers!
    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.

    391 replies

    jishiAuthor
    Headliner II
    January 4, 2015
    Yeah, I thought it was equivalent. 0 triggered the sleep fadeout instantly, I just looked at the controller and saw the sleep countdown was removed.

    I added an "off" value that does it instead. Seemed more intuitive.
    Lyricist III
    January 4, 2015
    I added an "off" value that does it instead. Seemed more intuitive.


    Thanks sleep() works super now.

    And your "volume change hook" code is also upp and running.
    jishiAuthor
    Headliner II
    January 10, 2015
    I just pushed an update to sonos-http-api with an attempt for a "announce everywhere" function, and then restore.

    I know a few home automationers have been wanting this for a while, so try it out and see if it is useful.

    I'll try and add a page later to control this or for "on the fly" announcements.
    Contributor I
    March 31, 2015
    Jishi - did you ever solve for the repeating issue? Full disclosure - I am the author of a Sonos plugin for the Indigo home automation system. I have the same problem, but have been unable to figure out a solution.

    Well, apart from the repeating issue, it still works the same way? I take it that the regrouping isn't an issue for you?
    jishiAuthor
    Headliner II
    March 31, 2015
    Jishi - did you ever solve for the repeating issue? Full disclosure - I am the author of a Sonos plugin for the Indigo home automation system. I have the same problem, but have been unable to figure out a solution.

    Hi, I think you need to refresh my memory and explain what the repeating issue was, or explain the symptoms that you are seeing, and I'll see if I can help. You are using SonosPy, correct? So it's more of a network/logic issue than directly related to my libraries? Maybe you should create a new topic where we can discuss this, to not add off-topic discussions to this thread.
    Contributor I
    March 31, 2015
    Sorry - I just posted a new thread. This is not related to your code, but I found it interesting that you experienced a similar problem as me with text to speech announcements repeating a little of the text.

    Hi, I think you need to refresh my memory and explain what the repeating issue was, or explain the symptoms that you are seeing, and I'll see if I can help. You are using SonosPy, correct? So it's more of a network/logic issue than directly related to my libraries? Maybe you should create a new topic where we can discuss this, to not add off-topic discussions to this thread.
    Lyricist III
    April 19, 2015
    First thank you for all you amazing work could you be so kind to direct me to how to force a player via the command line such as the following:
    call to your web interface

    http://192.168.1.160:8080/index.htm#RINCON_000E5813DC720140

    this way i can force a specific player thus locking the interface from a user messing with another player.

    Can see where to set the var: ( ps not areal programmer just learning) Thank you Robert
    jishiAuthor
    Headliner II
    April 20, 2015
    First thank you for all you amazing work could you be so kind to direct me to how to force a player via the command line such as the following:
    call to your web interface

    http://192.168.1.160:8080/index.htm#RINCON_000E5813DC720140

    this way i can force a specific player thus locking the interface from a user messing with another player.

    Can see where to set the var: ( ps not areal programmer just learning) Thank you Robert


    Are you trying to lock it down using some sort of widget load of the web interface (where a user can't manually change the URL)? Because otherwise it will be kind of pointless. You also need to consider how you want it to act if that player is grouped to another one. Allow access or not?
    Lyricist III
    April 20, 2015
    All I am trying to do is stop my kids from messing with the other players in the house and a guest when they come over just be able to control their room and not mess with the other the best way o thought was to just make a call to the web program remove the list of other players in the page ( hide them) and allow control for that player only as per groups etc I wanted to keep it simple if it was part of a group and the room was called it would be removed from the group and work on its own options to add to a group and other fancy stuff really not needed just need to select fav play stop etc many thanks for getting back Regards

    Robert
    Lyricist I
    May 16, 2015
    Hi jishi,

    thanks a lot for your awsume package!!
    I was looking for a possibility to remote control my Sonos Play 5 and came across your package.
    My Play 5 is connected to a TV in my bedroom. So, I was "only" looking for a possibility to increase, decrease the volumne while watching TV.
    I managed to install all this on a raspberry and it is just working great. 🙂
    I even somehow managed with my basic knowledge to integrate a "shutdown" command on a key press of my remote. As my raspberry is connected via USB Y-cable to my television, I thought that this might be better than just switch off the power. :-)

    Thanks a lot again for your work on this package. Keep going 🙂