From ecd06d72394215e437ea928c66f8a6852f740a99 Mon Sep 17 00:00:00 2001 From: Khaos Tian Date: Mon, 26 Sep 2016 13:19:50 -0700 Subject: [PATCH] Bump api version --- lib/api.js | 2 +- lib/server.js | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/api.js b/lib/api.js index 41aea23..738de79 100644 --- a/lib/api.js +++ b/lib/api.js @@ -20,7 +20,7 @@ function API() { this._dynamicPlatforms = {}; // this._dynamicPlatforms[pluginName.platformName] = platform constructor // expose the homebridge API version - this.version = 2.0; + this.version = 2.1; // expose the User class methods to plugins to get paths. Example: homebridge.user.storagePath() this.user = User; diff --git a/lib/server.js b/lib/server.js index 2e3013f..5a0b612 100644 --- a/lib/server.js +++ b/lib/server.js @@ -52,6 +52,7 @@ function Server(insecureAccess) { this._activeDynamicPlugins = {}; this._configurablePlatformPlugins = {}; + this._publishedCameras = {}; this._setupManager = new BridgeSetupManager(); this._setupManager.on('newConfig', this._handleNewConfig.bind(this)); @@ -466,9 +467,16 @@ Server.prototype._handlePublishCameraAccessories = function(accessories) { accessory._prepareAssociatedHAPAccessory(); var hapAccessory = accessory._associatedHAPAccessory; + var advertiseAddress = mac.generate(accessory.uuid); + + if (this._publishedCameras[advertiseAddress]) { + throw new Error("Camera accessory %s experienced an address collision.", accessory.displayName); + } else { + this._publishedCameras[advertiseAddress] = accessory; + } hapAccessory.publish({ - username: mac.generate(accessory.uuid), + username: advertiseAddress, pincode: bridgeConfig.pin || "031-45-154", category: accessory.category }, this._allowInsecureAccess);