From f6df85695df1070470804e00b592c3c3988d3b83 Mon Sep 17 00:00:00 2001 From: Khaos Tian Date: Sun, 28 Feb 2016 18:19:46 -0800 Subject: [PATCH] Forward identity only if plugin cares about event --- lib/platformAccessory.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/platformAccessory.js b/lib/platformAccessory.js index 324aa28..a3d8f61 100644 --- a/lib/platformAccessory.js +++ b/lib/platformAccessory.js @@ -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)); }