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
    November 22, 2013
    Nothing is playing all q empty
    jishiAuthor
    Headliner II
    November 22, 2013
    Nothing is playing all q empty

    That's not what I asked 🙂 I want you to do this:

    Add a queue to a player (local tracks or something).

    Play a Pandora favorite, does it say (queue not in use)?
    Lyricist III
    November 22, 2013
    got it ...sorry

    no it does not .......
    test steps
    added something to q
    entered localhost:5005/office/favorite/carlos

    played fine then

    tried to change to new fav and failed

    hope that helps....
    buzz
    Grand Maestro
    November 22, 2013
    Perhaps I'm jumping into a sea where I don't know what I am doing, but the space between "r o" in "object.item.audioItem.audioBr oadcast" seems out of place. Perhaps this is just an artifact of a message text capture.
    jishiAuthor
    Headliner II
    November 22, 2013
    Yeah, I saw that too, but I think that's because the windows console doesn't word wrap correctly.

    Robertboca, I want you to test what I said with the official app, not my stuff.
    Trending Lyricist I
    November 22, 2013
    Step away from the thread for a few days.... wow... looks like I miss all kinds of changes...

    So just for reference J.....

    code:

    websonos │ 0 │ fork │ 8405 │ online │ │ 0 │ 47h │ 46.367 MB │ /root/.pm2/logs/websonos-err.log

    -rw-r--r-- 1 root root 0 Nov 11 20:48 websonos-err.log
    -rw-r--r-- 1 root root 318495 Nov 22 16:55 websonos-out.log


    This is interesting though:
    ./node-sonos-web-controller/
    -rw-r--r-- 1 root root 22371372 Nov 22 16:55 notification.log


    Been running on the linux vm (ubuntu 12.10) for 47 hours now straight. With average use around here.... Got only 46 megs in use right at this moment.... The log file.... isn't bad size anymore either.

    Great job.... thus far. I think I'm on 0.4.x still since I haven't grabbed the git code since monday or tuesday.

    I'll pull in the latest now, and see how it does.

    BTW, since you suggested it... I've been finding that even running an npm update for the sonos-discovery manually, I still have needed to delete the directory and npm install.... Most of the other stuff, like socket.io and static don't need the extra work.
    Lyricist III
    November 22, 2013
    Yes got it it

    It says Queue Not in use....

    Sorry did not understand 😃
    Trending Lyricist I
    November 22, 2013
    So I updated the version.... to the latest git from 5:00pm EST ....

    When I go to use the favourites to start a stream out of rdio.... I find that it just sits there. No change. If I have the desktop controller open and visible, I see that it "flashes" for a second, but no change.

    If I have one playing started through the desktop controller, I can start or resume the stream without issue.

    I grabbed the pm2-service-out.log I'll pm it to you, since I don't have time right now to strip out the macs.....

    Slacker seems to suffer the same issue.

    Tuned in, or even the jazzradio/di.fm premium seem to work OK though.
    jishiAuthor
    Headliner II
    November 22, 2013
    I think I know what's going on. Just out of curiosity steelrat, did those favorite use to work?

    I'll try and find a permanent fix for the radios when I get the time, now I have some more references to work with.
    Trending Lyricist I
    November 24, 2013
    Captured on the windows xp netbook.... (it was easier)...

    PM'd you J with the answer for the SetAvTransport.

    If you need more from the stream let me know. I'll probably try to grab a slacker one tomorrow....