Merge remote-tracking branch 'nfarina/master'

# Conflicts:
#	lib/plugin.js
This commit is contained in:
straccio
2016-11-28 13:36:00 +01:00
3 changed files with 17 additions and 13 deletions

View File

@@ -166,10 +166,12 @@ Plugin.installed = function() {
// reconstruct full path // reconstruct full path
var pluginPath = path.join(requirePath, name); var pluginPath = path.join(requirePath, name);
try {
// we only care about directories // we only care about directories
if (!fs.statSync(pluginPath).isDirectory()) continue; if (!fs.statSync(pluginPath).isDirectory()) continue;
} catch (e) {
continue;
}
// does this module contain a package.json? // does this module contain a package.json?
var pjson; var pjson;
try { try {

View File

@@ -23,7 +23,9 @@ module.exports = {
Server: Server Server: Server
} }
function Server(insecureAccess) { function Server(insecureAccess, opts) {
opts = opts || {};
// Setup Accessory Cache Storage // Setup Accessory Cache Storage
accessoryStorage.initSync({ dir: User.cachedAccessoryPath() }); accessoryStorage.initSync({ dir: User.cachedAccessoryPath() });
@@ -46,7 +48,7 @@ function Server(insecureAccess) {
}.bind(this)); }.bind(this));
this._plugins = this._loadPlugins(); // plugins[name] = Plugin instance this._plugins = this._loadPlugins(); // plugins[name] = Plugin instance
this._config = this._loadConfig(); this._config = opts.config || this._loadConfig();
this._cachedPlatformAccessories = this._loadCachedPlatformAccessories(); this._cachedPlatformAccessories = this._loadCachedPlatformAccessories();
this._bridge = this._createBridge(); this._bridge = this._createBridge();
@@ -55,7 +57,7 @@ function Server(insecureAccess) {
this._publishedCameras = {}; this._publishedCameras = {};
this._setupManager = new BridgeSetupManager(); this._setupManager = new BridgeSetupManager();
this._setupManager.on('newConfig', this._handleNewConfig.bind(this)); this._setupManager.on('newConfig', this._handleNewConfig.bind(this));
this._setupManager.on('requestCurrentConfig', function(callback) { this._setupManager.on('requestCurrentConfig', function(callback) {
callback(this._config); callback(this._config);
}.bind(this)); }.bind(this));
@@ -93,7 +95,7 @@ Server.prototype.run = function() {
Server.prototype._publish = function() { Server.prototype._publish = function() {
// pull out our custom Bridge settings from config.json, if any // pull out our custom Bridge settings from config.json, if any
var bridgeConfig = this._config.bridge || {}; var bridgeConfig = this._config.bridge || {};
var info = this._bridge.getService(Service.AccessoryInformation); var info = this._bridge.getService(Service.AccessoryInformation);
if (bridgeConfig.manufacturer) if (bridgeConfig.manufacturer)
info.setCharacteristic(Characteristic.Manufacturer, bridgeConfig.manufacturer); info.setCharacteristic(Characteristic.Manufacturer, bridgeConfig.manufacturer);
@@ -168,7 +170,7 @@ Server.prototype._loadConfig = function() {
// Complain and exit if it doesn't exist yet // Complain and exit if it doesn't exist yet
if (!fs.existsSync(configPath)) { if (!fs.existsSync(configPath)) {
log.warn("config.json (%s) not found.", configPath); log.warn("config.json (%s) not found.", configPath);
var config = {}; var config = {};
config.bridge = { config.bridge = {
@@ -427,7 +429,7 @@ Server.prototype._handleRegisterPlatformAccessories = function(accessories) {
accessory._prepareAssociatedHAPAccessory(); accessory._prepareAssociatedHAPAccessory();
hapAccessories.push(accessory._associatedHAPAccessory); hapAccessories.push(accessory._associatedHAPAccessory);
this._cachedPlatformAccessories.push(accessory); this._cachedPlatformAccessories.push(accessory);
} }
@@ -513,7 +515,7 @@ Server.prototype._handleNewConfig = function(type, name, replace, config) {
} else { } else {
var targetName; var targetName;
if (name.indexOf('.') !== -1) { if (name.indexOf('.') !== -1) {
targetName = name.split(".")[1]; targetName = name.split(".")[1];
} }
var found = false; var found = false;
for (var index in this._config.accessories) { for (var index in this._config.accessories) {
@@ -545,7 +547,7 @@ Server.prototype._handleNewConfig = function(type, name, replace, config) {
} else { } else {
var targetName; var targetName;
if (name.indexOf('.') !== -1) { if (name.indexOf('.') !== -1) {
targetName = name.split(".")[1]; targetName = name.split(".")[1];
} }
var found = false; var found = false;

View File

@@ -1,7 +1,7 @@
{ {
"name": "homebridge", "name": "homebridge",
"description": "HomeKit support for the impatient", "description": "HomeKit support for the impatient",
"version": "0.4.9", "version": "0.4.10",
"scripts": { "scripts": {
"dev": "DEBUG=* ./bin/homebridge -D -P example-plugins/ || true" "dev": "DEBUG=* ./bin/homebridge -D -P example-plugins/ || true"
}, },