var fs = require('fs'); var path = require('path'); var storage = require('node-persist'); var crypto = require('crypto'); console.log("Starting HomeBridge server..."); // Look for the configuration file var configPath = path.join(__dirname, "config.json"); // Complain and exit if it doesn't exist yet if (!fs.existsSync(configPath)) { console.log("Couldn't find a config.json file in the same directory as app.js. Look at config-sample.json for examples of how to format your config.js and add your home accessories."); process.exit(1); } // Initialize persistent storage storage.initSync(); // Load up the configuration file var config = JSON.parse(fs.readFileSync(configPath)); // Just to prevent them getting garbage collected var accessories = []; function startup() { if (config.platforms) loadPlatforms(); if (config.accessories) loadAccessories(); } function loadAccessories() { // Instantiate all accessories in the config console.log("Loading " + config.accessories.length + " accessories..."); for (var i=0; i