diff --git a/lib/addins/GarageDoorOpenerAdvanced.js b/lib/addins/GarageDoorOpenerAdvanced.js index e85e874..71d59f7 100644 --- a/lib/addins/GarageDoorOpenerAdvanced.js +++ b/lib/addins/GarageDoorOpenerAdvanced.js @@ -15,9 +15,6 @@ * "sensorOn"-keyword in knx_config.json (both need to operate the same way). * */ - -/* jshint esversion: 6, strict: true, node: true */ - 'use strict'; /** * @type {HandlerPattern} */ @@ -103,7 +100,7 @@ class GarageDoorOpenerAdvanced extends HandlerPattern { // - open - if the "open"-contact is present // - closed - if the "closed"-contact is present // - both - if both ontacts are present - no simulation in this case - this.doorContactPresent = this.myAPI.getLocalConstant("doorContactPresent"); + this.doorContactPresent = this.myAPI.getLocalConstant("doorContactPresent");; // Door run-time this.doorRunTime = this.myAPI.getLocalConstant("doorRunTime"); // in mil.seconds @@ -145,12 +142,10 @@ class GarageDoorOpenerAdvanced extends HandlerPattern { if (field === "KNXPulseMove") { if (knxValue === 1) { - var curDate = new Date(); - var percentageRun; + if (oldValue !== 1){ // value changed? console.log('INFO ' + this.debugName + ': KNXPulseMove detected'); - if (this.timer1 !== undefined){ clearTimeout(this.timer1); this.timer1 = undefined; @@ -230,7 +225,8 @@ class GarageDoorOpenerAdvanced extends HandlerPattern { this.myAPI.setValue("CurrentDoorState", 4); // STOPPED // calculate percentageOpen - + var curDate = new Date(); + var percentageRun = undefined; percentageRun = (curDate.getTime() - this.dateRunStart.getTime()) / this.doorRunTime; console.log('INFO ' + this.debugName + ': percentageRun = ' + percentageRun); @@ -266,7 +262,9 @@ class GarageDoorOpenerAdvanced extends HandlerPattern { this.myAPI.setValue("CurrentDoorState", 4); // STOPPED // calculate percentageOpen - + var curDate = new Date(); + var percentageRun = undefined; + percentageRun = (curDate.getTime() - this.dateRunStart.getTime()) / this.doorRunTime; console.log('INFO ' + this.debugName + ': percentageRun = ' + percentageRun); console.log('INFO ' + this.debugName + ': percentageOpen before = ' + this.percentageOpen); @@ -349,7 +347,7 @@ class GarageDoorOpenerAdvanced extends HandlerPattern { } // simulateDoorContactMode } - else if (this.lastMove === "goingDown"){ + else { // if (this.lastMove === "goingDown"){ console.log('INFO ' + this.debugName + ': TargetDoorState = 1 OPEN set'); this.myAPI.setValue("TargetDoorState", 0); // OPEN @@ -733,7 +731,7 @@ class GarageDoorOpenerAdvanced extends HandlerPattern { console.log('INFO ' + this.debugName + ': KNXDoorClosed = timer running detected'); } - } else if (oldValue === null) { // Init run + } else { // if (oldValue === null) { // Init run console.log('INFO ' + this.debugName + ': Init Garage Door HK Status KNXDoorClosed = false'); @@ -757,10 +755,6 @@ class GarageDoorOpenerAdvanced extends HandlerPattern { } // KNXDoorClosed -// TODO: Door is open, gets closed automatically by someone going through -// -> TargetDoorState needs to be set. - - if (field==="KNXDoorOpened") { console.log('INFO ' + this.debugName + ': In if-case -> field===KNXDoorOpened'); @@ -861,7 +855,7 @@ class GarageDoorOpenerAdvanced extends HandlerPattern { console.log('INFO ' + this.debugName + ': KNXDoorOpened = timer running detected'); } - } else if (oldValue === null) { // Init run + } else { // if (oldValue === null) { // Init run console.log('INFO ' + this.debugName + ': Init Garage Door HK Status KNXDoorOpened = false'); @@ -908,7 +902,7 @@ class GarageDoorOpenerAdvanced extends HandlerPattern { // - open - if the "open"-contact is present // - closed - if the "closed"-contact is present // - both - if both ontacts are present - no simulation in this case - this.doorContactPresent = this.myAPI.getLocalConstant("doorContactPresent"); + this.doorContactPresent = this.myAPI.getLocalConstant("doorContactPresent");; // Door run-time this.doorRunTime = this.myAPI.getLocalConstant("doorRunTime"); // in mil.seconds