mirror of
https://github.com/mtan93/homebridge.git
synced 2026-04-07 06:13:12 +01:00
@@ -13,15 +13,27 @@ SonosPlatform.prototype = {
|
|||||||
this.log("Fetching Sonos devices.");
|
this.log("Fetching Sonos devices.");
|
||||||
var that = this;
|
var that = this;
|
||||||
|
|
||||||
|
// track found devices so we don't add duplicates
|
||||||
|
var roomNamesFound = {};
|
||||||
|
|
||||||
sonos.search(function (device) {
|
sonos.search(function (device) {
|
||||||
that.log("Found device at " + device.host);
|
that.log("Found device at " + device.host);
|
||||||
|
|
||||||
device.deviceDescription(function (err, description) {
|
device.deviceDescription(function (err, description) {
|
||||||
if (description["zoneType"] != '11') {
|
if (description["zoneType"] != '11' && description["zoneType"] != '8') { // 8 is the Sonos SUB
|
||||||
that.log("Found playable device - " + description["roomName"]);
|
|
||||||
// device is an instance of sonos.Sonos
|
var roomName = description["roomName"];
|
||||||
var accessory = new SonosAccessory(that.log, that.config, device, description);
|
|
||||||
callback([accessory]);
|
if (!roomNamesFound[roomName]) {
|
||||||
|
roomNamesFound[roomName] = true;
|
||||||
|
that.log("Found playable device - " + roomName);
|
||||||
|
// device is an instance of sonos.Sonos
|
||||||
|
var accessory = new SonosAccessory(that.log, that.config, device, description);
|
||||||
|
callback([accessory]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
that.log("Ignoring playable device with duplicate room name - " + roomName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user