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

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
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
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).
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...
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
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
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).
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 😃
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.
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...
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.
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".
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?
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
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.
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)
Badge +1
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.


Actually, what I'm looking at now is caching the favorites whenever I receive a "favorites" emit, and then using some kind of text-to-speech to read the favorites when the wheel is turned and the zone player is off. This would go through the Pi's speaker, mostly because I don't want to destroy the Sonos queue by shoving an MP3 at it.

I considered (and am still considering) the LCD thing, but the text to speech thing sounds more fun! :D

I'll keep the thread up to date.
Userlevel 4
Badge +14
This would go through the Pi's speaker, mostly because I don't want to destroy the Sonos queue by shoving an MP3 at it.


FYI, you can play an MP3 on the player without touching the queue. A SetAVTransportURI call will change what is currently playing to a single item which doesn't affect the queue (similar to a radiostation). However, you would loose the queue position and track position, but that could be saved before hand and restored after.

To restore the queue, you just call SetAVTransportURI and set it to "x-rincon-queue:RINCON_12345678901201400#0" where the RINCON_xxxxxxxxx is the UUID of the player (I don't know why it needs the uuid, I don't think you can set a player to play another players queue...).

Worth noting is that you don't need to use the x-rincon-mp3radio: scheme for it neither, you can just set it to a connectable http url like: http://192.168.0.100:1234/tts.mp3 and it will play it straight up. It just need to end in .mp3 for it to read is as an mp3.

A bit more work, and maybe you don't want the sound through your Sonos anyway, but I just wanted to point out that possibility.
Badge +1
FYI, you can play an MP3 on the player without touching the queue. A SetAVTransportURI call will change what is currently playing to a single item which doesn't affect the queue (similar to a radiostation). However, you would loose the queue position and track position, but that could be saved before hand and restored after.


Thanks. That's a neat solution. I've figured out how to set the mp3 url, then set the queue uri back, but how can I get (and then restore) the queue (and even track, though less important) position?
Userlevel 4
Badge +14
Thanks. That's a neat solution. I've figured out how to set the mp3 url, then set the queue uri back, but how can I get (and then restore) the queue (and even track, though less important) position?

You need to note the trackno that was active, then use the seek() method to restore it after you have re-enabled the queue. If you have noted the elapsed time as well, you can trackSeek() as well, before you invoke play().

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.
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 🙂
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.
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.
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.