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

Userlevel 4
Badge +14
Great, that should work. I try it later when I'm at home.
How is it possible to get the "Turn Light on when audio is playing" feature from the Raspberry Pi? Is there a setting for that?


No, there is no setting. You will need to hack it in yourself.

Depending on what you are running, add this second line right after this line:

code:

var discovery = new SonosDiscovery();
discovery.setToggleLED(true);


You only need to do this for one of your apps, if you are running multiple (like, web-controller and http-api)
Userlevel 4
Badge +14
Hi. Just wanted to drop a quick note of thanks for node-sonos-discovery. I used it in my project to get a Griffin PowerMate to control my Sonos. You can check it out here:

Controlling a Sonos with the Griffin PowerMate


Wow, that's a neat combo! Ever considered adding an LCD display to make use of the wheel even more? Thinking about the favorites short coming. If you had like double press, then roll wheel to select favorite. Or if you could make a logical blink sequence to feeback which favorite you select.

Double press, blink once. If you turn the wheel, it would blink twice, trice etc and then press it again selects the favorite.
Badge +1
Hi. Just wanted to drop a quick note of thanks for node-sonos-discovery. I used it in my project to get a Griffin PowerMate to control my Sonos. You can check it out here:

Controlling a Sonos with the Griffin PowerMate
Badge +2
Great, that should work. I try it later when I'm at home.
How is it possible to get the "Turn Light on when audio is playing" feature from the Raspberry Pi? Is there a setting for that?
Userlevel 4
Badge +14
Doesn't seem like you are standing in the folder where the package.json exists for the IR project.

If you installed the node-sonos-remote-control into /home/pi/sonos-remote-control, you need to cd into that dir and invoke "npm install".
Userlevel 4
Badge +14
Well, I started on it but ran into some issues that resulted in banging my head into the wall an evening and then I gave up and went on with other matters in my life ;)

The error you are seeing is because it hasn't the necessary sonos-discovery module in it's node_modules folder. It should have the appropriate dependency added in the package.json file so a:

npm install

should fix that. However, configuring LIRC isn't as straightforward as one would hope though 🙂 Unfortunately I wiped my installation so I don't have the possibility to check my config right now.
Badge +2
I'm a little rusty on how to create an image but I can probably write up a step-by-step how-to on the raspberry installation, but I would need to redo it all from scratch to take note of all steps. If I manage to create a clean installation I may even be able to create an image for it, but in that case it would be preferable to have some sort of easy update feature as well.

Any news about this? I'll start tomorrow with my raspberry pi and appreciate every piece and bit to help me getting started...
I remember my first single board computer. It was ground breaking at the time with a four character seven segment display, a numeric keypad, and was about the size of the larger iPads. I paid several times the cost of CuBox.
Userlevel 4
Badge +14
I just ordered a CuBox-i2 from http://cubox-i.com/

It has a really nice form factor, with built-in IR-receiver. I ordered the i2 because I am going to run Plex on it, but for only controlling Sonos via IR, hosting the http api and run the web-controller the i1 would probably be more than enough.

Maybe I can even make a pre-made image with everything needed 😃
Userlevel 4
Badge +14
As I have stated in the readme, I will never target Safari personally. Focus will be on cross-platform available browsers.

Webkit is also seriously broken when it comes to some newer css-techniques which makes it difficult to support for this.

It is also not intended for mobile devices, since it doesn't handle touch events. The plan is to create a touch-friendly layout instead (when I find the time).
Badge
Thank you for fixing that. Boots fine how.
In Firefox it works great. But in Safari (iMac, iPhone, iPad) I have several small issues. For example the queue is not scrollable on iMac. But on iPhone and iPad it is fully expanded but also not scrollable. The volume behaves strangely. When I change the volume, the group volume slider goes wild and sometimes the button even flies off the slider. Keep up the good work.
Userlevel 4
Badge +14
I installed this app on a Raspberry Pi an it looks great! But now I'm trying to get it running on boot (with Forever) and there is one strange thing. When I navigate to the sonos folder first, it runs just fine:

cd /home/pi/sonos
node server.js


But when I run it from any other folder I only get a blank screen in the web browser:

node /home/pi/sonos/server.js


No error message. It seems to be running though...


Found the problem. I have pushed an update to the git-repo that fixes that.
Badge
I installed this app on a Raspberry Pi an it looks great! But now I'm trying to get it running on boot (with Forever) and there is one strange thing. When I navigate to the sonos folder first, it runs just fine:

cd /home/pi/sonos
node server.js


But when I run it from any other folder I only get a blank screen in the web browser:

node /home/pi/sonos/server.js


No error message. It seems to be running though...
Badge +2
I'm a little rusty on how to create an image but I can probably write up a step-by-step how-to on the raspberry installation, but I would need to redo it all from scratch to take note of all steps. If I manage to create a clean installation I may even be able to create an image for it, but in that case it would be preferable to have some sort of easy update feature as well.

That's great news. I was doing some little projects with the Raspberry in the past and I have to some extend experience with programming and computers, but not as much as you are talking about in this whole thread. So I'm a little worried, but I'll start soon. Still waiting for the IR receiver, case and some other accessories. Maybe I can help with the HTML/CSS UI support. My use case is your mentioned BigPicture-Support (what is playing now and next) and IR support (for basic navigation like Play/Stopp, Next, Previous, Favorite 10).
Userlevel 4
Badge +14
Hi Jishi,

Thanks for your project and support you provide. Would it be possible to get an image for my Raspberry Pi from you. I'm not so used to compiling and more. An alternative would be a detailed installation guide. Is one or the other possible?

Best regards, Olly


I'm a little rusty on how to create an image but I can probably write up a step-by-step how-to on the raspberry installation, but I would need to redo it all from scratch to take note of all steps. If I manage to create a clean installation I may even be able to create an image for it, but in that case it would be preferable to have some sort of easy update feature as well.
Badge +2
...

Hi Jishi,

Thanks for your project and support you provide. Would it be possible to get an image for my Raspberry Pi from you. I'm not so used to compiling and more. An alternative would be a detailed installation guide. Is one or the other possible?

Best regards, Olly
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

Cheers!


Awesome Library! I've used it to create a tool that does store the listening positions of titles longer 10 minutes (configurable). And it restores the last known position when you start it again.

http://www.schrankmonster.de/2014/03/23/give-you-sonos-audiobook-podcast-auto-bookmarker-lose-listening-progress-again/

Of course everything also on Github: https://github.com/bietiekay/sonos-auto-bookmarker
Userlevel 2
Hello again,

You can check my changes on my github forks :
* https://github.com/gfraysse/node-sonos-discovery
* https://github.com/gfraysse/node-sonos-web-controller

Let me know if you feel it is of any interest it lacks some polishing but I'm still working on it.
I still need to get the missing icons and integrate them.
Userlevel 4
Badge +14
For now it's on my home git repo but I'll upload it on my fork on github and send you the link.

I'm looking for the icons used for the music library browsing : back icons, Favorites and Music library icons. If you already have them that would help me otherwise I'll try to get them from the windows app too.

I've also looked to implement the "Radio" feature but haven't had the opportunity to do the packet captures to understand how the TuneIn implementation in Sonos works.

Regards


Let me know if you manage to extract them (I think I used Telerik JustDecompile http://www.telerik.com/products/decompiler.aspx), otherwise I can fix it easily.

I think TuneIn and most music services connect directly from the controller to the services without using the players, which makes it a bit more troublesome to implement. TuneIn doesn't have a free API and you need some credentials (I think) in order to get it to work.
Userlevel 2
For now it's on my home git repo but I'll upload it on my fork on github and send you the link.

I'm looking for the icons used for the music library browsing : back icons, Favorites and Music library icons. If you already have them that would help me otherwise I'll try to get them from the windows app too.

I've also looked to implement the "Radio" feature but haven't had the opportunity to do the packet captures to understand how the TuneIn implementation in Sonos works.

Regards
Userlevel 4
Badge +14
Did you fork it on github? Then just send me a pullrequest and I'll try and merge it in.

I extracted most of the graphical elements from the Windows application, since they were basically embedded png resources. However, I wanted the gui to scale nicely, so I remade a lot of them in SVG and tried to reproduce most of it using standard css. Today it is only the volume scrubber and the shuffle/repeat/crossfade that are still images extracted from the Sonos application.

If you tell me which one you need I can easily extract them and add to the repo.
Userlevel 2
As I was lacking the music library browsing feature which is my main use, so I decided to start developping it myself. I actually have something working.
It still needs some polishing and some functions (like adding a whole album to the queue for example) are still missing but browsing back and forth between artists and albums does work as well as going back to the previous menu.

jishi (or anyone else) : if you're interested I can send you the code in some way (via mail or github). Feel free to do whatever you want with it.

I do have one question though, one thing that I'm missing is the set of icons used by the Sonos app to have the same look & feel, I was wondering how you got the rest of the design ?

Best regards
Userlevel 4
Badge +14
Well, that's not really the optimal solution. I would need to get some info about the state of the players before and after you try and group them the second time.

If you could give me the info from http://IP:1400/status/perf

From both players and PM them to me. I only need the first few lines (10 or so), the rest is irrelevant.
Userlevel 2
Bummer okay - I'll just restart the sonos-remote node every 5 minutes or so.
Userlevel 4
Badge +14
player is the selected player, which in your case would always be TV Room since you don't have buttons to switch control.

player.coordinator is the coordinator player for a group. This is the player that you "initiated" the group from. According to your preset this would always be TV Room, but if you were to add "TV Room" to "Dining Room" from your Sonos controller, your groupVolume control wouldn't work.

I used pm2 ti run this yes, no problem. I have now switched my raspberry installation to rasplex, which is a bit dumber, so now I just start it with a autostart script like:
node sonos-lirc.js &
It won't restart if it crashes with this approach though.

It's weird that the preset only works one time, I haven't noticed this behavior in my setup. IT doesn't look like it breaks according to your logs either...