Skip to content

Commit

Permalink
Add example to update reachability
Browse files Browse the repository at this point in the history
  • Loading branch information
KhaosT committed Feb 8, 2016
1 parent 2ad7932 commit 7436be9
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions example-plugins/homebridge-samplePlatform/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 7436be9

Please sign in to comment.