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.
This commit is contained in:
Alistair Galbraith
2015-06-30 19:19:29 -07:00
parent 94619e40d5
commit 466ace2761

View File

@@ -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<devices.length; i++) {
var device = devices[i];
if (device["MyQDeviceTypeName"] == "GarageDoorOpener") {
if ((device["MyQDeviceTypeName"] == "GarageDoorOpener") && (that.requiredDeviceId == device.MyQDeviceId)) {
that.deviceId = device.MyQDeviceId;
break;
}
}
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();
}
}
@@ -145,6 +146,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));