Skip to content

Commit

Permalink
enhance
Browse files Browse the repository at this point in the history
  • Loading branch information
donavanbecker committed Aug 1, 2024
1 parent b360c40 commit 767539d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions src/devices/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ export abstract class deviceBase {
* @param CharacteristicValue - The new value to set for the characteristic. If undefined, the function logs the value and returns without updating.
* @param CharacteristicName - The name of the characteristic being updated, used for logging purposes.
* @param Value - The value to compare against to determine the status.
* @param Status1 - The status message to log if the characteristic value matches the provided value.
* @param Status2 - The status message to log if the characteristic value does not match the provided value.
* @param StatusMatch - The status message to log if the characteristic value matches the provided value.
* @param StatusDoesNotMatch - The status message to log if the characteristic value does not match the provided value.
* @return void
*/
async updateCharacteristic(
Expand All @@ -135,20 +135,20 @@ export abstract class deviceBase {
CharacteristicValue: CharacteristicValue,
CharacteristicName: string,
Value?: CharacteristicValue,
Status1?: string,
Status2?: string,
StatusMatch?: string,
StatusDoesNotMatch?: string,
): Promise<void> {
if (CharacteristicValue === undefined) {
this.debugLog(`${CharacteristicName}: ${CharacteristicValue}`);
await this.debugLog(`${CharacteristicName}: ${CharacteristicValue}`);
} else {
Service.updateCharacteristic(Characteristic, CharacteristicValue);
this.debugLog(`updateCharacteristic ${CharacteristicName}: ${CharacteristicValue}`);
this.debugWarnLog(`context before: ${this.accessory.context[ServiceName[CharacteristicName]]}`);
if ((this.accessory.context[ServiceName[CharacteristicName]] !== CharacteristicValue) && (Status1 !== undefined) && (Status2 !== undefined)) {
await this.infoLog(`was ${CharacteristicValue === Value ? Status1 : Status2}`);
await this.debugLog(`updateCharacteristic ${CharacteristicName}: ${CharacteristicValue}`);
await this.debugWarnLog(`context before: ${this.accessory.context[ServiceName[CharacteristicName]]}`);
if (StatusMatch && StatusDoesNotMatch) {
await this.infoLog(`was ${CharacteristicName}: ${CharacteristicValue === Value ? StatusMatch : StatusDoesNotMatch}`);
}
this.accessory.context[ServiceName[CharacteristicName]] = CharacteristicValue;
this.debugWarnLog(`context after: ${this.accessory.context[ServiceName[CharacteristicName]]}`);
await this.debugWarnLog(`context after: ${this.accessory.context[ServiceName[CharacteristicName]]}`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/devices/lock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ export class LockMechanism extends deviceBase {
this.LockMechanism.LockTargetState, 'LockTargetState', 1, 'Locked', 'Unlocked');
// LockCurrentState
await this.updateCharacteristic(this.LockMechanism.Service, 'LockMechanism', this.hap.Characteristic.LockCurrentState,
this.LockMechanism.LockCurrentState, 'LockCurrentState');
this.LockMechanism.LockCurrentState, 'LockCurrentState', 1, 'Locked', 'Unlocked');
}
// Battery
// BatteryLevel
Expand Down

0 comments on commit 767539d

Please sign in to comment.