diff --git a/app.js b/app.js index b24ad18..2d6307c 100644 --- a/app.js +++ b/app.js @@ -21,12 +21,15 @@ if (!fs.existsSync(configPath)) { // Initialize HAP-NodeJS hap.init(); -// Start by creating our Bridge which will host all loaded Accessories -var bridge = new Bridge('HomeBridge', uuid.generate("HomeBridge")); - // Load up the configuration file var config = JSON.parse(fs.readFileSync(configPath)); +// pull out our custom Bridge settings from config.json, if any +var bridgeConfig = config.bridge || {}; + +// Start by creating our Bridge which will host all loaded Accessories +var bridge = new Bridge(bridgeConfig.name || 'Homebridge', uuid.generate("HomeBridge")); + // keep track of async calls we're waiting for callbacks on before we can start up // this is hacky but this is all going away once we build proper plugin support var asyncCalls = 0; @@ -139,9 +142,9 @@ function loadPlatforms() { function publish() { bridge.publish({ - username: "CC:22:3D:E3:CE:27", - port: 51826, - pincode: "031-45-154", + username: bridgeConfig.username || "CC:22:3D:E3:CE:27", + port: bridgeConfig.port || 51826, + pincode: bridgeConfig.pin || "031-45-154", category: Accessory.Categories.OTHER }); } diff --git a/config-sample.json b/config-sample.json index a9477d0..952067a 100644 --- a/config-sample.json +++ b/config-sample.json @@ -1,4 +1,11 @@ { + "bridge": { + "name": "Homebridge", + "username": "CC:22:3D:E3:CE:27", + "port": 51826, + "pin": "031-45-154" + }, + "description": "This is an example configuration file with all supported devices. You can use this as a template for creating your own configuration file containing devices you actually own.", "platforms": [