Skip to content

Commit

Permalink
add multiple instances
Browse files Browse the repository at this point in the history
  • Loading branch information
cflurin committed May 17, 2018
1 parent 5c3a3e8 commit 0595ff6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions index.js
Expand Up @@ -10,6 +10,7 @@ var platform_name = "mqtt";
var plugin_name = "homebridge-" + platform_name;
var storagePath;
var plugin_version;
var multiple = false;

module.exports = function(homebridge) {
console.log("homebridge API version: " + homebridge.version);
Expand All @@ -29,9 +30,9 @@ function PluginPlatform(log, config, api) {
this.log = log;

if (typeof(config) === "undefined" || config === null) {
this.log.error("config undefined or null!");
this.log("storagePath = %s", storagePath);
process.exit(1);
multiple = true;
this.log.warn("config undefined in '%s', irrelevant by multiple homebridge instances.", storagePath);
return;
}

plugin_version = Utils.readPluginVersion();
Expand Down Expand Up @@ -72,9 +73,11 @@ function PluginPlatform(log, config, api) {
}

PluginPlatform.prototype.configureAccessory = function(accessory) {

//this.log.debug("configureAccessory %s", JSON.stringify(accessory, null, 2));
cachedAccessories++;

this.controller.configureAccessory(accessory);
if (!multiple) {
this.controller.configureAccessory(accessory);
}
}
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "homebridge-mqtt",
"version": "0.4.8",
"version": "0.5.0",
"description": "MQTT Plugin for Homebridge",
"license": "ISC",
"author": {
Expand Down

0 comments on commit 0595ff6

Please sign in to comment.