From 466ace27617c4c95bfa09231e0d92ede65f52e8c Mon Sep 17 00:00:00 2001 From: Alistair Galbraith Date: Tue, 30 Jun 2015 19:19:29 -0700 Subject: [PATCH 1/3] Added ability to specify a specific Liftmaster door Current version operates the "first door found". For users with multiple doors, this allows them to specify a specific door with the 'requiredDeviceId' option in config. --- accessories/LiftMaster.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/accessories/LiftMaster.js b/accessories/LiftMaster.js index 2b20448..8690a0e 100644 --- a/accessories/LiftMaster.js +++ b/accessories/LiftMaster.js @@ -9,6 +9,7 @@ function LiftMasterAccessory(log, config) { this.name = config["name"]; this.username = config["username"]; this.password = config["password"]; + this.requiredDeviceId = config["requiredDeviceId"]; } LiftMasterAccessory.prototype = { @@ -86,14 +87,14 @@ LiftMasterAccessory.prototype = { // look through the array of devices for an opener for (var i=0; i Date: Tue, 30 Jun 2015 19:42:07 -0700 Subject: [PATCH 2/3] Fixed bug where Liftmaster door ID may not be defined --- accessories/LiftMaster.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accessories/LiftMaster.js b/accessories/LiftMaster.js index 8690a0e..8d15c38 100644 --- a/accessories/LiftMaster.js +++ b/accessories/LiftMaster.js @@ -87,7 +87,7 @@ LiftMasterAccessory.prototype = { // look through the array of devices for an opener for (var i=0; i Date: Wed, 1 Jul 2015 12:47:50 -0700 Subject: [PATCH 3/3] A MyQ account with multiple opener devices will trigger a fatal exception, after dumping out possible doors and their names Also updated config-sample.json with additional option, and comments --- accessories/LiftMaster.js | 47 ++++++++++++++++++++++++++++++++++++--- config-sample.json | 1 + 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/accessories/LiftMaster.js b/accessories/LiftMaster.js index 8d15c38..8b6b33f 100644 --- a/accessories/LiftMaster.js +++ b/accessories/LiftMaster.js @@ -83,20 +83,61 @@ LiftMasterAccessory.prototype = { // parse and interpret the response var json = JSON.parse(body); var devices = json["Devices"]; + var foundDoors = []; // look through the array of devices for an opener for (var i=0; i 1) { + that.log("WARNING: You have multiple doors on your MyQ account."); + that.log("WARNING: Specify the ID of the door you want to control using the 'requiredDeviceId' property in your config.json file."); + that.log("WARNING: You can have multiple liftmaster accessories to cover your multiple doors"); + + for (var j = 0; j < foundDoors.length; j++) { + that.log("Found Door: " + foundDoors[j]); + } + + throw "FATAL: Please specify which specific door this Liftmaster accessory should control - you have multiples on your account"; + + } + + // Did we get a device ID? if (that.deviceId) { that.log("Found an opener with ID " + that.deviceId +". Ready to send command..."); that.setTargetState(); } + else + { + that.log("Error: Couldn't find a door device, or the ID you specified isn't associated with your account"); + } } else { that.log("Error '"+err+"' getting devices: " + body); diff --git a/config-sample.json b/config-sample.json index e8e4b96..768a1d1 100644 --- a/config-sample.json +++ b/config-sample.json @@ -48,6 +48,7 @@ "accessory": "LiftMaster", "name": "Garage Door", "description": "This shim supports LiftMaster garage door openers that are already internet-connected to the 'MyQ' service.", + // "requiredDeviceId", "", "username": "your-liftmaster-username", "password" : "your-liftmaster-password" },