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

    Lyricist III
    January 24, 2016
    Hi, i've just come across this effort for a web controller by you, it looks great and is exactly what i need for my home automation wall controller, but try as i can, i can't get anything to populate in the controller. I've installed it and can access it via the browser but it's just empty, no discovery etc. Am i doing something wrong?

    Would really love to get the working.

    Thanks
    jishiAuthor
    Headliner II
    January 24, 2016
    Sounds like it doesn't find your system. Could you please provide the output from the console, and also describe the environment where you are running this? Device, operating system, how it is connected to your network and if you can run an official controller on that device, does it work?
    Lyricist III
    January 24, 2016
    Hi, its a windows server, windows 2012 Just connected to the network via normal network connection, wired, with an IP address on the same network as the Sonos. If I run the official controller, it works fine. I've disabled all firewalls and so on. If you mean the output from the command prompt when i run it, that is below:

    C:\Node>node server.js
    no settings file found, will only use default settings
    info - socket.io started
    http server listening on port 8888
    queue-changed { uuid: 'RINCON_000E5825AA6C01400' }
    getqueue 0 600
    loading-queue: 133.683ms
    jishiAuthor
    Headliner II
    January 24, 2016
    You could try disabling the firewall completely as a test. It might block the node process from opening a listening port.
    Lyricist III
    January 25, 2016
    I've tried that, no luck 😞
    Lyricist III
    January 25, 2016
    I've installed it on a different server own the network where I'm running many network services, as well as the original songs controller which works fine, and it's still not working, doing the same thing
    Lyricist III
    January 25, 2016
    ok here's the weird thing. If I reboot the Sonos so the queues are clear, then start the server.js, it shows this:


    C:\Node>node server.js
    no settings file found, will only us
    info - socket.io started
    http server listening on port 8888

    As soon as I add songs to the queue with the official app, this get's added to the console

    queue-changed { uuid: 'RINCON_000E5825AA6C01400' }
    getqueue 0 600
    loading-queue: 375.074ms

    So it's definitely detecting something with regards to the player, but not showing this on the UI or allowing me to interact
    jishiAuthor
    Headliner II
    January 25, 2016
    Yeah, since it got a uuid, I would assume that the events actually works. Do you get any errors in your console in the browser?
    Lyricist III
    January 25, 2016
    do you mean the UI in the browser? then no, i just see the UI with nothing populated in it
    jishiAuthor
    Headliner II
    January 25, 2016
    do you mean the UI in the browser? then no, i just see the UI with nothing populated in it

    Which browser? Most of them have a console that you can retrieve (F12 usually, in Windows), which might output some errors.