diff --git a/example-plugins/homebridge-samplePlatform/index.js b/example-plugins/homebridge-samplePlatform/index.js index 4b2beef..a7f1a8b 100644 --- a/example-plugins/homebridge-samplePlatform/index.js +++ b/example-plugins/homebridge-samplePlatform/index.js @@ -33,6 +33,12 @@ function SamplePlatform(log, config, api) { response.end(); } + if (request.url == "/reachability") { + this.updateAccessoriesReachability(); + response.writeHead(204); + response.end(); + } + if (request.url == "/remove") { this.removeAccessory(); response.writeHead(204); @@ -188,6 +194,14 @@ SamplePlatform.prototype.addAccessory = function(accessoryName) { this.api.registerPlatformAccessories("homebridge-samplePlatform", "SamplePlatform", [newAccessory]); } +SamplePlatform.prototype.updateAccessoriesReachability = function() { + console.log("Update Reachability"); + for (var index in this.accessories) { + var accessory = this.accessories[index]; + accessory.updateReachability(false); + } +} + // Sample function to show how developer can remove accessory dynamically from outside event SamplePlatform.prototype.removeAccessory = function() { console.log("Remove Accessory");