From 507bddc351dc1392f652dfc439e433e7d839a644 Mon Sep 17 00:00:00 2001 From: sean9keenan Date: Mon, 27 Feb 2017 23:40:20 -0800 Subject: [PATCH 01/17] Hack to prevent callback from being called multiple times --- index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 5d526c2..e52651c 100644 --- a/index.js +++ b/index.js @@ -319,9 +319,15 @@ function BigAssFanAccessory(log, config, existingAccessory) { BigAssFanAccessory.prototype.getStateFactory = function(propertyToWrap, subProperty, outputMapping) { return function(callback) { + // TODO: Determine why update can callback multiple times + // This temporarily prevents multiple calls to the callback + var callbackCalled = false; this.myBigAss[propertyToWrap].update(subProperty, function(err, value) { var returnVal = outputMapping(value); - callback(err, returnVal); + if (!callbackCalled) { // TODO: remove after bug is found + callbackCalled = true; + callback(err, returnVal); + } }); } } From c50d93b010b263fdbeafdf3d3feb48afb33bd76f Mon Sep 17 00:00:00 2001 From: pponce Date: Sat, 1 Apr 2017 16:28:16 -0700 Subject: [PATCH 02/17] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9586bfa..857b228 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "homebridge": ">=0.2.0" }, "dependencies": { - "BigAssFansAPI": ">=1.1.1" + "BigAssFansAPI": "git://github.com/pponce/BigAssFansAPI#master" }, "homepage": "https://github.com/sean9keenan/homebridge-bigAssFans" } From 0c53501cce3e659f024c5c1d7098b79fc27841a6 Mon Sep 17 00:00:00 2001 From: pponce Date: Sat, 1 Apr 2017 16:31:10 -0700 Subject: [PATCH 03/17] Update index.js --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 5d526c2..85ca7f3 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ var bigAssApi = require("BigAssFansAPI"); -bigAssApi.logging = false; +bigAssApi.logging = true; var Service, Characteristic; @@ -30,7 +30,9 @@ function BigAssFansPlatform(log, config, api) { this.fanMaster = new bigAssApi.FanMaster(this.numberOfFans); this.fanMaster.onFanFullyUpdated = function(myBigAss){ - platform.addAccessory(myBigAss); + console.log("Found a new fan with name '" + myBigAss.name + "'"); + console.log("and identifier: '" + myBigAss.id + "'\n"); + console.log("and lightExists: '" + myBigAss.light.exists + "'\n"); } if (api) { From ce43b9dc333b4b10e096857836c51869d35e06bf Mon Sep 17 00:00:00 2001 From: pponce Date: Sat, 1 Apr 2017 18:30:10 -0700 Subject: [PATCH 04/17] Update index.js --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 85ca7f3..5cf1317 100644 --- a/index.js +++ b/index.js @@ -250,6 +250,7 @@ function BigAssFanAccessory(log, config, existingAccessory) { var lightMaxBrightness = this.myBigAss.light.max ? this.myBigAss.light.max : 16; var fanMaxSpeed = this.myBigAss.fan.max ? this.myBigAss.fan.max : 7; + this.log("var this.myBigAss.light.exists = " this.myBigAss.light.exists ) if (this.myBigAss.light.exists) { this.log("Found a light for: " + this.homekitLightName); From dbacc8d52a9978058753e42e223572f94efc65a5 Mon Sep 17 00:00:00 2001 From: pponce Date: Sat, 1 Apr 2017 18:31:13 -0700 Subject: [PATCH 05/17] Update index.js --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 5cf1317..3eb27c4 100644 --- a/index.js +++ b/index.js @@ -250,7 +250,7 @@ function BigAssFanAccessory(log, config, existingAccessory) { var lightMaxBrightness = this.myBigAss.light.max ? this.myBigAss.light.max : 16; var fanMaxSpeed = this.myBigAss.fan.max ? this.myBigAss.fan.max : 7; - this.log("var this.myBigAss.light.exists = " this.myBigAss.light.exists ) + this.log("var this.myBigAss.light.exists = " this.myBigAss.light.exists ); if (this.myBigAss.light.exists) { this.log("Found a light for: " + this.homekitLightName); From b723b6da46dbd6356a31fb084f95d168778f11e5 Mon Sep 17 00:00:00 2001 From: pponce Date: Sat, 1 Apr 2017 18:33:34 -0700 Subject: [PATCH 06/17] Update index.js --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 3eb27c4..8a35faf 100644 --- a/index.js +++ b/index.js @@ -250,7 +250,7 @@ function BigAssFanAccessory(log, config, existingAccessory) { var lightMaxBrightness = this.myBigAss.light.max ? this.myBigAss.light.max : 16; var fanMaxSpeed = this.myBigAss.fan.max ? this.myBigAss.fan.max : 7; - this.log("var this.myBigAss.light.exists = " this.myBigAss.light.exists ); + console.log("var this.myBigAss.light.exists = " this.myBigAss.light.exists ); if (this.myBigAss.light.exists) { this.log("Found a light for: " + this.homekitLightName); From 44ccc92d738ab1b75c706fa731a6562243447983 Mon Sep 17 00:00:00 2001 From: pponce Date: Sat, 1 Apr 2017 18:34:39 -0700 Subject: [PATCH 07/17] Update index.js --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 8a35faf..35258f1 100644 --- a/index.js +++ b/index.js @@ -250,7 +250,7 @@ function BigAssFanAccessory(log, config, existingAccessory) { var lightMaxBrightness = this.myBigAss.light.max ? this.myBigAss.light.max : 16; var fanMaxSpeed = this.myBigAss.fan.max ? this.myBigAss.fan.max : 7; - console.log("var this.myBigAss.light.exists = " this.myBigAss.light.exists ); + console.log("var this.myBigAss.light.exists = " + this.myBigAss.light.exists ); if (this.myBigAss.light.exists) { this.log("Found a light for: " + this.homekitLightName); From 9316c69e3c926bca126a877537d2bdfec6767aab Mon Sep 17 00:00:00 2001 From: pponce Date: Sat, 1 Apr 2017 18:39:23 -0700 Subject: [PATCH 08/17] Update index.js --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 35258f1..980c789 100644 --- a/index.js +++ b/index.js @@ -30,6 +30,7 @@ function BigAssFansPlatform(log, config, api) { this.fanMaster = new bigAssApi.FanMaster(this.numberOfFans); this.fanMaster.onFanFullyUpdated = function(myBigAss){ + platform.addAccessory(myBigAss); console.log("Found a new fan with name '" + myBigAss.name + "'"); console.log("and identifier: '" + myBigAss.id + "'\n"); console.log("and lightExists: '" + myBigAss.light.exists + "'\n"); From 64e4edb97c226ac364d7ccce94f5f21ee4086af5 Mon Sep 17 00:00:00 2001 From: pponce Date: Sun, 2 Apr 2017 07:34:44 -0700 Subject: [PATCH 09/17] Update index.js --- index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 980c789..a6415cc 100644 --- a/index.js +++ b/index.js @@ -30,9 +30,14 @@ function BigAssFansPlatform(log, config, api) { this.fanMaster = new bigAssApi.FanMaster(this.numberOfFans); this.fanMaster.onFanFullyUpdated = function(myBigAss){ + console.log("\nBefore addAccessory:"); + console.log("Found a new fan with name '" + myBigAss.name + "'"); + console.log("and identifier: '" + myBigAss.id + "'"); + console.log("and lightExists: '" + myBigAss.light.exists + "'\n"); platform.addAccessory(myBigAss); + console.log("\nAfter addAccessory:"); console.log("Found a new fan with name '" + myBigAss.name + "'"); - console.log("and identifier: '" + myBigAss.id + "'\n"); + console.log("and identifier: '" + myBigAss.id + "'"); console.log("and lightExists: '" + myBigAss.light.exists + "'\n"); } From 72d6ca3fd28b90e0186ccecce66c610f3c6291be Mon Sep 17 00:00:00 2001 From: pponce Date: Sun, 2 Apr 2017 07:50:15 -0700 Subject: [PATCH 10/17] Update index.js --- index.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/index.js b/index.js index a6415cc..980c789 100644 --- a/index.js +++ b/index.js @@ -30,14 +30,9 @@ function BigAssFansPlatform(log, config, api) { this.fanMaster = new bigAssApi.FanMaster(this.numberOfFans); this.fanMaster.onFanFullyUpdated = function(myBigAss){ - console.log("\nBefore addAccessory:"); - console.log("Found a new fan with name '" + myBigAss.name + "'"); - console.log("and identifier: '" + myBigAss.id + "'"); - console.log("and lightExists: '" + myBigAss.light.exists + "'\n"); platform.addAccessory(myBigAss); - console.log("\nAfter addAccessory:"); console.log("Found a new fan with name '" + myBigAss.name + "'"); - console.log("and identifier: '" + myBigAss.id + "'"); + console.log("and identifier: '" + myBigAss.id + "'\n"); console.log("and lightExists: '" + myBigAss.light.exists + "'\n"); } From fac288a58be5d3ee45614dc1800b249d9c747328 Mon Sep 17 00:00:00 2001 From: pponce Date: Sun, 2 Apr 2017 13:00:57 -0700 Subject: [PATCH 11/17] Update index.js --- index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/index.js b/index.js index 980c789..b25b856 100644 --- a/index.js +++ b/index.js @@ -70,11 +70,13 @@ BigAssFansPlatform.prototype.addAccessory = function(theFan) { var newAccessory; var uuid; + cosole.log("theFan.light.exists = " + theFan.light.exists); //test var doctoredConfig = { "name" : theFan.name, "fan_name" : theFan.name, "fan_id" : theFan.id, "fan_ip_address" : theFan.address, + "light_exists" : theFan.light.exists, //test "light_on" : platform.config.light_on, "fan_on" : platform.config.fan_on, "homekit_fan_name" : platform.config.homekit_fan_name, @@ -125,6 +127,7 @@ function BigAssFanAccessory(log, config, existingAccessory) { this.fanName = config["fan_name"]; // TODO: Allow this to be null this.fanID = config["fan_id"]; this.fanIPAddress = config["fan_ip_address"]; // Can be null - resorts to broadcasting + this.lightExists = config["light_exists"] //test this.lightOn = config["light_on"]; // Can be null - default is below this.fanOn = config["fan_on"]; // Can be null - default is below this.homekitFanName = config["homekit_fan_name"] @@ -139,6 +142,7 @@ function BigAssFanAccessory(log, config, existingAccessory) { setDefault("fanIPAddress", "255.255.255.255"); setDefault("lightOn", 16); setDefault("fanOn", 3); + setDefault("lightExists", false); //test setDefault("name", this.fanName); setDefault("homekitFanName", this.name + " Fan"); @@ -252,6 +256,7 @@ function BigAssFanAccessory(log, config, existingAccessory) { var fanMaxSpeed = this.myBigAss.fan.max ? this.myBigAss.fan.max : 7; console.log("var this.myBigAss.light.exists = " + this.myBigAss.light.exists ); + console.log("var this.light.exists = " + this.light.exists ); //test if (this.myBigAss.light.exists) { this.log("Found a light for: " + this.homekitLightName); From 13a3b65e06171802226e5cc240555f126bd70b6e Mon Sep 17 00:00:00 2001 From: pponce Date: Sun, 2 Apr 2017 13:03:06 -0700 Subject: [PATCH 12/17] Update index.js --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index b25b856..373f8eb 100644 --- a/index.js +++ b/index.js @@ -70,7 +70,7 @@ BigAssFansPlatform.prototype.addAccessory = function(theFan) { var newAccessory; var uuid; - cosole.log("theFan.light.exists = " + theFan.light.exists); //test + console.log("theFan.light.exists = " + theFan.light.exists); //test var doctoredConfig = { "name" : theFan.name, "fan_name" : theFan.name, From 23c48ec1a0e971c28f2dd2040d2144f6c0c1c5aa Mon Sep 17 00:00:00 2001 From: pponce Date: Sun, 2 Apr 2017 13:05:34 -0700 Subject: [PATCH 13/17] Update index.js --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 373f8eb..ee35f14 100644 --- a/index.js +++ b/index.js @@ -256,8 +256,8 @@ function BigAssFanAccessory(log, config, existingAccessory) { var fanMaxSpeed = this.myBigAss.fan.max ? this.myBigAss.fan.max : 7; console.log("var this.myBigAss.light.exists = " + this.myBigAss.light.exists ); - console.log("var this.light.exists = " + this.light.exists ); //test - if (this.myBigAss.light.exists) { + console.log("var this.lightExists = " + this.lightExists ); //test + if (this.lightExists) { this.log("Found a light for: " + this.homekitLightName); var existingLightBulbService; From 7eaec2e377bd021894e7021a93705e0485c41c13 Mon Sep 17 00:00:00 2001 From: pponce Date: Sun, 2 Apr 2017 14:04:56 -0700 Subject: [PATCH 14/17] Update index.js --- index.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index ee35f14..cb096ea 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ var bigAssApi = require("BigAssFansAPI"); -bigAssApi.logging = true; +bigAssApi.logging = false; var Service, Characteristic; @@ -31,9 +31,6 @@ function BigAssFansPlatform(log, config, api) { this.fanMaster.onFanFullyUpdated = function(myBigAss){ platform.addAccessory(myBigAss); - console.log("Found a new fan with name '" + myBigAss.name + "'"); - console.log("and identifier: '" + myBigAss.id + "'\n"); - console.log("and lightExists: '" + myBigAss.light.exists + "'\n"); } if (api) { @@ -76,7 +73,7 @@ BigAssFansPlatform.prototype.addAccessory = function(theFan) { "fan_name" : theFan.name, "fan_id" : theFan.id, "fan_ip_address" : theFan.address, - "light_exists" : theFan.light.exists, //test + "light_exists" : theFan.light.exists, "light_on" : platform.config.light_on, "fan_on" : platform.config.fan_on, "homekit_fan_name" : platform.config.homekit_fan_name, @@ -127,7 +124,7 @@ function BigAssFanAccessory(log, config, existingAccessory) { this.fanName = config["fan_name"]; // TODO: Allow this to be null this.fanID = config["fan_id"]; this.fanIPAddress = config["fan_ip_address"]; // Can be null - resorts to broadcasting - this.lightExists = config["light_exists"] //test + this.lightExists = config["light_exists"] // Can be null - default is below this.lightOn = config["light_on"]; // Can be null - default is below this.fanOn = config["fan_on"]; // Can be null - default is below this.homekitFanName = config["homekit_fan_name"] @@ -142,7 +139,7 @@ function BigAssFanAccessory(log, config, existingAccessory) { setDefault("fanIPAddress", "255.255.255.255"); setDefault("lightOn", 16); setDefault("fanOn", 3); - setDefault("lightExists", false); //test + setDefault("lightExists", false); setDefault("name", this.fanName); setDefault("homekitFanName", this.name + " Fan"); @@ -255,8 +252,6 @@ function BigAssFanAccessory(log, config, existingAccessory) { var lightMaxBrightness = this.myBigAss.light.max ? this.myBigAss.light.max : 16; var fanMaxSpeed = this.myBigAss.fan.max ? this.myBigAss.fan.max : 7; - console.log("var this.myBigAss.light.exists = " + this.myBigAss.light.exists ); - console.log("var this.lightExists = " + this.lightExists ); //test if (this.lightExists) { this.log("Found a light for: " + this.homekitLightName); From dc545055889597143a72b293f1a469f0f7169a93 Mon Sep 17 00:00:00 2001 From: pponce Date: Sun, 2 Apr 2017 14:06:24 -0700 Subject: [PATCH 15/17] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 857b228..9586bfa 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "homebridge": ">=0.2.0" }, "dependencies": { - "BigAssFansAPI": "git://github.com/pponce/BigAssFansAPI#master" + "BigAssFansAPI": ">=1.1.1" }, "homepage": "https://github.com/sean9keenan/homebridge-bigAssFans" } From 02654ff4dbc748b2abcee7d91051ea224ba32cd4 Mon Sep 17 00:00:00 2001 From: pponce Date: Sun, 2 Apr 2017 14:11:37 -0700 Subject: [PATCH 16/17] Update index.js --- index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/index.js b/index.js index cb096ea..1971ba7 100644 --- a/index.js +++ b/index.js @@ -67,7 +67,6 @@ BigAssFansPlatform.prototype.addAccessory = function(theFan) { var newAccessory; var uuid; - console.log("theFan.light.exists = " + theFan.light.exists); //test var doctoredConfig = { "name" : theFan.name, "fan_name" : theFan.name, From 861ef088471555e3e77551849a294a8f37bd91a3 Mon Sep 17 00:00:00 2001 From: pponce Date: Mon, 17 Apr 2017 13:09:56 -0700 Subject: [PATCH 17/17] added legacy light_exists configuration variable --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ea0862c..e72529a 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ You must also set the fan_name to the name returned here. | fan_name | _*Required*_ | Must get this from `getFanInfo.js` | | fan_id | _*Required*_ | Must get this from `getFanInfo.js` | | fan_ip_address | Optional | IP address of fan, defaults to broadcast | +| light_exists | Optional | Has light? set to true - default false | | light_on | Optional | What "On" means - default Max | | fan_on | Optional | What "On" means - default 3/7 | | homekit_fan_name | Optional | Name to call the Fan in Homekit |