diff --git a/accessories/LiftMaster.js b/accessories/LiftMaster.js index 2b20448..8b6b33f 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 = { @@ -82,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 open."); + 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); @@ -145,6 +187,7 @@ LiftMasterAccessory.prototype = { that.log("State was successfully set."); else that.log("Bad return code: " + json["ReturnCode"]); + that.log("Raw response " + JSON.stringify(json)); } else { that.log("Error '"+err+"' setting door state: " + JSON.stringify(json)); diff --git a/config-sample.json b/config-sample.json index 639ccb1..d9ae5ef 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" },