Skip to content

Commit 8814a6c

Browse files
update LockTargetState to match LockCurrentState during lock refresh (#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]>
1 parent 1506565 commit 8814a6c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/devices/lock.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,14 @@ export class LockMechanism extends deviceBase {
192192
: this.lockStatus.state.unlocked
193193
? this.hap.Characteristic.LockCurrentState.UNSECURED
194194
: retryCount > 1 ? this.hap.Characteristic.LockCurrentState.JAMMED : this.hap.Characteristic.LockCurrentState.UNKNOWN
195+
this.LockMechanism.LockTargetState = this.LockMechanism.LockCurrentState
196+
195197
if (this.LockMechanism.LockCurrentState === this.hap.Characteristic.LockCurrentState.UNKNOWN) {
196198
await this.warnLog(`LockCurrentState: ${this.LockMechanism.LockCurrentState}, (UNKNOWN) parseStatus`
197199
+ ` lockEvent: ${JSON.stringify(this.lockEvent)}`)
198200
}
199201
await this.debugLog(`LockCurrentState: ${this.LockMechanism.LockCurrentState}`)
202+
await this.debugLog(`LockTargetState: ${this.LockMechanism.LockTargetState}`)
200203
}
201204
// Contact Sensor
202205
if (!this.device.lock?.hide_contactsensor && this.ContactSensor?.Service) {
@@ -261,11 +264,14 @@ export class LockMechanism extends deviceBase {
261264
: this.lockEvent.state.unlocked
262265
? this.hap.Characteristic.LockCurrentState.UNSECURED
263266
: retryCount > 1 ? this.hap.Characteristic.LockCurrentState.JAMMED : this.hap.Characteristic.LockCurrentState.UNKNOWN
267+
this.LockMechanism.LockTargetState = this.LockMechanism.LockCurrentState
268+
264269
if (this.LockMechanism.LockCurrentState === this.hap.Characteristic.LockCurrentState.UNKNOWN) {
265270
await this.warnLog(`LockCurrentState: ${this.LockMechanism.LockCurrentState}, (UNKNOWN) parseEventStatus`
266271
+ ` lockEvent: ${JSON.stringify(this.lockEvent)}`)
267272
}
268273
await this.debugLog(`LockCurrentState: ${this.LockMechanism.LockCurrentState}`)
274+
await this.debugLog(`LockTargetState: ${this.LockMechanism.LockTargetState}`)
269275
}
270276
// Contact Sensor
271277
if (!this.device.lock?.hide_contactsensor && this.ContactSensor?.Service) {

0 commit comments

Comments
 (0)