mirror of
https://github.com/mtan93/homebridge.git
synced 2026-03-08 05:31:55 +00:00
Merge pull request #715 from EdJoPaTo/multiAccessories
fixed SamplePlatform crashes
This commit is contained in:
@@ -28,7 +28,7 @@ function SamplePlatform(log, config, api) {
|
|||||||
|
|
||||||
this.requestServer = http.createServer(function(request, response) {
|
this.requestServer = http.createServer(function(request, response) {
|
||||||
if (request.url === "/add") {
|
if (request.url === "/add") {
|
||||||
this.addAccessory();
|
this.addAccessory(new Date().toISOString());
|
||||||
response.writeHead(204);
|
response.writeHead(204);
|
||||||
response.end();
|
response.end();
|
||||||
}
|
}
|
||||||
@@ -176,10 +176,6 @@ SamplePlatform.prototype.addAccessory = function(accessoryName) {
|
|||||||
console.log("Add Accessory");
|
console.log("Add Accessory");
|
||||||
var uuid;
|
var uuid;
|
||||||
|
|
||||||
if (!accessoryName) {
|
|
||||||
accessoryName = "Test Accessory"
|
|
||||||
}
|
|
||||||
|
|
||||||
uuid = UUIDGen.generate(accessoryName);
|
uuid = UUIDGen.generate(accessoryName);
|
||||||
|
|
||||||
var newAccessory = new Accessory(accessoryName, uuid);
|
var newAccessory = new Accessory(accessoryName, uuid);
|
||||||
@@ -216,4 +212,4 @@ SamplePlatform.prototype.removeAccessory = function() {
|
|||||||
this.api.unregisterPlatformAccessories("homebridge-samplePlatform", "SamplePlatform", this.accessories);
|
this.api.unregisterPlatformAccessories("homebridge-samplePlatform", "SamplePlatform", this.accessories);
|
||||||
|
|
||||||
this.accessories = [];
|
this.accessories = [];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user