diff --git a/index.js b/index.js index 464c79d..820f831 100644 --- a/index.js +++ b/index.js @@ -404,18 +404,14 @@ BlindsHTTPAccessory.prototype.replaceUrlPosition = function (url, pos) { }; BlindsHTTPAccessory.prototype.setTargetPosition = function (pos, callback) { - if (this.stopTimeout !== null) { - clearTimeout(this.stopTimeout); - this.stopTimeout = null; - } - if (this.stepInterval !== null) { - clearInterval(this.stepInterval); - this.stepInterval = null; - } - if (this.lagTimeout !== null) { - clearTimeout(this.lagTimeout); - this.lagTimeout = null; - } + clearTimeout(this.stopTimeout); + this.stopTimeout = null; + + clearInterval(this.stepInterval); + this.stepInterval = null; + + clearTimeout(this.lagTimeout); + this.lagTimeout = null; this.manualStop = false; this.currentTargetPosition = pos; @@ -573,6 +569,8 @@ BlindsHTTPAccessory.prototype.setTargetPosition = function (pos, callback) { BlindsHTTPAccessory.prototype.endMoveRequest = function (moveMessage) { clearInterval(this.stepInterval); this.stepInterval = null; + clearTimeout(this.lagTimeout); + this.lagTimeout = null; this.log.info(`End ${moveMessage} to ${this.lastPosition}% (target ${this.currentTargetPosition}%)`); @@ -588,12 +586,11 @@ BlindsHTTPAccessory.prototype.endMoveRequest = function (moveMessage) { BlindsHTTPAccessory.prototype.sendStopRequest = function (targetService, on, callback) { if (on) { + clearTimeout(this.stopTimeout); + this.stopTimeout = null; + if (targetService) { this.log.info('Requesting manual stop'); - if (this.stopTimeout !== null) { - clearTimeout(this.stopTimeout); - this.stopTimeout = null; - } } else { this.log.info('Requesting stop'); } diff --git a/package.json b/package.json index 1c4213b..27caa4b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homebridge-blinds", - "version": "1.3.25-beta.2", + "version": "1.3.25-beta.3", "description": "A homebridge plugin to control my blinds", "main": "index.js", "scripts": {