Skip to content

Commit

Permalink
stop timer if position is reached (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbyquaker committed Mar 14, 2019
1 parent b086151 commit 6101ab3
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions nodes/redmatic-homekit-homematic-garage.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,13 @@ module.exports = function (RED) {
case 'o': {
this.debug('updateSensor opened=' + this.opened + ' lastMove=' + this.lastMove);
if (this.moving) {
valueCurrent = this.opened ? 0 : this.moving;
if (this.opened) {
valueCurrent = 0;
clearTimeout(this.timer);
this.moving = false;
} else {
valueCurrent = this.moving;
}
} else if (timeout && this.lastMove === 2) {
if (this.opened) {
valueCurrent = 0;
Expand All @@ -135,7 +141,13 @@ module.exports = function (RED) {
case 'c': {
this.debug('updateSensor closed=' + this.closed + ' lastMove=' + this.lastMove);
if (this.moving) {
valueCurrent = this.closed ? 1 : this.moving;
if (this.closed) {
valueCurrent = 1;
clearTimeout(this.timer);
this.moving = false;
} else {
valueCurrent = this.moving;
}
} else if (timeout && this.lastMove === 3) {
if (this.closed) {
valueCurrent = 1;
Expand All @@ -158,8 +170,12 @@ module.exports = function (RED) {
this.debug('updateSensor opened=' + this.opened + ' closed=' + this.closed + ' lastMove=' + this.lastMove);
if (this.opened && !this.closed) {
valueCurrent = 0;
clearTimeout(this.timer);
this.moving = false;
} else if (this.closed && !this.opened) {
valueCurrent = 1;
clearTimeout(this.timer);
this.moving = false;
} else if (this.moving) {
valueCurrent = this.moving;
} else if (timeout) {
Expand Down

0 comments on commit 6101ab3

Please sign in to comment.