-
-
Notifications
You must be signed in to change notification settings - Fork 145
Logical Device Support #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Completed start/stop on base sonos class
…wait for initial data
6f6e52a to
30c4b7b
Compare
|
@bencevans or @mrose17, could one of you review this code? There's also a question of whether or not this works on stereo pairs - I unfortunately don't have one to test with and have been working with a grouped Play:1/Play:3. |
|
I can view code but still don't have a Sonos where I am now so won't get to test out till later this month. |
|
@bencevans - kk. I've been testing against real devices, and perhaps @mrose17 can help out as well. Separately, a pure code review would be great if you have time. |
examples/volumeWatcher.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed starting the listeners on initialisation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(oops - this should be initialize() instead of startListeners())
We previously discussed doing initialization for listeners automatically with search (meaning manually spun up Sonos instances would have to initialize()) on their own. Are you thinking we should do automatic initialization for any Sonos instance? (also, how? since a callback is needed - not sure if it's good practice to do that from a constructor.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I was thinking the client would be like a Sequelize
instance. (are you familiar?)
On Mon, 8 Dec, 2014 at 5:36 AM, Stephen Wan notifications@github.com
wrote:
In examples/volumeWatcher.js:
@@ -0,0 +1,8 @@
+var Sonos = require('../index').Sonos;
+
+var device = new Sonos(process.env.SONOS_HOST || '192.168.2.11');
+device.startListeners(function() {
(oops - this should be initialize() instead of startListeners())We previously discussed doing initialization for listeners
automatically with search (meaning manually spun up Sonos instances
would have to initialize()) on their own. Are you thinking we should
do automatic initialization for any Sonos instance? (also, how? since
a callback is needed - not sure if it's good practice to do that from
a constructor.)—
Reply to this email directly or view it on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, iirc Sequelize does something like...
new Sequelize().initialize().etc();
Which relies on promises. The current API here is:
new Sonos().initialize(callback);
Which is more or less the same thing, except using callbacks, not promises.
My thinking is that we can automatically initialize for Sonos and LogicalDevice instances returned by a search()/"managed" sonos device, but leave calling initialize() up to client code if manually constructed (i.e. new Sonos().initialize(...).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. That's true, I don't know about you but I'd rather keep the callback & EventEmitter style rather than promises. Your thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Callbacks seem reasonable here.
|
Just been for a peek through the code and it's looking delightful! |
|
@bencevans, @mrose17 - Any other comments on this before merge? |
|
Not from me (although can't test). Any thoughts from @mrose17 |
|
looks good to me. i won't be able to test until this evening though (i don't have a sonos here in the office... the new office will have one, hopefully)! i say "commit" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TypeError: Cannot read property '0' of undefined
at /Users/stephen/git/node-sonos/lib/events/volumeListener.js:16:84
at Parser. (/Users/stephen/git/node-sonos/node_modules/xml2js/lib/xml2js.js:255:20)
at Parser.emit (events.js:95:17)
- When changing EQ settings. Should guard this listener from assumptions
cc/ @bencevans
Changes:
addService/removeServiceto be prefixed with_.LogicalDeviceclass. Takes in an array of Sonos devices that can be managed together (i.e. forms a group or stereo pair). This class currently supports group change for volume. The API between aLogicalDeviceand regularSonosdevice should be identical. (Commands that are only addressed to the coordinator (e.g. play/pause) are simply passed down to the underlyingSonosprototype.volumeListenerclass to keep internal state on aSonosobject. Used byLogicalDeviceto do volume changes (but not on other methods).(Closes #43)