mirror of
https://github.com/mtan93/homebridge.git
synced 2026-03-08 05:31:55 +00:00
Add example to update reachability
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user