@switchbot/homebridge-switchbot 3.6.1-beta.15 → 3.6.1-beta.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "SwitchBot",
3
3
  "name": "@switchbot/homebridge-switchbot",
4
- "version": "3.6.1-beta.15",
4
+ "version": "3.6.1-beta.17",
5
5
  "description": "The SwitchBot plugin allows you to access your SwitchBot device(s) from HomeKit.",
6
6
  "author": {
7
7
  "name": "SwitchBot",
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "engineStrict": true,
28
28
  "engines": {
29
- "homebridge": "^1.8.4-beta.21",
29
+ "homebridge": "^1.8.3 || ^2.0.0",
30
30
  "node": "^18 || ^20 || ^22"
31
31
  },
32
32
  "main": "dist/index.js",
@@ -85,22 +85,22 @@
85
85
  "undici": "^6.19.2"
86
86
  },
87
87
  "optionalDependencies": {
88
- "node-switchbot": "2.2.1-beta.2"
88
+ "node-switchbot": "2.2.1-beta.3"
89
89
  },
90
90
  "devDependencies": {
91
91
  "@eslint/js": "^9.7.0",
92
92
  "@stylistic/eslint-plugin": "^2.3.0",
93
93
  "@types/eslint__js": "^8.42.3",
94
- "@types/node": "^20.14.10",
94
+ "@types/node": "^20.14.11",
95
95
  "eslint": "^9.7.0",
96
96
  "globals": "^15.8.0",
97
- "homebridge": "^1.8.4-beta.21",
97
+ "homebridge": "^1.8.3",
98
98
  "homebridge-config-ui-x": "4.56.4",
99
99
  "nodemon": "^3.1.4",
100
100
  "npm-check-updates": "^16.14.20",
101
101
  "rimraf": "^6.0.1",
102
102
  "ts-node": "^10.9.2",
103
103
  "typescript": "^5.5.3",
104
- "typescript-eslint": "^8.0.0-alpha.42"
104
+ "typescript-eslint": "^8.0.0-alpha.44"
105
105
  }
106
106
  }
@@ -782,7 +782,7 @@ export abstract class deviceBase {
782
782
 
783
783
  async debugSuccessLog(...log: any[]): Promise<void> {
784
784
  if (await this.enablingDeviceLogging()) {
785
- if (this.deviceLogging?.includes('debug')) {
785
+ if (await this.loggingIsDebug()) {
786
786
  this.log.success(`[DEBUG] ${this.device.deviceType}: ${this.accessory.displayName}`, String(...log));
787
787
  }
788
788
  }
@@ -796,7 +796,7 @@ export abstract class deviceBase {
796
796
 
797
797
  async debugWarnLog(...log: any[]): Promise<void> {
798
798
  if (await this.enablingDeviceLogging()) {
799
- if (this.deviceLogging?.includes('debug')) {
799
+ if (await this.loggingIsDebug()) {
800
800
  this.log.warn(`[DEBUG] ${this.device.deviceType}: ${this.accessory.displayName}`, String(...log));
801
801
  }
802
802
  }
@@ -810,7 +810,7 @@ export abstract class deviceBase {
810
810
 
811
811
  async debugErrorLog(...log: any[]): Promise<void> {
812
812
  if (await this.enablingDeviceLogging()) {
813
- if (this.deviceLogging?.includes('debug')) {
813
+ if (await this.loggingIsDebug()) {
814
814
  this.log.error(`[DEBUG] ${this.device.deviceType}: ${this.accessory.displayName}`, String(...log));
815
815
  }
816
816
  }
@@ -820,13 +820,17 @@ export abstract class deviceBase {
820
820
  if (await this.enablingDeviceLogging()) {
821
821
  if (this.deviceLogging === 'debug') {
822
822
  this.log.info(`[DEBUG] ${this.device.deviceType}: ${this.accessory.displayName}`, String(...log));
823
- } else {
823
+ } else if (this.deviceLogging === 'debugMode') {
824
824
  this.log.debug(`${this.device.deviceType}: ${this.accessory.displayName}`, String(...log));
825
825
  }
826
826
  }
827
827
  }
828
828
 
829
+ async loggingIsDebug(): Promise<boolean> {
830
+ return this.deviceLogging === 'debugMode' || this.deviceLogging === 'debug';
831
+ }
832
+
829
833
  async enablingDeviceLogging(): Promise<boolean> {
830
- return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
834
+ return this.deviceLogging === 'debugMode' || this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
831
835
  }
832
836
  }
@@ -363,7 +363,7 @@ export abstract class irdeviceBase {
363
363
 
364
364
  async debugSuccessLog(...log: any[]): Promise<void> {
365
365
  if (await this.enablingDeviceLogging()) {
366
- if (this.deviceLogging?.includes('debug')) {
366
+ if (await this.loggingIsDebug()) {
367
367
  this.log.success(`[DEBUG] ${this.device.remoteType}: ${this.accessory.displayName}`, String(...log));
368
368
  }
369
369
  }
@@ -377,7 +377,7 @@ export abstract class irdeviceBase {
377
377
 
378
378
  async debugWarnLog(...log: any[]): Promise<void> {
379
379
  if (await this.enablingDeviceLogging()) {
380
- if (this.deviceLogging?.includes('debug')) {
380
+ if (await this.loggingIsDebug()) {
381
381
  this.log.warn(`[DEBUG] ${this.device.remoteType}: ${this.accessory.displayName}`, String(...log));
382
382
  }
383
383
  }
@@ -391,7 +391,7 @@ export abstract class irdeviceBase {
391
391
 
392
392
  async debugErrorLog(...log: any[]): Promise<void> {
393
393
  if (await this.enablingDeviceLogging()) {
394
- if (this.deviceLogging?.includes('debug')) {
394
+ if (await this.loggingIsDebug()) {
395
395
  this.log.error(`[DEBUG] ${this.device.remoteType}: ${this.accessory.displayName}`, String(...log));
396
396
  }
397
397
  }
@@ -401,13 +401,17 @@ export abstract class irdeviceBase {
401
401
  if (await this.enablingDeviceLogging()) {
402
402
  if (this.deviceLogging === 'debug') {
403
403
  this.log.info(`[DEBUG] ${this.device.remoteType}: ${this.accessory.displayName}`, String(...log));
404
- } else {
404
+ } else if (this.deviceLogging === 'debugMode') {
405
405
  this.log.debug(`${this.device.remoteType}: ${this.accessory.displayName}`, String(...log));
406
406
  }
407
407
  }
408
408
  }
409
409
 
410
+ async loggingIsDebug(): Promise<boolean> {
411
+ return this.deviceLogging === 'debugMode' || this.deviceLogging === 'debug';
412
+ }
413
+
410
414
  async enablingDeviceLogging(): Promise<boolean> {
411
- return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
415
+ return this.deviceLogging === 'debugMode' || this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
412
416
  }
413
417
  }
package/src/platform.ts CHANGED
@@ -104,8 +104,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
104
104
  };
105
105
 
106
106
  // Plugin Configuration
107
- this.getPlatformConfigSettings();
108
107
  this.getPlatformLogSettings();
108
+ this.getPlatformConfigSettings();
109
109
  this.getVersion();
110
110
 
111
111
  // Finish initializing the platform
@@ -2907,7 +2907,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
2907
2907
  }
2908
2908
 
2909
2909
  async getPlatformLogSettings() {
2910
- this.debugMode = process.argv.includes('-D') || process.argv.includes('--debug');
2910
+ this.debugMode = process.argv.includes('-D') ?? process.argv.includes('--debug');
2911
2911
  if (this.config.options?.logging === 'debug' || this.config.options?.logging === 'standard' || this.config.options?.logging === 'none') {
2912
2912
  this.platformLogging = this.config.options.logging;
2913
2913
  await this.debugWarnLog(`Using Config Logging: ${this.platformLogging}`);
@@ -2971,7 +2971,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
2971
2971
 
2972
2972
  async debugSuccessLog(...log: any[]): Promise<void> {
2973
2973
  if (await this.enablingPlatformLogging()) {
2974
- if (this.platformLogging?.includes('debug')) {
2974
+ if (await this.loggingIsDebug()) {
2975
2975
  this.log.success('[DEBUG]', String(...log));
2976
2976
  }
2977
2977
  }
@@ -2985,7 +2985,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
2985
2985
 
2986
2986
  async debugWarnLog(...log: any[]): Promise<void> {
2987
2987
  if (await this.enablingPlatformLogging()) {
2988
- if (this.platformLogging?.includes('debug')) {
2988
+ if (await this.loggingIsDebug()) {
2989
2989
  this.log.warn('[DEBUG]', String(...log));
2990
2990
  }
2991
2991
  }
@@ -2999,7 +2999,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
2999
2999
 
3000
3000
  async debugErrorLog(...log: any[]): Promise<void> {
3001
3001
  if (await this.enablingPlatformLogging()) {
3002
- if (this.platformLogging?.includes('debug')) {
3002
+ if (await this.loggingIsDebug()) {
3003
3003
  this.log.error('[DEBUG]', String(...log));
3004
3004
  }
3005
3005
  }
@@ -3007,15 +3007,19 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
3007
3007
 
3008
3008
  async debugLog(...log: any[]): Promise<void> {
3009
3009
  if (await this.enablingPlatformLogging()) {
3010
- if (this.platformLogging === 'debugMode') {
3011
- this.log.debug(String(...log));
3012
- } else if (this.platformLogging === 'debug') {
3010
+ if (this.platformLogging === 'debug') {
3013
3011
  this.log.info('[DEBUG]', String(...log));
3012
+ } else if (this.platformLogging === 'debugMode') {
3013
+ this.log.debug(String(...log));
3014
3014
  }
3015
3015
  }
3016
3016
  }
3017
3017
 
3018
+ async loggingIsDebug(): Promise<boolean> {
3019
+ return this.platformLogging === 'debugMode' || this.platformLogging === 'debug';
3020
+ }
3021
+
3018
3022
  async enablingPlatformLogging(): Promise<boolean> {
3019
- return this.platformLogging?.includes('debug') || this.platformLogging === 'standard';
3023
+ return this.platformLogging === 'debugMode' || this.platformLogging === 'debug' || this.platformLogging === 'standard';
3020
3024
  }
3021
3025
  }