From 9dac9af69028551977ea6edd2d67f96e9749555d Mon Sep 17 00:00:00 2001 From: Donavan Becker Date: Sun, 29 Sep 2024 21:42:45 -0500 Subject: [PATCH] listen for logs emitted --- package-lock.json | 22 ++++------------------ package.json | 2 +- src/platform.ts | 6 ++++-- 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/package-lock.json b/package-lock.json index 704c3cf2..b489d411 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.19", + "node-switchbot": "2.5.0-beta.21", "rxjs": "^7.8.1" }, "devDependencies": { @@ -10465,19 +10465,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/loglevel": { - "version": "1.9.2", - "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.9.2.tgz", - "integrity": "sha512-HgMmCqIJSAKqo68l0rS2AanEWfkxaZ5wNiEFb5ggm08lDs9Xl2KxBlX3PTcaD2chBM1gXAYf491/M2Rv8Jwayg==", - "license": "MIT", - "engines": { - "node": ">= 0.6.0" - }, - "funding": { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/loglevel" - } - }, "node_modules/long-timeout": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/long-timeout/-/long-timeout-0.1.1.tgz", @@ -11969,15 +11956,14 @@ } }, "node_modules/node-switchbot": { - "version": "2.5.0-beta.19", - "resolved": "https://registry.npmjs.org/node-switchbot/-/node-switchbot-2.5.0-beta.19.tgz", - "integrity": "sha512-bXSUv3YAtEzuetdX2MM623kKhQ+9DDl7cKue/lmMn1DyzX8whAXu4arG+B/xZBu2INQ68rKnAz0wPqbEpracwA==", + "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==", "license": "MIT", "dependencies": { "@stoprocent/noble": "^1.15.0", "@types/sinon": "^17.0.3", "async-mutex": "^0.5.0", - "loglevel": "^1.9.2", "sinon": "^19.0.2", "undici": "^6.19.8" }, diff --git a/package.json b/package.json index 7a88a9d3..ae86ea90 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.19", + "node-switchbot": "2.5.0-beta.21", "rxjs": "^7.8.1" }, "devDependencies": { diff --git a/src/platform.ts b/src/platform.ts index 09f89659..d66c9146 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -129,8 +129,10 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { // SwitchBot OpenAPI this.switchBotAPI = new SwitchBotOpenAPI(this.config.credentials?.token, this.config.credentials?.secret) - // Set the log level - this.switchBotAPI.setLogLevel(LogLevel.DEBUG) + // Listen for log events + this.switchBotAPI.on('log', (log) => { + this.debugLog(`[${log.level.toUpperCase()}] ${log.message}`) + }) // import fakegato-history module and EVE characteristics this.fakegatoAPI = fakegato(api) this.eve = new EveHomeKitTypes(api)