Skip to content

Commit

Permalink
Garage Door Opener - If the autoCloseDelay is set to 0, set the H…
Browse files Browse the repository at this point in the history
…omekit state to closed immediately (#479)
  • Loading branch information
Luke Rhodes committed Jan 1, 2020
1 parent bdb1938 commit 9382a7a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions accessories/garageDoorOpener.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,19 @@ class GarageDoorOpenerAccessory extends BroadlinkRMAccessory {
log(`${name} setDoorCurrentState: opened`);
serviceManager.setCharacteristic(Characteristic.CurrentDoorState, Characteristic.CurrentDoorState.OPEN);

// If the autoCloseDelay is set to 0, set the state to closed immediately.
if (autoCloseDelay === 0) {
serviceManager.setCharacteristic(Characteristic.TargetDoorState, Characteristic.TargetDoorState.CLOSED);
}

if (!autoCloseDelay) return;

log(`${name} automatically closing in ${autoCloseDelay}s`);
this.autoCloseTimeoutPromise = delayForDuration(autoCloseDelay);
await this.autoCloseTimeoutPromise;

serviceManager.setCharacteristic(Characteristic.TargetDoorState, Characteristic.TargetDoorState.CLOSED);

this.close()
}

Expand Down

0 comments on commit 9382a7a

Please sign in to comment.