Skip to content

Commit

Permalink
update LockTargetState to match LockCurrentState during lock refresh (#…
Browse files Browse the repository at this point in the history
…144)

## ♻️ Current situation

The LockTargetState attribute is not updated while polling/listening to
events from the August API. This leads to any manual changes of the lock
(ie I physically lock/unlock it) to cause the lock status to always show
unlocking or locking in Homekit.

## 💡 Proposed solution

Update the LockTargetState attribute to be the same value as the
LockCurrentState during both polling or pushed events. This plugin used
to operate with this logic around the 2.0.0 version and prior but
somewhere after 2.0.0 this logic was changed.

## ⚙️ Release Notes

LockTargetState is updated for manual lock events

## ➕ Additional Information


### Testing


### Reviewer Nudging

Co-authored-by: Donavan Becker <[email protected]>
  • Loading branch information
ryanpesek and donavanbecker committed Jan 23, 2025
1 parent 1506565 commit 8814a6c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/devices/lock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,14 @@ export class LockMechanism extends deviceBase {
: this.lockStatus.state.unlocked
? this.hap.Characteristic.LockCurrentState.UNSECURED
: retryCount > 1 ? this.hap.Characteristic.LockCurrentState.JAMMED : this.hap.Characteristic.LockCurrentState.UNKNOWN
this.LockMechanism.LockTargetState = this.LockMechanism.LockCurrentState

if (this.LockMechanism.LockCurrentState === this.hap.Characteristic.LockCurrentState.UNKNOWN) {
await this.warnLog(`LockCurrentState: ${this.LockMechanism.LockCurrentState}, (UNKNOWN) parseStatus`
+ ` lockEvent: ${JSON.stringify(this.lockEvent)}`)
}
await this.debugLog(`LockCurrentState: ${this.LockMechanism.LockCurrentState}`)
await this.debugLog(`LockTargetState: ${this.LockMechanism.LockTargetState}`)
}
// Contact Sensor
if (!this.device.lock?.hide_contactsensor && this.ContactSensor?.Service) {
Expand Down Expand Up @@ -261,11 +264,14 @@ export class LockMechanism extends deviceBase {
: this.lockEvent.state.unlocked
? this.hap.Characteristic.LockCurrentState.UNSECURED
: retryCount > 1 ? this.hap.Characteristic.LockCurrentState.JAMMED : this.hap.Characteristic.LockCurrentState.UNKNOWN
this.LockMechanism.LockTargetState = this.LockMechanism.LockCurrentState

if (this.LockMechanism.LockCurrentState === this.hap.Characteristic.LockCurrentState.UNKNOWN) {
await this.warnLog(`LockCurrentState: ${this.LockMechanism.LockCurrentState}, (UNKNOWN) parseEventStatus`
+ ` lockEvent: ${JSON.stringify(this.lockEvent)}`)
}
await this.debugLog(`LockCurrentState: ${this.LockMechanism.LockCurrentState}`)
await this.debugLog(`LockTargetState: ${this.LockMechanism.LockTargetState}`)
}
// Contact Sensor
if (!this.device.lock?.hide_contactsensor && this.ContactSensor?.Service) {
Expand Down

0 comments on commit 8814a6c

Please sign in to comment.