Minor Tweak

This commit is contained in:
Khaos Tian
2016-09-26 14:15:12 -07:00
parent ecd06d7239
commit 66ea6e640d
2 changed files with 13 additions and 2 deletions

View File

@@ -140,6 +140,11 @@ PlatformAccessory.prototype.configureCameraSource = function(cameraSource) {
PlatformAccessory.prototype._prepareAssociatedHAPAccessory = function () {
this._associatedHAPAccessory = new Accessory(this.displayName, this.UUID);
if (this.cameraSource) {
this._associatedHAPAccessory.configureCameraSource(this.cameraSource);
}
this._associatedHAPAccessory._sideloadServices(this.services);
this._associatedHAPAccessory.category = this.category;
this._associatedHAPAccessory.reachable = this.reachable;

View File

@@ -462,12 +462,14 @@ Server.prototype._handleUnregisterPlatformAccessories = function(accessories) {
}
Server.prototype._handlePublishCameraAccessories = function(accessories) {
var accessoryPin = (this._config.bridge || {}).pin || "031-45-154";
for (var index in accessories) {
var accessory = accessories[index];
accessory._prepareAssociatedHAPAccessory();
var hapAccessory = accessory._associatedHAPAccessory;
var advertiseAddress = mac.generate(accessory.uuid);
var advertiseAddress = mac.generate(accessory.UUID);
if (this._publishedCameras[advertiseAddress]) {
throw new Error("Camera accessory %s experienced an address collision.", accessory.displayName);
@@ -475,9 +477,13 @@ Server.prototype._handlePublishCameraAccessories = function(accessories) {
this._publishedCameras[advertiseAddress] = accessory;
}
hapAccessory.on('listening', function(port) {
log.info("%s is running on port %s.", accessory.displayName, port);
});
hapAccessory.publish({
username: advertiseAddress,
pincode: bridgeConfig.pin || "031-45-154",
pincode: accessoryPin,
category: accessory.category
}, this._allowInsecureAccess);
}