From a3e34088b98722e132d628d12d703aedefec892e Mon Sep 17 00:00:00 2001 From: Alistair Galbraith Date: Wed, 1 Jul 2015 12:47:50 -0700 Subject: [PATCH] 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" },