Add example to update reachability

This commit is contained in:
Khaos Tian
2016-02-08 14:50:50 -08:00
parent 2ad7932fbc
commit 7436be9b44

View File

@@ -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");