Sonos with node.js, my attempt!



Show first post
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.

397 replies

However I just realized, I don't know what would happen for random playback, because I don't know when the random sequence is set, and if it get reset if you disable the queue temporarily. That might perhaps be a bit of a problem.

I'd imagine using a Controller calls the same methods. If you load and shuffle a queue, start a radio station (queue goes into 'Not in Use' mode) then play the same track you previously interrupted, the 'Next' track is still the same one as before. The 'Next' track remains correct even if you resume further into the queue (meaning if you read ahead to know the play order, then skip back, interrupt the first track with radio, then resume at what would have been 4th in the shuffle, the 5th appears in 'Next').

I was curious 🙂
Userlevel 4
Badge +14
Actually, I think it really should be there so I committed a fix. Pull or download it again and see if it works.
Badge +1
I've gotten voice feedback working: when the player is paused or stopped, double pressing the button puts you in favorites mode. The LED pulses, and your first favorite is spoken through the Sonos Zone. A twist of the knob says the next favorite, and so on. Pressing the knob once plays the last spoken favorite. Pressing twice (or doing nothing for 30 seconds) exits favorites mode back to a paused Sonos.

The code is a disaster (when I code, I charge ahead full speed without care for comments or structure), so I'll spend the next few days cleaning it up, and working on the feel of the wheel turn/speaking timing, and get the new code posted.

On a side note, I'd love for the PowerMate to have something like a magnetic haptic capability: setting the PowerMate to a certain mode introduces little "notches" in the turning motion. This would make selecting individual favorites far easier, and less of a cautious turn of the wheel.

Jishi, I issued a pull request for a slight change that was helpful to me, but that will break other installs. Feel free to discard if you like. Just wanted to get it out there.
Will do....

In a little bit of time troubleshooting here this afternoon, I remembered I removed nvm (version manager) when I was trying to get the services working....

So I thought, could be a version 0.8 to 0.10 bug....

So I reinstalled nvm, and then ran this with v0.8 on the original code, and everything seems to work.

I'll change back up to the v0.10 through nvm, and try your fixed server.js, and let you know.

Thanks... for the quick turn around.
Badge
Hi Jishi (and Matt!),

Looks like Matts pull request #14 (add sub functionality) has introduced a problem in sonos-discovery...

I have a stereo pair of play 1's and a bridge. When I fire up the web controller I see my devices listed in the console output, but I don't see any rooms listed in the UI so basically I can't control/play anything. If I separate the play 1's they both become visible as separate rooms in the UI and all works as expected.

Everything works fine if I regress pull request #14 and #15 in sonos-discovery.

I'll see if I can figure out what the problem is myself, but I must admit I'm struggling with node.js a little bit:)

Thanks both for your work - looking forward to trying some ifttt recipes too;)

Cheers,
Dave.
Badge +1
Really sorry about this. I tested basic pairing with just the sonos-discovery, but didn't try it "live" with anything like the web controller.

Let me pair up a couple of my Sonos tonight, and get the web controller installed, and get this debugged.

Sorry again. I hate that I broke something that was working so well for folks.
Userlevel 4
Badge +14
No problem, it's good to get it sorted out. I pushed an update which implements a working group volume now as well. It uses the scroll wheel in the same manner as the official client, but haven't fixed the click adjustment yet. You could adjust volume before, but it never reflected the volume on load, or when adjusted in another client. This do work now.

Soon all the basic control is in place, which will be a milestone 🙂
Badge
Really sorry about this. I tested basic pairing with just the sonos-discovery, but didn't try it "live" with anything like the web controller.

Let me pair up a couple of my Sonos tonight, and get the web controller installed, and get this debugged.

Sorry again. I hate that I broke something that was working so well for folks.


Many thanks Matt, I'll have another look this evening too. Out of interest, what IDE do you use? Nodeclipse?

Cheers,
Dave.
Cool....

git updates "instruction" reading is obviously going to be on the list...

I also got your suggested pm2 scheduler running, so the server.js can now start on startup.... Much easier to setup configure etc, over the forever, etc.... It's not perfect, I think I have to bounce the pm2 id's on reboot, but after that it has been seeming pretty stable.

So it's definitely coming together.

Nice job....
Badge +1
Out of interest, what IDE do you use? Nodeclipse?

I just use sublime text and the command line.
Userlevel 4
Badge +14
I implemented some group management (not sure if something is missing, have I missed something?).

I didn't do the Sonos way because I think it sucks, so I did a drag and drop solution instead. Drag the player name onto another zone to move it, or drop it outside all zones to detach it as a standalone player. What do you guys think about that? I just realized that it might be a problem of you have a lot of players which actually fills up the whole left column, but I will try and find a solution to that.

This will of course not work on a touch device, but the intended usage for this is a desktop (I will focus on a mobile version and a tablet version later). Just realize that a web controller would be useful for ChromeOS users as well.
Badge +1
I've submitted a pull request for to correct my (dumb) mistake. Hopefully it'll be accepted soon, and you'll be back in business.

Sorry again.
Userlevel 4
Badge +14
Okay, did a basic implementation of favorite selection, double clicking the favorite will replace the queue (or start radio).

I also recorded a video for those of you who don't want to mess around with node and git to try it out, this is how it looks like:

http://www.youtube.com/watch?v=Ad80vH1igFU

Actually, I'm pretty impressed my self with how good it actually behaves in a web browser...
Userlevel 4
Badge +14
Thanks for the quick fix, I have merged the pull request now.
Userlevel 2
Starting to look very good!! I have been following the development closely. I currently have the nodejs webserver hosted on my NAS4Free box running freeBSD. All functions work nicely and so far it makes a very useable controller and is super quick. Keep up the good work. Works with most browsers even mobile devices are reasonably functional. Keep this up and we might actually have a workable controller for the Linux community finally. Thanks again. Any basic assistance or testing required, if I can help certainly let me know. Ynot.
Badge
Excellent - many thanks Matt and Jishi:D
Agreed.... I've got node running in a ubuntu vm, and hosting from there....

So far any testing from desktops and the netbook are working.... Haven't tried the ipad, or the "phablet", phones....

Definitely great work.....
Userlevel 4
Badge +14
I have started working on the mobile version of the web controller, here is a quick screenshot:

http://upload.grabbarna.se/files/Screen%20Shot%202014-07-03%20at%2023.55.09.png

The good thing is that Chrome for Android now supports "Add to homepage" web apps, which means that you can hopefully get a native look and feel on it (Safari for iOS supports it as well).

My first target is an improved volume control (with percentage feedback and easier to adjust at low volumes). I'll try and keep you posted.
Hey J,

Been running the controller through pm2 for just over an hour now....

I've noticed on the "pm2 list", that the memory in use seems to be "slowly" increasing from:

22.5 mb, up to currently 41.992 mb....

Not saying there's a memory leak, as I have no idea what exactly pm2 is reporting for memory utilization. And a lot of that time it would seem that the "page" is in the background browser window.

But I thought you should know, since it's maybe something related to the node 10.0.21 build I've got vs your 0.8.x....
Userlevel 4
Badge +14
If you want to try out the mobile version, you can pull the "mobile" branch from sonos-web-controller, or download this:

https://github.com/jishi/node-sonos-web-controller/archive/mobile.zip

then visit http://IP:8080/m from your mobile browser. Only tested in Chrome for Android as of now. You can also try the "Add to homescreen" feature, which would open it up fullscreen.

Today only prev, play/pause, next and group volume works. And it will control the first zone that it finds, no way to select.
Userlevel 4
Badge +14
I haven't really looked into the memory utilization yet, so any observations are of interest.

I don't know how aggressive the garbage collect in node is, and if you have a lot of free memory I wouldn't be surprised it the memory usage seems high. When you've had it running for a few days, it would be nice to hear what your consumption would be.
Badge
Thanks for your work. I've been using AirSonos for a couple weeks, and its awesome.
Userlevel 4
Badge +14
And a lot of that time it would seem that the "page" is in the background browser window.

Could you explain what you mean by that?
Userlevel 4
Badge +14
Thanks for your work. I've been using AirSonos for a couple weeks, and its awesome.

Thanks, but I can't take credit for AirSonos, haven't been involved in that at all. Looks really neat though!
Userlevel 2
Just tested the tts functionality and as long as nothing is playing it works great. However the fact that the que is replaced is a bit of a problem. I have seen a few mentions of the ability to save the playstate and then reload it afterwards. Any pointers as to how I could achieve that?