diff --git a/package-lock.json b/package-lock.json index b489d411..8b58ea19 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,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": { @@ -11956,9 +11956,9 @@ } }, "node_modules/node-switchbot": { - "version": "2.5.0-beta.21", - "resolved": "https://registry.npmjs.org/node-switchbot/-/node-switchbot-2.5.0-beta.21.tgz", - "integrity": "sha512-PiMsQA2/rXgdtbNWeHtZSH+heGuD7ovU1y1k8ciM3lAI2smZ9oXunv4B16VdKQP4TSHup97yMAtjB+I6zo+oSw==", + "version": "2.5.0-beta.22", + "resolved": "https://registry.npmjs.org/node-switchbot/-/node-switchbot-2.5.0-beta.22.tgz", + "integrity": "sha512-rEdNvBdGpY5JwZGUxA060gJUHqph4+U9SG+sL+SSY6KVoy9EMGk78rewIyQDDd3szMenRlog4gNqgJPHt7v2bA==", "license": "MIT", "dependencies": { "@stoprocent/noble": "^1.15.0", diff --git a/package.json b/package.json index ae86ea90..5ca81e46 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/platform.ts b/src/platform.ts index d66c9146..f61566bd 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -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) @@ -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)) {