Skip to content

Commit

Permalink
Merge pull request #17 from plhyhc/fix/duplicate-notifications
Browse files Browse the repository at this point in the history
fix duplicate iOS notificaitons
  • Loading branch information
plhyhc authored Oct 24, 2023
2 parents c9e22f2 + 0212b0b commit 4705e45
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
10 changes: 2 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ GarageDoorOpener.prototype.checkSensor = function (callback) {

GarageDoorOpener.prototype.readSensorState = function () {
var val = this.gpioSensorVal(rpio.read(this.doorSensorPin));
return val == rpio.HIGH ? CurrentDoorState.CLOSED : CurrentDoorState.OPEN;
return val == rpio.HIGH ? 1 : 0; // closed / opened
}

GarageDoorOpener.prototype.setState = function (val) {
Expand All @@ -83,13 +83,7 @@ GarageDoorOpener.prototype.setDoorState = function (newState, callback) {
callback(null);
return;
}
if (newState == TargetDoorState.CLOSED) {
this.service.getCharacteristic(TargetDoorState).updateValue(TargetDoorState.OPEN);
this.service.getCharacteristic(CurrentDoorState).updateValue(CurrentDoorState.OPENING);
} else if (newState == TargetDoorState.OPEN) {
this.service.getCharacteristic(TargetDoorState).updateValue(TargetDoorState.CLOSED);
this.service.getCharacteristic(CurrentDoorState).updateValue(CurrentDoorState.CLOSING);
}

if (this.timerid !== -1) {
clearTimeout(this.timerid);
this.timerid = -1;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@
"type": "git",
"url": "git+https://github.com/plhyhc/homebridge-garage-door-wsensor.git"
},
"version": "2.0.8"
"version": "2.0.9"
}

0 comments on commit 4705e45

Please sign in to comment.