From 7436be9b44d20778954c5ff7ab5d332c30023b25 Mon Sep 17 00:00:00 2001 From: Khaos Tian Date: Mon, 8 Feb 2016 14:50:50 -0800 Subject: [PATCH] Add example to update reachability --- example-plugins/homebridge-samplePlatform/index.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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");