Skip to content

Commit

Permalink
Merge pull request #30 from justjam2013/fix-garage-door-state
Browse files Browse the repository at this point in the history
Fix garage door state update
  • Loading branch information
justjam2013 authored Nov 23, 2024
2 parents fcbd6e8 + 7ed9687 commit 26af1f3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "homebridge-virtual-accessories",
"displayName": "Virtual Accessories for Homebridge",
"type": "module",
"version": "1.0.4",
"version": "1.0.5",
"description": "Virtual accessories for Homebridge.",
"author": "justjam2013",
"license": "Apache-2.0",
Expand Down
16 changes: 15 additions & 1 deletion src/accessories/virtualAccessoryGarageDoor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,21 @@ export class GarageDoor extends Accessory {
this.saveState(this.storagePath, this.stateStorageKey, this.states.GarageDoorState);
}

this.platform.log.info(`[${this.accessoryConfiguration.accessoryName}] Setting Target Door State: ${this.getStateName(this.states.GarageDoorState)}`);
// eslint-disable-next-line max-len
this.platform.log.info(`[${this.accessoryConfiguration.accessoryName}] Setting Target Garage Door State: ${this.getStateName(this.states.GarageDoorState)}`);

// CurrentDoorState CLOSING/OPENING
const transition: number = (this.states.GarageDoorState === GarageDoor.OPEN) ? GarageDoor.OPENING : GarageDoor.CLOSING;
this.service!.setCharacteristic(this.platform.Characteristic.CurrentDoorState, (transition));
this.platform.log.info(`[${this.accessoryConfiguration.accessoryName}] Setting Curent Garage Door State: ${this.getStateName(transition)}`);

// CurrentDoorState CLOSED/OPEN with 3 second delay
const transitionDelayMillis: number = 3 * 1000;
setTimeout(() => {
this.service!.setCharacteristic(this.platform.Characteristic.CurrentDoorState, (this.states.GarageDoorState));
// eslint-disable-next-line max-len
this.platform.log.info(`[${this.accessoryConfiguration.accessoryName}] Setting Current Garage Door State: ${this.getStateName(this.states.GarageDoorState)}`);
}, transitionDelayMillis);
}

/**
Expand Down

0 comments on commit 26af1f3

Please sign in to comment.