Skip to content

Commit

Permalink
allow info logs to be pushed
Browse files Browse the repository at this point in the history
  • Loading branch information
donavanbecker committed Sep 30, 2024
1 parent 9dac9af commit 174f562
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
8 changes: 4 additions & 4 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 @@ -81,7 +81,7 @@
"async-mqtt": "^2.6.3",
"fakegato-history": "^0.6.5",
"homebridge-lib": "^7.0.8",
"node-switchbot": "2.5.0-beta.21",
"node-switchbot": "2.5.0-beta.22",
"rxjs": "^7.8.1"
},
"devDependencies": {
Expand Down
17 changes: 14 additions & 3 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,19 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
this.switchBotAPI = new SwitchBotOpenAPI(this.config.credentials?.token, this.config.credentials?.secret)
// Listen for log events
this.switchBotAPI.on('log', (log) => {
this.debugLog(`[${log.level.toUpperCase()}] ${log.message}`)
switch (log.level) {
case LogLevel.ERROR:
this.errorLog(`[${log.level.toUpperCase()}] ${log.message}`)
break
case LogLevel.WARN:
this.warnLog(`[${log.level.toUpperCase()}] ${log.message}`)
break
case LogLevel.DEBUG:
this.debugLog(`[${log.level.toUpperCase()}] ${log.message}`)
break
default:
this.infoLog(`[${log.level.toUpperCase()}] ${log.message}`)
}
})
// import fakegato-history module and EVE characteristics
this.fakegatoAPI = fakegato(api)
Expand Down Expand Up @@ -462,9 +474,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {

while (retryCount < maxRetries) {
try {
const { body, statusCode } = await this.switchBotAPI.getDevices()
const { devicesAPI, statusCode } = await this.switchBotAPI.getDevices()
await this.debugWarnLog(`statusCode: ${statusCode}`)
const devicesAPI: any = await body.json()
await this.debugWarnLog(`devicesAPI: ${JSON.stringify(devicesAPI)}`)

if (this.isSuccessfulResponse(statusCode, devicesAPI.statusCode)) {
Expand Down

0 comments on commit 174f562

Please sign in to comment.