Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
fix: resolve Homebridge warnings in log
Browse files Browse the repository at this point in the history
  • Loading branch information
sman591 committed Apr 20, 2021
1 parent ef45d82 commit 03c7a0b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
13 changes: 2 additions & 11 deletions src/characteristic/abstractCharacteristic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ export default abstract class AbstractCharacteristic<
this.apiCommand = apiCommand
this.apiDataKey = apiDataKey

this.service
.getCharacteristic(this.characteristic)
.on(CharacteristicEventTypes.GET, this.handleGet.bind(this))

if (this.handleSet) {
// read-only characteristics won't have a handleSet
this.service
Expand Down Expand Up @@ -96,7 +92,7 @@ export default abstract class AbstractCharacteristic<
// The air conditioner will make a sound every time this API is called.
// To avoid unnecessary chimes, we'll optimistically skip sending the API call.
this.logDebug('State equals cached state. Skipping.', targetState)
callback(null, targetState)
callback(null)
return
}

Expand All @@ -106,19 +102,14 @@ export default abstract class AbstractCharacteristic<
.sendCommand(this.deviceId, this.apiCommand, this.apiDataKey, apiValue)
.then(() => {
this.cachedState = targetState
callback(null, targetState)
callback(null)
})
.catch((error) => {
this.logError('Failed to set state', targetState, error.toString())
callback(error)
})
}

/** Handle a "get" command from Homebridge */
handleGet(callback: CharacteristicGetCallback) {
callback(null, this.cachedState)
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
logError(message: string, ...parameters: any[]) {
this.platform.log.error(
Expand Down
2 changes: 1 addition & 1 deletion src/platformAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class LgAirConditionerPlatformAccessory {
this.platform.log,
)

// // create handlers for required characteristics
// create handlers for required characteristics
this.updateCharacteristics()
const refreshInterval = this.platform.getRefreshIntervalMinutes()
this.platform.log.info(
Expand Down

0 comments on commit 03c7a0b

Please sign in to comment.