@switchbot/homebridge-switchbot 1.11.0 → 1.12.1

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 (93) hide show
  1. package/CHANGELOG.md +31 -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 +22 -32
  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 +22 -22
  32. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  33. package/dist/irdevice/airconditioner.js +47 -50
  34. package/dist/irdevice/airconditioner.js.map +1 -1
  35. package/dist/irdevice/airpurifier.d.ts +12 -9
  36. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  37. package/dist/irdevice/airpurifier.js +23 -26
  38. package/dist/irdevice/airpurifier.js.map +1 -1
  39. package/dist/irdevice/camera.d.ts +10 -7
  40. package/dist/irdevice/camera.d.ts.map +1 -1
  41. package/dist/irdevice/camera.js +14 -17
  42. package/dist/irdevice/camera.js.map +1 -1
  43. package/dist/irdevice/fan.d.ts +12 -9
  44. package/dist/irdevice/fan.d.ts.map +1 -1
  45. package/dist/irdevice/fan.js +32 -35
  46. package/dist/irdevice/fan.js.map +1 -1
  47. package/dist/irdevice/light.d.ts +10 -7
  48. package/dist/irdevice/light.d.ts.map +1 -1
  49. package/dist/irdevice/light.js +16 -19
  50. package/dist/irdevice/light.js.map +1 -1
  51. package/dist/irdevice/other.d.ts +12 -9
  52. package/dist/irdevice/other.d.ts.map +1 -1
  53. package/dist/irdevice/other.js +21 -24
  54. package/dist/irdevice/other.js.map +1 -1
  55. package/dist/irdevice/tv.d.ts +13 -10
  56. package/dist/irdevice/tv.d.ts.map +1 -1
  57. package/dist/irdevice/tv.js +28 -31
  58. package/dist/irdevice/tv.js.map +1 -1
  59. package/dist/irdevice/vacuumcleaner.d.ts +10 -7
  60. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  61. package/dist/irdevice/vacuumcleaner.js +16 -19
  62. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  63. package/dist/irdevice/waterheater.d.ts +10 -7
  64. package/dist/irdevice/waterheater.d.ts.map +1 -1
  65. package/dist/irdevice/waterheater.js +19 -22
  66. package/dist/irdevice/waterheater.js.map +1 -1
  67. package/dist/platform.d.ts.map +1 -1
  68. package/dist/platform.js +5 -5
  69. package/dist/platform.js.map +1 -1
  70. package/dist/settings.d.ts +1 -0
  71. package/dist/settings.d.ts.map +1 -1
  72. package/dist/settings.js.map +1 -1
  73. package/package.json +4 -4
  74. package/src/device/bot.ts +40 -20
  75. package/src/device/colorbulb.ts +22 -44
  76. package/src/device/contact.ts +4 -12
  77. package/src/device/curtain.ts +13 -28
  78. package/src/device/humidifier.ts +9 -30
  79. package/src/device/lock.ts +4 -10
  80. package/src/device/meter.ts +4 -10
  81. package/src/device/motion.ts +4 -12
  82. package/src/device/plug.ts +4 -10
  83. package/src/irdevice/airconditioner.ts +57 -60
  84. package/src/irdevice/airpurifier.ts +33 -36
  85. package/src/irdevice/camera.ts +22 -25
  86. package/src/irdevice/fan.ts +43 -46
  87. package/src/irdevice/light.ts +26 -29
  88. package/src/irdevice/other.ts +29 -32
  89. package/src/irdevice/tv.ts +45 -50
  90. package/src/irdevice/vacuumcleaner.ts +24 -27
  91. package/src/irdevice/waterheater.ts +27 -30
  92. package/src/platform.ts +9 -9
  93. package/src/settings.ts +1 -0
@@ -65,6 +65,14 @@ export class ColorBulb {
65
65
  } else {
66
66
  this.On = this.accessory.context.On;
67
67
  }
68
+ this.Hue = 0;
69
+ this.Brightness = 0;
70
+ this.Saturation = 0;
71
+ if (device.deviceType === 'Color Bulb') {
72
+ this.ColorTemperature = 140;
73
+ }
74
+ this.minKelvin = 2000;
75
+ this.maxKelvin = 9000;
68
76
  // this is subject we use to track when we need to POST changes to the SwitchBot API
69
77
  this.doColorBulbUpdate = new Subject();
70
78
  this.colorBulbUpdateInProgress = false;
@@ -82,13 +90,13 @@ export class ColorBulb {
82
90
  // get the Lightbulb service if it exists, otherwise create a new Lightbulb service
83
91
  // you can create multiple services for each accessory
84
92
  (this.lightBulbService = accessory.getService(this.platform.Service.Lightbulb) || accessory.addService(this.platform.Service.Lightbulb)),
85
- `${accessory.displayName} ${this.device.deviceType}`;
93
+ `${accessory.displayName} ${device.deviceType}`;
86
94
 
87
95
  if (this.adaptiveLightingShift === -1 && this.accessory.context.adaptiveLighting) {
88
96
  this.accessory.removeService(this.lightBulbService);
89
97
  this.lightBulbService = this.accessory.addService(this.platform.Service.Lightbulb);
90
98
  this.accessory.context.adaptiveLighting = false;
91
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} adaptiveLighting: ${this.accessory.context.adaptiveLighting}`);
99
+ this.debugLog(`${device.deviceType}: ${this.accessory.displayName} adaptiveLighting: ${this.accessory.context.adaptiveLighting}`);
92
100
  }
93
101
 
94
102
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
@@ -160,7 +168,7 @@ export class ColorBulb {
160
168
  })
161
169
  .onSet(this.SaturationSet.bind(this));
162
170
 
163
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} adaptiveLightingShift: ${this.adaptiveLightingShift}`);
171
+ this.debugLog(`${device.deviceType}: ${this.accessory.displayName} adaptiveLightingShift: ${this.adaptiveLightingShift}`);
164
172
  if (this.adaptiveLightingShift !== -1) {
165
173
  this.AdaptiveLightingController = new platform.api.hap.AdaptiveLightingController(this.lightBulbService, {
166
174
  customTemperatureAdjustment: this.adaptiveLightingShift,
@@ -168,7 +176,7 @@ export class ColorBulb {
168
176
  this.accessory.configureController(this.AdaptiveLightingController);
169
177
  this.accessory.context.adaptiveLighting = true;
170
178
  this.debugLog(
171
- `${this.device.deviceType}: ${this.accessory.displayName} adaptiveLighting: ${this.accessory.context.adaptiveLighting},` +
179
+ `${device.deviceType}: ${this.accessory.displayName} adaptiveLighting: ${this.accessory.context.adaptiveLighting},` +
172
180
  ` adaptiveLightingShift: ${this.adaptiveLightingShift}`,
173
181
  );
174
182
  }
@@ -196,14 +204,9 @@ export class ColorBulb {
196
204
  try {
197
205
  await this.pushChanges();
198
206
  } catch (e: any) {
199
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges`);
200
- if (this.deviceLogging === 'debug') {
201
- this.errorLog(
202
- `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges,` + ` Error Message: ${JSON.stringify(e.message)}`,
203
- );
204
- }
205
- if (this.platform.debugMode) {
206
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges,` + ` Error: ${JSON.stringify(e)}`);
207
+ this.errorLog(`${device.deviceType}: ${this.accessory.displayName} failed pushChanges`);
208
+ if (this.deviceLogging.includes('debug')) {
209
+ this.errorLog(`${device.deviceType}: ${this.accessory.displayName} failed pushChanges,` + ` Error Message: ${JSON.stringify(e.message)}`);
207
210
  }
208
211
  this.apiError(e);
209
212
  }
@@ -275,17 +278,12 @@ export class ColorBulb {
275
278
  this.updateHomeKitCharacteristics();
276
279
  } catch (e: any) {
277
280
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
278
- if (this.deviceLogging === 'debug') {
281
+ if (this.deviceLogging.includes('debug')) {
279
282
  this.errorLog(
280
283
  `${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` +
281
284
  ` Error Message: ${JSON.stringify(e.message)}`,
282
285
  );
283
286
  }
284
- if (this.platform.debugMode) {
285
- this.errorLog(
286
- `${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`,
287
- );
288
- }
289
287
  this.apiError(e);
290
288
  }
291
289
  }
@@ -349,17 +347,12 @@ export class ColorBulb {
349
347
  }
350
348
  } catch (e: any) {
351
349
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
352
- if (this.deviceLogging === 'debug') {
350
+ if (this.deviceLogging.includes('debug')) {
353
351
  this.errorLog(
354
352
  `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
355
353
  ` Error Message: ${JSON.stringify(e.message)}`,
356
354
  );
357
355
  }
358
- if (this.platform.debugMode) {
359
- this.errorLog(
360
- `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`,
361
- );
362
- }
363
356
  this.apiError(e);
364
357
  }
365
358
  }
@@ -398,17 +391,12 @@ export class ColorBulb {
398
391
  }
399
392
  } catch (e: any) {
400
393
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
401
- if (this.deviceLogging === 'debug') {
394
+ if (this.deviceLogging.includes('debug')) {
402
395
  this.errorLog(
403
396
  `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
404
397
  ` Error Message: ${JSON.stringify(e.message)}`,
405
398
  );
406
399
  }
407
- if (this.platform.debugMode) {
408
- this.errorLog(
409
- `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`,
410
- );
411
- }
412
400
  this.apiError(e);
413
401
  }
414
402
  }
@@ -443,17 +431,12 @@ export class ColorBulb {
443
431
  }
444
432
  } catch (e: any) {
445
433
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
446
- if (this.deviceLogging === 'debug') {
434
+ if (this.deviceLogging.includes('debug')) {
447
435
  this.errorLog(
448
436
  `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
449
437
  ` Error Message: ${JSON.stringify(e.message)}`,
450
438
  );
451
439
  }
452
- if (this.platform.debugMode) {
453
- this.errorLog(
454
- `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`,
455
- );
456
- }
457
440
  this.apiError(e);
458
441
  }
459
442
  }
@@ -485,17 +468,12 @@ export class ColorBulb {
485
468
  }
486
469
  } catch (e: any) {
487
470
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
488
- if (this.deviceLogging === 'debug') {
471
+ if (this.deviceLogging.includes('debug')) {
489
472
  this.errorLog(
490
473
  `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
491
474
  ` Error Message: ${JSON.stringify(e.message)}`,
492
475
  );
493
476
  }
494
- if (this.platform.debugMode) {
495
- this.errorLog(
496
- `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`,
497
- );
498
- }
499
477
  this.apiError(e);
500
478
  }
501
479
  }
@@ -694,7 +672,7 @@ export class ColorBulb {
694
672
  config['offline'] = device.offline;
695
673
  }
696
674
  if (Object.entries(config).length !== 0) {
697
- 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)}`);
698
676
  }
699
677
  }
700
678
 
@@ -775,6 +753,6 @@ export class ColorBulb {
775
753
  }
776
754
 
777
755
  enablingDeviceLogging(): boolean {
778
- return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
756
+ return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
779
757
  }
780
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
  }
@@ -176,12 +176,9 @@ export class Humidifier {
176
176
  await this.pushChanges();
177
177
  } catch (e: any) {
178
178
  this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges`);
179
- if (this.deviceLogging === 'debug') {
179
+ if (this.deviceLogging.includes('debug')) {
180
180
  this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges,` + ` Error Message: ${JSON.stringify(e.message)}`);
181
181
  }
182
- if (this.platform.debugMode) {
183
- this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges,` + ` Error: ${JSON.stringify(e)}`);
184
- }
185
182
  this.apiError(e);
186
183
  }
187
184
  this.humidifierUpdateInProgress = false;
@@ -333,14 +330,11 @@ export class Humidifier {
333
330
  })
334
331
  .catch(async (e: any) => {
335
332
  this.errorLog(`Humidifier: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
336
- if (this.deviceLogging === 'debug') {
333
+ if (this.deviceLogging.includes('debug')) {
337
334
  this.errorLog(
338
335
  `Humidifier: ${this.accessory.displayName} failed refreshStatus with BLE Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
339
336
  );
340
337
  }
341
- if (this.platform.debugMode) {
342
- this.errorLog(`Humidifier: ${this.accessory.displayName} failed refreshStatus with BLE Connection,` + ` Error: ${JSON.stringify(e)}`);
343
- }
344
338
  if (this.platform.config.credentials?.openToken) {
345
339
  this.warnLog(`Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`);
346
340
  await this.openAPIRefreshStatus();
@@ -380,15 +374,12 @@ export class Humidifier {
380
374
  }
381
375
  } catch (e: any) {
382
376
  this.errorLog(`Humidifier: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
383
- if (this.deviceLogging === 'debug') {
377
+ if (this.deviceLogging.includes('debug')) {
384
378
  this.errorLog(
385
379
  `Humidifier: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` +
386
380
  ` Error Message: ${JSON.stringify(e.message)}`,
387
381
  );
388
382
  }
389
- if (this.platform.debugMode) {
390
- this.errorLog(`Humidifier: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
391
- }
392
383
  this.apiError(e);
393
384
  }
394
385
  }
@@ -432,14 +423,11 @@ export class Humidifier {
432
423
  })
433
424
  .catch(async (e: any) => {
434
425
  this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
435
- if (this.deviceLogging === 'debug') {
426
+ if (this.deviceLogging.includes('debug')) {
436
427
  this.errorLog(
437
428
  `Humidifier: ${this.accessory.displayName} failed pushChanges with BLE Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
438
429
  );
439
430
  }
440
- if (this.platform.debugMode) {
441
- this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges with BLE Connection,` + ` Error: ${JSON.stringify(e)}`);
442
- }
443
431
  if (this.platform.config.credentials?.openToken) {
444
432
  this.warnLog(`Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`);
445
433
  await this.openAPIpushChanges();
@@ -481,15 +469,12 @@ export class Humidifier {
481
469
  this.statusCode(push);
482
470
  } catch (e: any) {
483
471
  this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
484
- if (this.deviceLogging === 'debug') {
472
+ if (this.deviceLogging.includes('debug')) {
485
473
  this.errorLog(
486
474
  `Humidifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
487
475
  ` Error Message: ${JSON.stringify(e.message)}`,
488
476
  );
489
477
  }
490
- if (this.platform.debugMode) {
491
- this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
492
- }
493
478
  this.apiError(e);
494
479
  }
495
480
  } else if (
@@ -531,15 +516,12 @@ export class Humidifier {
531
516
  }
532
517
  } catch (e: any) {
533
518
  this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushAutoChanges with OpenAPI Connection`);
534
- if (this.deviceLogging === 'debug') {
519
+ if (this.deviceLogging.includes('debug')) {
535
520
  this.errorLog(
536
521
  `Humidifier: ${this.accessory.displayName} failed pushAutoChanges with OpenAPI Connection,` +
537
522
  ` Error Message: ${JSON.stringify(e.message)}`,
538
523
  );
539
524
  }
540
- if (this.platform.debugMode) {
541
- this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushAutoChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
542
- }
543
525
  this.apiError(e);
544
526
  }
545
527
  }
@@ -569,15 +551,12 @@ export class Humidifier {
569
551
  }
570
552
  } catch (e: any) {
571
553
  this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushActiveChanges with OpenAPI Connection`);
572
- if (this.deviceLogging === 'debug') {
554
+ if (this.deviceLogging.includes('debug')) {
573
555
  this.errorLog(
574
556
  `Humidifier: ${this.accessory.displayName} failed pushActiveChanges with OpenAPI Connection,` +
575
557
  ` Error Message: ${JSON.stringify(e.message)}`,
576
558
  );
577
559
  }
578
- if (this.platform.debugMode) {
579
- this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushActiveChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
580
- }
581
560
  this.apiError(e);
582
561
  }
583
562
  }
@@ -763,7 +742,7 @@ export class Humidifier {
763
742
  config['offline'] = device.offline;
764
743
  }
765
744
  if (Object.entries(config).length !== 0) {
766
- this.warnLog(`Humidifier: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
745
+ this.infoLog(`Humidifier: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
767
746
  }
768
747
  }
769
748
 
@@ -848,6 +827,6 @@ export class Humidifier {
848
827
  }
849
828
 
850
829
  enablingDeviceLogging(): boolean {
851
- return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
830
+ return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
852
831
  }
853
832
  }
@@ -98,12 +98,9 @@ export class Lock {
98
98
  await this.pushChanges();
99
99
  } catch (e: any) {
100
100
  this.errorLog(`Lock: ${this.accessory.displayName} failed pushChanges`);
101
- if (this.deviceLogging === 'debug') {
101
+ if (this.deviceLogging.includes('debug')) {
102
102
  this.errorLog(`Lock: ${this.accessory.displayName} failed pushChanges,` + ` Error Message: ${JSON.stringify(e.message)}`);
103
103
  }
104
- if (this.platform.debugMode) {
105
- this.errorLog(`Lock: ${this.accessory.displayName} failed pushChanges,` + ` Error: ${JSON.stringify(e)}`);
106
- }
107
104
  this.apiError(e);
108
105
  }
109
106
  this.lockUpdateInProgress = false;
@@ -133,14 +130,11 @@ export class Lock {
133
130
  this.updateHomeKitCharacteristics();
134
131
  } catch (e: any) {
135
132
  this.errorLog(`Lock: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
136
- if (this.deviceLogging === 'debug') {
133
+ if (this.deviceLogging.includes('debug')) {
137
134
  this.errorLog(
138
135
  `Lock: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
139
136
  );
140
137
  }
141
- if (this.platform.debugMode) {
142
- this.errorLog(`Lock: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
143
- }
144
138
  this.apiError(e);
145
139
  }
146
140
  }
@@ -264,7 +258,7 @@ export class Lock {
264
258
  config['scanDuration'] = device.scanDuration;
265
259
  }
266
260
  if (Object.entries(config).length !== 0) {
267
- this.warnLog(`Lock: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
261
+ this.infoLog(`Lock: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
268
262
  }
269
263
  }
270
264
 
@@ -340,6 +334,6 @@ export class Lock {
340
334
  }
341
335
 
342
336
  enablingDeviceLogging(): boolean {
343
- return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
337
+ return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
344
338
  }
345
339
  }
@@ -283,14 +283,11 @@ export class Meter {
283
283
  })
284
284
  .catch(async (e: any) => {
285
285
  this.errorLog(`Meter: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
286
- if (this.deviceLogging === 'debug') {
286
+ if (this.deviceLogging.includes('debug')) {
287
287
  this.errorLog(
288
288
  `Meter: ${this.accessory.displayName} failed refreshStatus with BLE Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
289
289
  );
290
290
  }
291
- if (this.platform.debugMode) {
292
- this.errorLog(`Meter: ${this.accessory.displayName} failed refreshStatus with BLE Connection,` + ` Error: ${JSON.stringify(e)}`);
293
- }
294
291
  if (this.platform.config.credentials?.openToken) {
295
292
  this.warnLog(`Meter: ${this.accessory.displayName} Using OpenAPI Connection`);
296
293
  this.SwitchToOpenAPI = true;
@@ -324,14 +321,11 @@ export class Meter {
324
321
  this.updateHomeKitCharacteristics();
325
322
  } catch (e: any) {
326
323
  this.errorLog(`Meter: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
327
- if (this.deviceLogging === 'debug') {
324
+ if (this.deviceLogging.includes('debug')) {
328
325
  this.errorLog(
329
326
  `Meter: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
330
327
  );
331
328
  }
332
- if (this.platform.debugMode) {
333
- this.errorLog(`Meter: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
334
- }
335
329
  this.apiError(e);
336
330
  }
337
331
  }
@@ -417,7 +411,7 @@ export class Meter {
417
411
  config['scanDuration'] = device.scanDuration;
418
412
  }
419
413
  if (Object.entries(config).length !== 0) {
420
- this.warnLog(`Meter: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
414
+ this.infoLog(`Meter: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
421
415
  }
422
416
  }
423
417
 
@@ -493,6 +487,6 @@ export class Meter {
493
487
  }
494
488
 
495
489
  enablingDeviceLogging(): boolean {
496
- return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
490
+ return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
497
491
  }
498
492
  }
@@ -261,15 +261,12 @@ export class Motion {
261
261
  })
262
262
  .catch(async (e: any) => {
263
263
  this.errorLog(`Motion Sensor: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
264
- if (this.deviceLogging === 'debug') {
264
+ if (this.deviceLogging.includes('debug')) {
265
265
  this.errorLog(
266
266
  `Motion Sensor: ${this.accessory.displayName} failed refreshStatus with BLE Connection,` +
267
267
  ` Error Message: ${JSON.stringify(e.message)}`,
268
268
  );
269
269
  }
270
- if (this.platform.debugMode) {
271
- this.errorLog(`Motion Sensor: ${this.accessory.displayName} failed refreshStatus with BLE Connection,` + ` Error: ${JSON.stringify(e)}`);
272
- }
273
270
  if (this.platform.config.credentials?.openToken) {
274
271
  this.warnLog(`Motion Sensor: ${this.accessory.displayName} Using OpenAPI Connection`);
275
272
  this.SwitchToOpenAPI = true;
@@ -306,17 +303,12 @@ export class Motion {
306
303
  this.updateHomeKitCharacteristics();
307
304
  } catch (e: any) {
308
305
  this.errorLog(`Motion Sensor: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
309
- if (this.deviceLogging === 'debug') {
306
+ if (this.deviceLogging.includes('debug')) {
310
307
  this.errorLog(
311
308
  `Motion Sensor: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` +
312
309
  ` Error Message: ${JSON.stringify(e.message)}`,
313
310
  );
314
311
  }
315
- if (this.platform.debugMode) {
316
- this.errorLog(
317
- `Motion Sensor: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`,
318
- );
319
- }
320
312
  this.apiError(e);
321
313
  }
322
314
  }
@@ -387,7 +379,7 @@ export class Motion {
387
379
  config['offline'] = device.offline;
388
380
  }
389
381
  if (Object.entries(config).length !== 0) {
390
- this.warnLog(`Motion Sensor: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
382
+ this.infoLog(`Motion Sensor: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
391
383
  }
392
384
  }
393
385
 
@@ -481,6 +473,6 @@ export class Motion {
481
473
  }
482
474
 
483
475
  enablingDeviceLogging(): boolean {
484
- return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
476
+ return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
485
477
  }
486
478
  }
@@ -95,12 +95,9 @@ export class Plug {
95
95
  await this.pushChanges();
96
96
  } catch (e: any) {
97
97
  this.errorLog(`Plug: ${this.accessory.displayName} failed pushChanges`);
98
- if (this.deviceLogging === 'debug') {
98
+ if (this.deviceLogging.includes('debug')) {
99
99
  this.errorLog(`Plug: ${this.accessory.displayName} failed pushChanges,` + ` Error Message: ${JSON.stringify(e.message)}`);
100
100
  }
101
- if (this.platform.debugMode) {
102
- this.errorLog(`Plug: ${this.accessory.displayName} failed pushChanges,` + ` Error: ${JSON.stringify(e)}`);
103
- }
104
101
  this.apiError(e);
105
102
  }
106
103
  this.plugUpdateInProgress = false;
@@ -127,14 +124,11 @@ export class Plug {
127
124
  this.updateHomeKitCharacteristics();
128
125
  } catch (e: any) {
129
126
  this.errorLog(`Plug: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
130
- if (this.deviceLogging === 'debug') {
127
+ if (this.deviceLogging.includes('debug')) {
131
128
  this.errorLog(
132
129
  `Plug: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
133
130
  );
134
131
  }
135
- if (this.platform.debugMode) {
136
- this.errorLog(`Plug: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
137
- }
138
132
  this.apiError(e);
139
133
  }
140
134
  }
@@ -278,7 +272,7 @@ export class Plug {
278
272
  config['offline'] = device.offline;
279
273
  }
280
274
  if (Object.entries(config).length !== 0) {
281
- this.warnLog(`Plug: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
275
+ this.infoLog(`Plug: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
282
276
  }
283
277
  }
284
278
 
@@ -354,6 +348,6 @@ export class Plug {
354
348
  }
355
349
 
356
350
  enablingDeviceLogging(): boolean {
357
- return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
351
+ return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
358
352
  }
359
353
  }