mirror of
https://github.com/mtan93/homebridge.git
synced 2026-04-16 14:23:10 +01:00
Fix name/log var corruption
This commit is contained in:
59
app.js
59
app.js
@@ -100,34 +100,39 @@ function loadPlatforms() {
|
|||||||
|
|
||||||
var platformInstance = new platformConstructor(log, platformConfig);
|
var platformInstance = new platformConstructor(log, platformConfig);
|
||||||
|
|
||||||
|
// wrap name and log in a closure so they don't change in the callback
|
||||||
|
function getAccessories(name, log) {
|
||||||
|
asyncCalls++;
|
||||||
|
platformInstance.accessories(function(foundAccessories){
|
||||||
|
asyncCalls--;
|
||||||
|
// loop through accessories adding them to the list and registering them
|
||||||
|
for (var i = 0; i < foundAccessories.length; i++) {
|
||||||
|
var accessoryInstance = foundAccessories[i];
|
||||||
|
|
||||||
|
log("Initializing device with name " + accessoryInstance.name + "...")
|
||||||
|
|
||||||
|
// Extract the raw "services" for this accessory which is a big array of objects describing the various
|
||||||
|
// hooks in and out of HomeKit for the HAP-NodeJS server.
|
||||||
|
var services = accessoryInstance.getServices();
|
||||||
|
|
||||||
|
// Create the actual HAP-NodeJS "Accessory" instance
|
||||||
|
var accessory = accessoryLoader.parseAccessoryJSON({
|
||||||
|
displayName: name,
|
||||||
|
services: services
|
||||||
|
});
|
||||||
|
|
||||||
|
// add it to the bridge
|
||||||
|
bridge.addBridgedAccessory(accessory);
|
||||||
|
}
|
||||||
|
|
||||||
|
// were we the last callback?
|
||||||
|
if (asyncCalls === 0 && !asyncWait)
|
||||||
|
publish();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// query for devices
|
// query for devices
|
||||||
asyncCalls++;
|
getAccessories(name, log);
|
||||||
platformInstance.accessories(function(foundAccessories){
|
|
||||||
asyncCalls--;
|
|
||||||
// loop through accessories adding them to the list and registering them
|
|
||||||
for (var i = 0; i < foundAccessories.length; i++) {
|
|
||||||
var accessoryInstance = foundAccessories[i];
|
|
||||||
|
|
||||||
log("Initializing device with name " + accessoryInstance.name + "...")
|
|
||||||
|
|
||||||
// Extract the raw "services" for this accessory which is a big array of objects describing the various
|
|
||||||
// hooks in and out of HomeKit for the HAP-NodeJS server.
|
|
||||||
var services = accessoryInstance.getServices();
|
|
||||||
|
|
||||||
// Create the actual HAP-NodeJS "Accessory" instance
|
|
||||||
var accessory = accessoryLoader.parseAccessoryJSON({
|
|
||||||
displayName: name,
|
|
||||||
services: services
|
|
||||||
});
|
|
||||||
|
|
||||||
// add it to the bridge
|
|
||||||
bridge.addBridgedAccessory(accessory);
|
|
||||||
}
|
|
||||||
|
|
||||||
// were we the last callback?
|
|
||||||
if (asyncCalls === 0 && !asyncWait)
|
|
||||||
publish();
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user