Forward identity only if plugin cares about event

This commit is contained in:
Khaos Tian
2016-02-28 18:19:46 -08:00
parent 32e776203f
commit f6df85695d

View File

@@ -131,7 +131,13 @@ PlatformAccessory.prototype._prepareAssociatedHAPAccessory = function () {
this._associatedHAPAccessory._sideloadServices(this.services);
this._associatedHAPAccessory.reachable = this.reachable;
this._associatedHAPAccessory.on('identify', function(paired, callback) {
this.emit('identify', paired, callback);
if (this.listeners('identify').length > 0) {
// allow implementors to identify this Accessory in whatever way is appropriate, and pass along
// the standard callback for completion.
this.emit('identify', paired, callback);
} else {
callback();
}
}.bind(this));
}