@switchbot/homebridge-switchbot 1.11.1 → 1.12.2-beta.0

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.
Files changed (83) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/config.schema.json +18 -3
  3. package/dist/device/bot.d.ts +8 -0
  4. package/dist/device/bot.d.ts.map +1 -1
  5. package/dist/device/bot.js +40 -21
  6. package/dist/device/bot.js.map +1 -1
  7. package/dist/device/colorbulb.d.ts.map +1 -1
  8. package/dist/device/colorbulb.js +8 -26
  9. package/dist/device/colorbulb.js.map +1 -1
  10. package/dist/device/contact.d.ts.map +1 -1
  11. package/dist/device/contact.js +4 -10
  12. package/dist/device/contact.js.map +1 -1
  13. package/dist/device/curtain.d.ts.map +1 -1
  14. package/dist/device/curtain.js +13 -28
  15. package/dist/device/curtain.js.map +1 -1
  16. package/dist/device/humidifier.d.ts.map +1 -1
  17. package/dist/device/humidifier.js +9 -30
  18. package/dist/device/humidifier.js.map +1 -1
  19. package/dist/device/lock.d.ts.map +1 -1
  20. package/dist/device/lock.js +4 -10
  21. package/dist/device/lock.js.map +1 -1
  22. package/dist/device/meter.d.ts.map +1 -1
  23. package/dist/device/meter.js +4 -10
  24. package/dist/device/meter.js.map +1 -1
  25. package/dist/device/motion.d.ts.map +1 -1
  26. package/dist/device/motion.js +4 -10
  27. package/dist/device/motion.js.map +1 -1
  28. package/dist/device/plug.d.ts.map +1 -1
  29. package/dist/device/plug.js +4 -10
  30. package/dist/device/plug.js.map +1 -1
  31. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  32. package/dist/irdevice/airconditioner.js +3 -6
  33. package/dist/irdevice/airconditioner.js.map +1 -1
  34. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  35. package/dist/irdevice/airpurifier.js +3 -6
  36. package/dist/irdevice/airpurifier.js.map +1 -1
  37. package/dist/irdevice/camera.d.ts.map +1 -1
  38. package/dist/irdevice/camera.js +3 -6
  39. package/dist/irdevice/camera.js.map +1 -1
  40. package/dist/irdevice/fan.d.ts.map +1 -1
  41. package/dist/irdevice/fan.js +3 -6
  42. package/dist/irdevice/fan.js.map +1 -1
  43. package/dist/irdevice/light.d.ts.map +1 -1
  44. package/dist/irdevice/light.js +3 -6
  45. package/dist/irdevice/light.js.map +1 -1
  46. package/dist/irdevice/other.d.ts.map +1 -1
  47. package/dist/irdevice/other.js +4 -7
  48. package/dist/irdevice/other.js.map +1 -1
  49. package/dist/irdevice/tv.d.ts.map +1 -1
  50. package/dist/irdevice/tv.js +3 -6
  51. package/dist/irdevice/tv.js.map +1 -1
  52. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  53. package/dist/irdevice/vacuumcleaner.js +3 -6
  54. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  55. package/dist/irdevice/waterheater.d.ts.map +1 -1
  56. package/dist/irdevice/waterheater.js +3 -6
  57. package/dist/irdevice/waterheater.js.map +1 -1
  58. package/dist/platform.js +6 -6
  59. package/dist/platform.js.map +1 -1
  60. package/dist/settings.d.ts +1 -0
  61. package/dist/settings.d.ts.map +1 -1
  62. package/dist/settings.js.map +1 -1
  63. package/package.json +76 -76
  64. package/src/device/bot.ts +40 -20
  65. package/src/device/colorbulb.ts +8 -36
  66. package/src/device/contact.ts +4 -12
  67. package/src/device/curtain.ts +13 -28
  68. package/src/device/humidifier.ts +9 -30
  69. package/src/device/lock.ts +4 -10
  70. package/src/device/meter.ts +4 -10
  71. package/src/device/motion.ts +4 -12
  72. package/src/device/plug.ts +4 -10
  73. package/src/irdevice/airconditioner.ts +3 -6
  74. package/src/irdevice/airpurifier.ts +3 -6
  75. package/src/irdevice/camera.ts +3 -6
  76. package/src/irdevice/fan.ts +3 -6
  77. package/src/irdevice/light.ts +3 -6
  78. package/src/irdevice/other.ts +4 -7
  79. package/src/irdevice/tv.ts +3 -8
  80. package/src/irdevice/vacuumcleaner.ts +3 -6
  81. package/src/irdevice/waterheater.ts +3 -6
  82. package/src/platform.ts +6 -6
  83. package/src/settings.ts +1 -0
package/package.json CHANGED
@@ -1,80 +1,80 @@
1
1
  {
2
- "displayName": "Homebridge SwitchBot",
3
- "name": "@switchbot/homebridge-switchbot",
4
- "version": "1.11.1",
5
- "description": "The [Homebridge](https://homebridge.io) SwitchBot plugin allows you to access your [SwitchBot](https://www.switch-bot.com) device(s) from HomeKit.",
6
- "author": "SwitchBot <support@wondertechlabs.com> (https://github.com/SwitchBot)",
7
- "license": "ISC",
8
- "repository": {
9
- "type": "git",
10
- "url": "git://github.com/OpenWonderLabs/homebridge-switchbot.git"
11
- },
12
- "bugs": {
13
- "url": "https://github.com/OpenWonderLabs/homebridge-switchbot/issues"
14
- },
15
- "engines": {
16
- "homebridge": "^1.4.0",
17
- "node": "^14.18.3 || ^16.13.2"
18
- },
19
- "main": "dist/index.js",
20
- "scripts": {
21
- "check": "npm install && npm outdated",
22
- "update": "ncu -u && npm update && npm install",
23
- "lint": "eslint src/**.ts",
24
- "watch": "npm run build && npm link && nodemon",
25
- "build": "rimraf ./dist && tsc",
26
- "prepublishOnly": "npm run lint && npm run build",
27
- "postpublish": "npm run clean",
28
- "clean": "rimraf ./dist",
29
- "test": "eslint src/**.ts"
30
- },
31
- "funding": [
32
- {
33
- "type": "Paypal",
34
- "url": "https://paypal.me/donavanbecker"
2
+ "displayName": "Homebridge SwitchBot",
3
+ "name": "@switchbot/homebridge-switchbot",
4
+ "version": "1.12.2-beta.0",
5
+ "description": "The [Homebridge](https://homebridge.io) SwitchBot plugin allows you to access your [SwitchBot](https://www.switch-bot.com) device(s) from HomeKit.",
6
+ "author": "SwitchBot <support@wondertechlabs.com> (https://github.com/SwitchBot)",
7
+ "license": "ISC",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git://github.com/OpenWonderLabs/homebridge-switchbot.git"
35
11
  },
36
- {
37
- "type": "GitHub",
38
- "url": "https://github.com/sponsors/donavanbecker"
12
+ "bugs": {
13
+ "url": "https://github.com/OpenWonderLabs/homebridge-switchbot/issues"
14
+ },
15
+ "engines": {
16
+ "homebridge": "^1.4.0",
17
+ "node": "^14.18.3 || ^16.13.2"
18
+ },
19
+ "main": "dist/index.js",
20
+ "scripts": {
21
+ "check": "npm install && npm outdated",
22
+ "update": "ncu -u && npm update && npm install",
23
+ "lint": "eslint src/**.ts",
24
+ "watch": "npm run build && npm link && nodemon",
25
+ "build": "rimraf ./dist && tsc",
26
+ "prepublishOnly": "npm run lint && npm run build",
27
+ "postpublish": "npm run clean",
28
+ "clean": "rimraf ./dist",
29
+ "test": "eslint src/**.ts"
30
+ },
31
+ "funding": [
32
+ {
33
+ "type": "Paypal",
34
+ "url": "https://paypal.me/donavanbecker"
35
+ },
36
+ {
37
+ "type": "GitHub",
38
+ "url": "https://github.com/sponsors/donavanbecker"
39
+ }
40
+ ],
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "keywords": [
45
+ "homebridge-plugin",
46
+ "switchbot",
47
+ "humidifier",
48
+ "humidity",
49
+ "temperature",
50
+ "bot",
51
+ "curtains",
52
+ "windows",
53
+ "ble",
54
+ "ir"
55
+ ],
56
+ "dependencies": {
57
+ "@homebridge/plugin-ui-utils": "^0.0.19",
58
+ "axios": "^0.25.0",
59
+ "rxjs": "^7.5.2"
60
+ },
61
+ "devDependencies": {
62
+ "@types/node": "^17.0.14",
63
+ "@typescript-eslint/eslint-plugin": "^5.10.2",
64
+ "@typescript-eslint/parser": "^5.10.2",
65
+ "eslint": "^8.8.0",
66
+ "eslint-config-prettier": "8.3.0",
67
+ "eslint-plugin-prettier": "4.0.0",
68
+ "homebridge": "^1.4.0",
69
+ "nodemon": "^2.0.15",
70
+ "npm-check-updates": "^12.2.1",
71
+ "prettier": "2.5.1",
72
+ "rimraf": "^3.0.2",
73
+ "ts-node": "^10.4.0",
74
+ "typescript": "^4.5.5",
75
+ "typescript-axios-wb": "^1.0.3"
76
+ },
77
+ "optionalDependencies": {
78
+ "node-switchbot": "^1.1.2"
39
79
  }
40
- ],
41
- "publishConfig": {
42
- "access": "public"
43
- },
44
- "keywords": [
45
- "homebridge-plugin",
46
- "switchbot",
47
- "humidifier",
48
- "humidity",
49
- "temperature",
50
- "bot",
51
- "curtains",
52
- "windows",
53
- "ble",
54
- "ir"
55
- ],
56
- "dependencies": {
57
- "@homebridge/plugin-ui-utils": "^0.0.19",
58
- "axios": "^0.25.0",
59
- "rxjs": "^7.5.2"
60
- },
61
- "devDependencies": {
62
- "@types/node": "^17.0.13",
63
- "@typescript-eslint/eslint-plugin": "^5.10.1",
64
- "@typescript-eslint/parser": "^5.10.1",
65
- "eslint": "^8.8.0",
66
- "eslint-config-prettier": "8.3.0",
67
- "eslint-plugin-prettier": "4.0.0",
68
- "homebridge": "^1.4.0",
69
- "nodemon": "^2.0.15",
70
- "npm-check-updates": "^12.2.1",
71
- "prettier": "2.5.1",
72
- "rimraf": "^3.0.2",
73
- "ts-node": "^10.4.0",
74
- "typescript": "^4.5.5",
75
- "typescript-axios-wb": "^1.0.3"
76
- },
77
- "optionalDependencies": {
78
- "node-switchbot": "^1.1.2"
79
- }
80
80
  }
package/src/device/bot.ts CHANGED
@@ -355,7 +355,7 @@ export class Bot {
355
355
  });
356
356
  } catch (e: any) {
357
357
  this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges`);
358
- if (this.deviceLogging === 'debug') {
358
+ if (this.deviceLogging.includes('debug')) {
359
359
  this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges,` + ` Error Message: ${JSON.stringify(e.message)}`);
360
360
  }
361
361
  if (this.platform.debugMode) {
@@ -506,7 +506,7 @@ export class Bot {
506
506
  })
507
507
  .catch(async (e: any) => {
508
508
  this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
509
- if (this.deviceLogging === 'debug') {
509
+ if (this.deviceLogging.includes('debug')) {
510
510
  this.errorLog(
511
511
  `Bot: ${this.accessory.displayName} failed refreshStatus with BLE Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
512
512
  );
@@ -534,7 +534,7 @@ export class Bot {
534
534
  this.updateHomeKitCharacteristics();
535
535
  } catch (e: any) {
536
536
  this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
537
- if (this.deviceLogging === 'debug') {
537
+ if (this.deviceLogging.includes('debug')) {
538
538
  this.errorLog(
539
539
  `Bot: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
540
540
  );
@@ -604,7 +604,7 @@ export class Bot {
604
604
  })
605
605
  .catch(async (e: any) => {
606
606
  this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
607
- if (this.deviceLogging === 'debug') {
607
+ if (this.deviceLogging.includes('debug')) {
608
608
  this.errorLog(
609
609
  `Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
610
610
  );
@@ -633,7 +633,7 @@ export class Bot {
633
633
  })
634
634
  .catch(async (e: any) => {
635
635
  this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
636
- if (this.deviceLogging === 'debug') {
636
+ if (this.deviceLogging.includes('debug')) {
637
637
  this.errorLog(
638
638
  `Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
639
639
  );
@@ -650,24 +650,22 @@ export class Bot {
650
650
  } else {
651
651
  throw new Error(`Bot: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
652
652
  }
653
- /* } else {
654
- this.errorLog(`Bot: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
655
- if (this.platform.config.credentials?.openToken) {
656
- this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
657
- await this.openAPIpushChanges();
658
- }
659
- }*/
660
653
  }
661
654
  this.OnCached = this.On;
662
655
  this.accessory.context.On = this.OnCached;
663
656
  }
664
657
 
665
658
  async turnOnOff(device_list: any): Promise<any> {
666
- if (this.On) {
667
- return device_list[0].turnOn({ id: this.device.bleMac });
668
- } else {
669
- return device_list[0].turnOff({ id: this.device.bleMac });
670
- }
659
+ return await this.retry({
660
+ max: await this.maxRetry(),
661
+ fn: () => {
662
+ if (this.On) {
663
+ return device_list[0].turnOn({ id: this.device.bleMac });
664
+ } else {
665
+ return device_list[0].turnOff({ id: this.device.bleMac });
666
+ }
667
+ },
668
+ });
671
669
  }
672
670
 
673
671
  async openAPIpushChanges(): Promise<void> {
@@ -710,7 +708,7 @@ export class Bot {
710
708
  }
711
709
  } catch (e: any) {
712
710
  this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
713
- if (this.deviceLogging === 'debug') {
711
+ if (this.deviceLogging.includes('debug')) {
714
712
  this.errorLog(
715
713
  `Bot: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
716
714
  );
@@ -1046,6 +1044,28 @@ export class Bot {
1046
1044
  this.doBotUpdate.next();
1047
1045
  }
1048
1046
 
1047
+ async retry({ max, fn }: { max: number; fn: { (): any; (): Promise<any> } }): Promise<null> {
1048
+ return fn().catch(async (err: any) => {
1049
+ if (max === 0) {
1050
+ throw err;
1051
+ }
1052
+ this.infoLog(err);
1053
+ this.infoLog('Retrying');
1054
+ await this.switchbot.wait(1000);
1055
+ return this.retry({ max: max - 1, fn });
1056
+ });
1057
+ }
1058
+
1059
+ async maxRetry(): Promise<number> {
1060
+ let maxRetry: number;
1061
+ if (this.device.bot?.maxRetry) {
1062
+ maxRetry = this.device.bot?.maxRetry;
1063
+ } else {
1064
+ maxRetry = 5;
1065
+ }
1066
+ return maxRetry;
1067
+ }
1068
+
1049
1069
  async config(device: device & devicesConfig): Promise<void> {
1050
1070
  let config = {};
1051
1071
  if (device.bot) {
@@ -1067,7 +1087,7 @@ export class Bot {
1067
1087
  config['offline'] = device.offline;
1068
1088
  }
1069
1089
  if (Object.entries(config).length !== 0) {
1070
- this.warnLog(`Bot: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
1090
+ this.infoLog(`Bot: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
1071
1091
  }
1072
1092
  }
1073
1093
 
@@ -1258,6 +1278,6 @@ export class Bot {
1258
1278
  }
1259
1279
 
1260
1280
  enablingDeviceLogging(): boolean {
1261
- return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
1281
+ return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
1262
1282
  }
1263
1283
  }
@@ -205,12 +205,9 @@ export class ColorBulb {
205
205
  await this.pushChanges();
206
206
  } catch (e: any) {
207
207
  this.errorLog(`${device.deviceType}: ${this.accessory.displayName} failed pushChanges`);
208
- if (this.deviceLogging === 'debug') {
208
+ if (this.deviceLogging.includes('debug')) {
209
209
  this.errorLog(`${device.deviceType}: ${this.accessory.displayName} failed pushChanges,` + ` Error Message: ${JSON.stringify(e.message)}`);
210
210
  }
211
- if (this.platform.debugMode) {
212
- this.errorLog(`${device.deviceType}: ${this.accessory.displayName} failed pushChanges,` + ` Error: ${JSON.stringify(e)}`);
213
- }
214
211
  this.apiError(e);
215
212
  }
216
213
  this.colorBulbUpdateInProgress = false;
@@ -281,17 +278,12 @@ export class ColorBulb {
281
278
  this.updateHomeKitCharacteristics();
282
279
  } catch (e: any) {
283
280
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
284
- if (this.deviceLogging === 'debug') {
281
+ if (this.deviceLogging.includes('debug')) {
285
282
  this.errorLog(
286
283
  `${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` +
287
284
  ` Error Message: ${JSON.stringify(e.message)}`,
288
285
  );
289
286
  }
290
- if (this.platform.debugMode) {
291
- this.errorLog(
292
- `${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`,
293
- );
294
- }
295
287
  this.apiError(e);
296
288
  }
297
289
  }
@@ -355,17 +347,12 @@ export class ColorBulb {
355
347
  }
356
348
  } catch (e: any) {
357
349
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
358
- if (this.deviceLogging === 'debug') {
350
+ if (this.deviceLogging.includes('debug')) {
359
351
  this.errorLog(
360
352
  `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
361
353
  ` Error Message: ${JSON.stringify(e.message)}`,
362
354
  );
363
355
  }
364
- if (this.platform.debugMode) {
365
- this.errorLog(
366
- `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`,
367
- );
368
- }
369
356
  this.apiError(e);
370
357
  }
371
358
  }
@@ -404,17 +391,12 @@ export class ColorBulb {
404
391
  }
405
392
  } catch (e: any) {
406
393
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
407
- if (this.deviceLogging === 'debug') {
394
+ if (this.deviceLogging.includes('debug')) {
408
395
  this.errorLog(
409
396
  `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
410
397
  ` Error Message: ${JSON.stringify(e.message)}`,
411
398
  );
412
399
  }
413
- if (this.platform.debugMode) {
414
- this.errorLog(
415
- `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`,
416
- );
417
- }
418
400
  this.apiError(e);
419
401
  }
420
402
  }
@@ -449,17 +431,12 @@ export class ColorBulb {
449
431
  }
450
432
  } catch (e: any) {
451
433
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
452
- if (this.deviceLogging === 'debug') {
434
+ if (this.deviceLogging.includes('debug')) {
453
435
  this.errorLog(
454
436
  `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
455
437
  ` Error Message: ${JSON.stringify(e.message)}`,
456
438
  );
457
439
  }
458
- if (this.platform.debugMode) {
459
- this.errorLog(
460
- `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`,
461
- );
462
- }
463
440
  this.apiError(e);
464
441
  }
465
442
  }
@@ -491,17 +468,12 @@ export class ColorBulb {
491
468
  }
492
469
  } catch (e: any) {
493
470
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
494
- if (this.deviceLogging === 'debug') {
471
+ if (this.deviceLogging.includes('debug')) {
495
472
  this.errorLog(
496
473
  `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
497
474
  ` Error Message: ${JSON.stringify(e.message)}`,
498
475
  );
499
476
  }
500
- if (this.platform.debugMode) {
501
- this.errorLog(
502
- `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`,
503
- );
504
- }
505
477
  this.apiError(e);
506
478
  }
507
479
  }
@@ -700,7 +672,7 @@ export class ColorBulb {
700
672
  config['offline'] = device.offline;
701
673
  }
702
674
  if (Object.entries(config).length !== 0) {
703
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
675
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
704
676
  }
705
677
  }
706
678
 
@@ -781,6 +753,6 @@ export class ColorBulb {
781
753
  }
782
754
 
783
755
  enablingDeviceLogging(): boolean {
784
- return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
756
+ return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
785
757
  }
786
758
  }
@@ -314,15 +314,12 @@ export class Contact {
314
314
  })
315
315
  .catch(async (e: any) => {
316
316
  this.errorLog(`Contact Sensor: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
317
- if (this.deviceLogging === 'debug') {
317
+ if (this.deviceLogging.includes('debug')) {
318
318
  this.errorLog(
319
319
  `Contact Sensor: ${this.accessory.displayName} failed refreshStatus with BLE Connection,` +
320
320
  ` Error Message: ${JSON.stringify(e.message)}`,
321
321
  );
322
322
  }
323
- if (this.platform.debugMode) {
324
- this.errorLog(`Contact Sensor: ${this.accessory.displayName} failed refreshStatus with BLE Connection,` + ` Error: ${JSON.stringify(e)}`);
325
- }
326
323
  if (this.platform.config.credentials?.openToken) {
327
324
  this.warnLog(`Contact Sensor: ${this.accessory.displayName} Using OpenAPI Connection`);
328
325
  this.SwitchToOpenAPI = true;
@@ -357,17 +354,12 @@ export class Contact {
357
354
  this.updateHomeKitCharacteristics();
358
355
  } catch (e: any) {
359
356
  this.errorLog(`Contact Sensor: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
360
- if (this.deviceLogging === 'debug') {
357
+ if (this.deviceLogging.includes('debug')) {
361
358
  this.errorLog(
362
359
  `Contact Sensor: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` +
363
360
  ` Error Message: ${JSON.stringify(e.message)}`,
364
361
  );
365
362
  }
366
- if (this.platform.debugMode) {
367
- this.errorLog(
368
- `Contact Sensor: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`,
369
- );
370
- }
371
363
  this.apiError(e);
372
364
  }
373
365
  }
@@ -450,7 +442,7 @@ export class Contact {
450
442
  config['scanDuration'] = device.scanDuration;
451
443
  }
452
444
  if (Object.entries(config).length !== 0) {
453
- this.warnLog(`Contact Sensor: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
445
+ this.infoLog(`Contact Sensor: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
454
446
  }
455
447
  }
456
448
 
@@ -544,6 +536,6 @@ export class Contact {
544
536
  }
545
537
 
546
538
  enablingDeviceLogging(): boolean {
547
- return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
539
+ return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
548
540
  }
549
541
  }
@@ -184,12 +184,9 @@ export class Curtain {
184
184
  await this.pushChanges();
185
185
  } catch (e: any) {
186
186
  this.errorLog(`Curtain: ${this.accessory.displayName} failed pushChanges`);
187
- if (this.deviceLogging === 'debug') {
187
+ if (this.deviceLogging.includes('debug')) {
188
188
  this.errorLog(`Curtain: ${this.accessory.displayName} failed pushChanges,` + ` Error Message: ${JSON.stringify(e.message)}`);
189
189
  }
190
- if (this.platform.debugMode) {
191
- this.errorLog(`Curtain: ${this.accessory.displayName} failed pushChanges,` + ` Error: ${JSON.stringify(e)}`);
192
- }
193
190
  this.apiError(e);
194
191
  }
195
192
  this.curtainUpdateInProgress = false;
@@ -425,14 +422,11 @@ export class Curtain {
425
422
  })
426
423
  .catch(async (e: any) => {
427
424
  this.errorLog(`Curtain: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
428
- if (this.deviceLogging === 'debug') {
425
+ if (this.deviceLogging.includes('debug')) {
429
426
  this.errorLog(
430
427
  `Curtain: ${this.accessory.displayName} failed refreshStatus with BLE Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
431
428
  );
432
429
  }
433
- if (this.platform.debugMode) {
434
- this.errorLog(`Curtain: ${this.accessory.displayName} failed refreshStatus with BLE Connection,` + ` Error: ${JSON.stringify(e)}`);
435
- }
436
430
  if (this.platform.config.credentials?.openToken) {
437
431
  this.warnLog(`Curtain: ${this.accessory.displayName} Using OpenAPI Connection`);
438
432
  this.SwitchToOpenAPI = true;
@@ -467,14 +461,11 @@ export class Curtain {
467
461
  this.updateHomeKitCharacteristics();
468
462
  } catch (e: any) {
469
463
  this.errorLog(`Curtain: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
470
- if (this.deviceLogging === 'debug') {
464
+ if (this.deviceLogging.includes('debug')) {
471
465
  this.errorLog(
472
466
  `Curtain: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
473
467
  );
474
468
  }
475
- if (this.platform.debugMode) {
476
- this.errorLog(`Curtain: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
477
- }
478
469
  this.apiError(e);
479
470
  }
480
471
  }
@@ -516,14 +507,11 @@ export class Curtain {
516
507
  })
517
508
  .catch(async (e: any) => {
518
509
  this.errorLog(`Curtain: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
519
- if (this.deviceLogging === 'debug') {
510
+ if (this.deviceLogging.includes('debug')) {
520
511
  this.errorLog(
521
512
  `Curtain: ${this.accessory.displayName} failed pushChanges with BLE Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
522
513
  );
523
514
  }
524
- if (this.platform.debugMode) {
525
- this.errorLog(`Curtain: ${this.accessory.displayName} failed pushChanges with BLE Connection,` + ` Error: ${JSON.stringify(e)}`);
526
- }
527
515
  if (this.platform.config.credentials?.openToken) {
528
516
  this.warnLog(`Curtain: ${this.accessory.displayName} Using OpenAPI Connection`);
529
517
  await this.openAPIpushChanges();
@@ -575,14 +563,11 @@ export class Curtain {
575
563
  }
576
564
  } catch (e: any) {
577
565
  this.errorLog(`Curtain: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
578
- if (this.deviceLogging === 'debug') {
566
+ if (this.deviceLogging.includes('debug')) {
579
567
  this.errorLog(
580
568
  `Curtain: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
581
569
  );
582
570
  }
583
- if (this.platform.debugMode) {
584
- this.errorLog(`Curtain: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
585
- }
586
571
  this.apiError(e);
587
572
  }
588
573
  }
@@ -747,7 +732,7 @@ export class Curtain {
747
732
  config['scanDuration'] = device.scanDuration;
748
733
  }
749
734
  if (Object.entries(config).length !== 0) {
750
- this.warnLog(`Curtain: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
735
+ this.infoLog(`Curtain: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
751
736
  }
752
737
  }
753
738
 
@@ -772,9 +757,9 @@ export class Curtain {
772
757
 
773
758
  async scan(device: device & devicesConfig): Promise<void> {
774
759
  if (device.scanDuration) {
775
- if (this.deviceRefreshRate > device.scanDuration) {
776
- this.scanDuration = this.deviceRefreshRate;
777
- this.warnLog(`Curtain: ${this.accessory.displayName} scanDuration is less then refreshRate, overriding scanDuration with refreshRate`);
760
+ if (this.updateRate > device.scanDuration) {
761
+ this.scanDuration = this.updateRate;
762
+ this.warnLog(`Curtain: ${this.accessory.displayName} scanDuration is less then updateRate, overriding scanDuration with updateRate`);
778
763
  } else {
779
764
  this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
780
765
  }
@@ -782,9 +767,9 @@ export class Curtain {
782
767
  this.debugLog(`Curtain: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
783
768
  }
784
769
  } else {
785
- if (this.deviceRefreshRate > 1) {
786
- this.scanDuration = this.deviceRefreshRate;
787
- this.warnLog(`Curtain: ${this.accessory.displayName} scanDuration is less then refreshRate, overriding scanDuration with refreshRate`);
770
+ if (this.updateRate > 1) {
771
+ this.scanDuration = this.updateRate;
772
+ this.warnLog(`Curtain: ${this.accessory.displayName} scanDuration is less then updateRate, overriding scanDuration with updateRate`);
788
773
  } else {
789
774
  this.scanDuration = this.accessory.context.scanDuration = 1;
790
775
  }
@@ -869,6 +854,6 @@ export class Curtain {
869
854
  }
870
855
 
871
856
  enablingDeviceLogging(): boolean {
872
- return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
857
+ return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
873
858
  }
874
859
  }