@switchbot/homebridge-switchbot 2.8.0-beta.0 → 2.8.0-beta.10

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 (139) hide show
  1. package/.prettierrc +1 -1
  2. package/.vscode/settings.json +1 -1
  3. package/CHANGELOG.md +10 -0
  4. package/config.schema.json +8 -0
  5. package/dist/device/blindtilt.d.ts +1 -0
  6. package/dist/device/blindtilt.d.ts.map +1 -1
  7. package/dist/device/blindtilt.js +58 -65
  8. package/dist/device/blindtilt.js.map +1 -1
  9. package/dist/device/bot.d.ts +1 -0
  10. package/dist/device/bot.d.ts.map +1 -1
  11. package/dist/device/bot.js +52 -55
  12. package/dist/device/bot.js.map +1 -1
  13. package/dist/device/ceilinglight.d.ts +1 -0
  14. package/dist/device/ceilinglight.d.ts.map +1 -1
  15. package/dist/device/ceilinglight.js +68 -68
  16. package/dist/device/ceilinglight.js.map +1 -1
  17. package/dist/device/colorbulb.d.ts +1 -0
  18. package/dist/device/colorbulb.d.ts.map +1 -1
  19. package/dist/device/colorbulb.js +76 -75
  20. package/dist/device/colorbulb.js.map +1 -1
  21. package/dist/device/contact.d.ts +2 -0
  22. package/dist/device/contact.d.ts.map +1 -1
  23. package/dist/device/contact.js +67 -59
  24. package/dist/device/contact.js.map +1 -1
  25. package/dist/device/curtain.d.ts +2 -0
  26. package/dist/device/curtain.d.ts.map +1 -1
  27. package/dist/device/curtain.js +81 -94
  28. package/dist/device/curtain.js.map +1 -1
  29. package/dist/device/hub.d.ts +9 -1
  30. package/dist/device/hub.d.ts.map +1 -1
  31. package/dist/device/hub.js +197 -30
  32. package/dist/device/hub.js.map +1 -1
  33. package/dist/device/humidifier.d.ts.map +1 -1
  34. package/dist/device/humidifier.js +58 -62
  35. package/dist/device/humidifier.js.map +1 -1
  36. package/dist/device/iosensor.d.ts +1 -0
  37. package/dist/device/iosensor.d.ts.map +1 -1
  38. package/dist/device/iosensor.js +28 -26
  39. package/dist/device/iosensor.js.map +1 -1
  40. package/dist/device/lightstrip.d.ts +1 -0
  41. package/dist/device/lightstrip.d.ts.map +1 -1
  42. package/dist/device/lightstrip.js +68 -67
  43. package/dist/device/lightstrip.js.map +1 -1
  44. package/dist/device/lock.d.ts +2 -0
  45. package/dist/device/lock.d.ts.map +1 -1
  46. package/dist/device/lock.js +51 -47
  47. package/dist/device/lock.js.map +1 -1
  48. package/dist/device/meter.d.ts +5 -3
  49. package/dist/device/meter.d.ts.map +1 -1
  50. package/dist/device/meter.js +75 -74
  51. package/dist/device/meter.js.map +1 -1
  52. package/dist/device/meterplus.d.ts +4 -3
  53. package/dist/device/meterplus.d.ts.map +1 -1
  54. package/dist/device/meterplus.js +74 -74
  55. package/dist/device/meterplus.js.map +1 -1
  56. package/dist/device/motion.d.ts +2 -0
  57. package/dist/device/motion.d.ts.map +1 -1
  58. package/dist/device/motion.js +66 -54
  59. package/dist/device/motion.js.map +1 -1
  60. package/dist/device/plug.d.ts +1 -0
  61. package/dist/device/plug.d.ts.map +1 -1
  62. package/dist/device/plug.js +39 -39
  63. package/dist/device/plug.js.map +1 -1
  64. package/dist/device/robotvacuumcleaner.d.ts +1 -0
  65. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  66. package/dist/device/robotvacuumcleaner.js +74 -53
  67. package/dist/device/robotvacuumcleaner.js.map +1 -1
  68. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  69. package/dist/irdevice/airconditioner.js +64 -66
  70. package/dist/irdevice/airconditioner.js.map +1 -1
  71. package/dist/irdevice/airpurifier.d.ts +1 -1
  72. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  73. package/dist/irdevice/airpurifier.js +32 -34
  74. package/dist/irdevice/airpurifier.js.map +1 -1
  75. package/dist/irdevice/camera.d.ts +1 -1
  76. package/dist/irdevice/camera.d.ts.map +1 -1
  77. package/dist/irdevice/camera.js +20 -23
  78. package/dist/irdevice/camera.js.map +1 -1
  79. package/dist/irdevice/fan.d.ts +2 -2
  80. package/dist/irdevice/fan.d.ts.map +1 -1
  81. package/dist/irdevice/fan.js +30 -32
  82. package/dist/irdevice/fan.js.map +1 -1
  83. package/dist/irdevice/light.d.ts +1 -1
  84. package/dist/irdevice/light.d.ts.map +1 -1
  85. package/dist/irdevice/light.js +26 -29
  86. package/dist/irdevice/light.js.map +1 -1
  87. package/dist/irdevice/other.d.ts +1 -1
  88. package/dist/irdevice/other.d.ts.map +1 -1
  89. package/dist/irdevice/other.js +22 -23
  90. package/dist/irdevice/other.js.map +1 -1
  91. package/dist/irdevice/tv.d.ts +2 -2
  92. package/dist/irdevice/tv.d.ts.map +1 -1
  93. package/dist/irdevice/tv.js +47 -50
  94. package/dist/irdevice/tv.js.map +1 -1
  95. package/dist/irdevice/vacuumcleaner.d.ts +1 -1
  96. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  97. package/dist/irdevice/vacuumcleaner.js +20 -23
  98. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  99. package/dist/irdevice/waterheater.d.ts +1 -1
  100. package/dist/irdevice/waterheater.d.ts.map +1 -1
  101. package/dist/irdevice/waterheater.js +22 -23
  102. package/dist/irdevice/waterheater.js.map +1 -1
  103. package/dist/platform.d.ts.map +1 -1
  104. package/dist/platform.js +46 -44
  105. package/dist/platform.js.map +1 -1
  106. package/dist/settings.d.ts +1 -0
  107. package/dist/settings.d.ts.map +1 -1
  108. package/dist/settings.js.map +1 -1
  109. package/dist/utils.js +1 -1
  110. package/dist/utils.js.map +1 -1
  111. package/package.json +3 -3
  112. package/src/device/blindtilt.ts +114 -78
  113. package/src/device/bot.ts +102 -63
  114. package/src/device/ceilinglight.ts +113 -73
  115. package/src/device/colorbulb.ts +144 -87
  116. package/src/device/contact.ts +98 -63
  117. package/src/device/curtain.ts +160 -134
  118. package/src/device/hub.ts +228 -39
  119. package/src/device/humidifier.ts +136 -85
  120. package/src/device/iosensor.ts +52 -32
  121. package/src/device/lightstrip.ts +118 -72
  122. package/src/device/lock.ts +85 -50
  123. package/src/device/meter.ts +104 -80
  124. package/src/device/meterplus.ts +103 -80
  125. package/src/device/motion.ts +95 -59
  126. package/src/device/plug.ts +70 -44
  127. package/src/device/robotvacuumcleaner.ts +107 -56
  128. package/src/irdevice/airconditioner.ts +116 -86
  129. package/src/irdevice/airpurifier.ts +60 -39
  130. package/src/irdevice/camera.ts +40 -28
  131. package/src/irdevice/fan.ts +52 -38
  132. package/src/irdevice/light.ts +48 -34
  133. package/src/irdevice/other.ts +44 -28
  134. package/src/irdevice/tv.ts +70 -56
  135. package/src/irdevice/vacuumcleaner.ts +40 -28
  136. package/src/irdevice/waterheater.ts +48 -32
  137. package/src/platform.ts +87 -56
  138. package/src/settings.ts +41 -40
  139. package/src/utils.ts +1 -1
package/src/device/bot.ts CHANGED
@@ -32,6 +32,7 @@ export class Bot {
32
32
  StatusLowBattery!: CharacteristicValue;
33
33
 
34
34
  // OpenAPI Others
35
+ Version: deviceStatus['version'];
35
36
  power: deviceStatus['power'];
36
37
  deviceStatus!: any; //deviceStatusResponse;
37
38
 
@@ -60,19 +61,23 @@ export class Bot {
60
61
  doBotUpdate!: Subject<void>;
61
62
 
62
63
  // Connection
63
- private readonly BLE = (this.device.connectionType === 'BLE' || this.device.connectionType === 'BLE/OpenAPI');
64
- private readonly OpenAPI = (this.device.connectionType === 'OpenAPI' || this.device.connectionType === 'BLE/OpenAPI');
65
-
66
- constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: device & devicesConfig) {
64
+ private readonly BLE = this.device.connectionType === 'BLE' || this.device.connectionType === 'BLE/OpenAPI';
65
+ private readonly OpenAPI = this.device.connectionType === 'OpenAPI' || this.device.connectionType === 'BLE/OpenAPI';
66
+
67
+ constructor(
68
+ private readonly platform: SwitchBotPlatform,
69
+ private accessory: PlatformAccessory,
70
+ public device: device & devicesConfig,
71
+ ) {
67
72
  // default placeholders
68
73
  this.logs(device);
69
74
  this.scan(device);
70
75
  this.refreshRate(device);
71
76
  this.PressOrSwitch(device);
72
77
  this.allowPushChanges(device);
73
- this.config(device);
74
78
  this.context();
75
79
  this.DoublePress(device);
80
+ this.config(device);
76
81
 
77
82
  this.multiPressCount = 0;
78
83
 
@@ -111,7 +116,6 @@ export class Bot {
111
116
  `${accessory.displayName} Switch`;
112
117
  this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Switch`);
113
118
 
114
-
115
119
  this.switchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
116
120
  if (!this.switchService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
117
121
  this.switchService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
@@ -392,8 +396,10 @@ export class Bot {
392
396
  }
393
397
  } catch (e: any) {
394
398
  this.apiError(e);
395
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType} Connection,`
396
- + ` Error Message: ${JSON.stringify(e.message)}`);
399
+ this.errorLog(
400
+ `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType} Connection,` +
401
+ ` Error Message: ${JSON.stringify(e.message)}`,
402
+ );
397
403
  }
398
404
  this.botUpdateInProgress = false;
399
405
  });
@@ -411,8 +417,9 @@ export class Bot {
411
417
  await this.openAPIparseStatus();
412
418
  } else {
413
419
  await this.offlineOff();
414
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
415
- + ` ${this.device.connectionType}, parseStatus will not happen.`);
420
+ this.debugWarnLog(
421
+ `${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` + ` ${this.device.connectionType}, parseStatus will not happen.`,
422
+ );
416
423
  }
417
424
  }
418
425
 
@@ -469,8 +476,10 @@ export class Bot {
469
476
  await this.openAPIRefreshStatus();
470
477
  } else {
471
478
  await this.offlineOff();
472
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
473
- + ` ${this.device.connectionType}, refreshStatus will not happen.`);
479
+ this.debugWarnLog(
480
+ `${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` +
481
+ ` ${this.device.connectionType}, refreshStatus will not happen.`,
482
+ );
474
483
  }
475
484
  }
476
485
 
@@ -495,15 +504,19 @@ export class Bot {
495
504
  // Set an event hander
496
505
  switchbot.onadvertisement = async (ad: ad) => {
497
506
  this.address = ad.address;
498
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},`
499
- + ` BLE Address Found: ${this.address}`);
507
+ this.debugLog(
508
+ `${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
509
+ ` BLE Address Found: ${this.address}`,
510
+ );
500
511
  this.serviceData = ad.serviceData;
501
512
  this.mode = ad.serviceData.mode;
502
513
  this.state = ad.serviceData.state;
503
514
  this.battery = ad.serviceData.battery;
504
515
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
505
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}, model: ${ad.serviceData.model}, modelName: `
506
- + `${ad.serviceData.modelName}, mode: ${ad.serviceData.mode}, state: ${ad.serviceData.state}, battery: ${ad.serviceData.battery}`);
516
+ this.debugLog(
517
+ `${this.device.deviceType}: ${this.accessory.displayName}, model: ${ad.serviceData.model}, modelName: ` +
518
+ `${ad.serviceData.modelName}, mode: ${ad.serviceData.mode}, state: ${ad.serviceData.state}, battery: ${ad.serviceData.battery}`,
519
+ );
507
520
 
508
521
  if (this.serviceData) {
509
522
  this.connected = true;
@@ -523,8 +536,10 @@ export class Bot {
523
536
  })
524
537
  .catch(async (e: any) => {
525
538
  this.apiError(e);
526
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed BLERefreshStatus with ${this.device.connectionType}`
527
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
539
+ this.errorLog(
540
+ `${this.device.deviceType}: ${this.accessory.displayName} failed BLERefreshStatus with ${this.device.connectionType}` +
541
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
542
+ );
528
543
  await this.BLERefreshConnection(switchbot);
529
544
  });
530
545
  } else {
@@ -542,17 +557,16 @@ export class Bot {
542
557
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
543
558
  this.statusCode(statusCode);
544
559
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
545
- this.debugLog(
546
- `${this.device.deviceType}: ${this.accessory.displayName
547
- } refreshStatus: ${JSON.stringify(deviceStatus)}`,
548
- );
560
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
549
561
  this.power = deviceStatus.body.power;
550
562
  this.openAPIparseStatus();
551
563
  this.updateHomeKitCharacteristics();
552
564
  } catch (e: any) {
553
565
  this.apiError(e);
554
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}`
555
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
566
+ this.errorLog(
567
+ `${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}` +
568
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
569
+ );
556
570
  }
557
571
  }
558
572
 
@@ -572,8 +586,9 @@ export class Bot {
572
586
  await this.openAPIpushChanges();
573
587
  } else {
574
588
  await this.offlineOff();
575
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
576
- + ` ${this.device.connectionType}, pushChanges will not happen.`);
589
+ this.debugWarnLog(
590
+ `${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` + ` ${this.device.connectionType}, pushChanges will not happen.`,
591
+ );
577
592
  }
578
593
  // Refresh the status from the API
579
594
  interval(15000)
@@ -618,8 +633,10 @@ export class Bot {
618
633
  })
619
634
  .catch(async (e: any) => {
620
635
  this.apiError(e);
621
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed BLEpushChanges with ${this.device.connectionType}`
622
- + ` Connection & botMode: ${this.botMode}, Error Message: ${JSON.stringify(e.message)}`);
636
+ this.errorLog(
637
+ `${this.device.deviceType}: ${this.accessory.displayName} failed BLEpushChanges with ${this.device.connectionType}` +
638
+ ` Connection & botMode: ${this.botMode}, Error Message: ${JSON.stringify(e.message)}`,
639
+ );
623
640
  await this.BLEPushConnection();
624
641
  });
625
642
  } else if (this.botMode === 'switch') {
@@ -645,16 +662,19 @@ export class Bot {
645
662
  })
646
663
  .catch(async (e: any) => {
647
664
  this.apiError(e);
648
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed BLEpushChanges with ${this.device.connectionType}`
649
- + ` Connection & botMode: ${this.botMode}, Error Message: ${JSON.stringify(e.message)}`);
665
+ this.errorLog(
666
+ `${this.device.deviceType}: ${this.accessory.displayName} failed BLEpushChanges with ${this.device.connectionType}` +
667
+ ` Connection & botMode: ${this.botMode}, Error Message: ${JSON.stringify(e.message)}`,
668
+ );
650
669
  await this.BLEPushConnection();
651
670
  });
652
671
  } else {
653
672
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
654
673
  }
655
674
  } else {
656
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No BLEpushChanges.` + `On: ${this.On}, `
657
- + `OnCached: ${this.accessory.context.On}`);
675
+ this.debugLog(
676
+ `${this.device.deviceType}: ${this.accessory.displayName} No BLEpushChanges.` + `On: ${this.On}, ` + `OnCached: ${this.accessory.context.On}`,
677
+ );
658
678
  }
659
679
  }
660
680
 
@@ -664,7 +684,7 @@ export class Bot {
664
684
  this.debugLog(`${this.device.deviceType}: ${this.multiPressCount} request(s) queued.`);
665
685
  this.On = true;
666
686
  }
667
- if ((this.On !== this.accessory.context.On || this.allowPush) || this.multiPressCount > 0) {
687
+ if (this.On !== this.accessory.context.On || this.allowPush || this.multiPressCount > 0) {
668
688
  let command = '';
669
689
  if (this.botMode === 'switch' && this.On) {
670
690
  command = 'turnOn';
@@ -682,9 +702,9 @@ export class Bot {
682
702
  throw new Error(`${this.device.deviceType}: ${this.accessory.displayName} Device Paramters not set for this Bot.`);
683
703
  }
684
704
  const bodyChange = JSON.stringify({
685
- 'command': `${command}`,
686
- 'parameter': 'default',
687
- 'commandType': 'command',
705
+ command: `${command}`,
706
+ parameter: 'default',
707
+ commandType: 'command',
688
708
  });
689
709
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
690
710
  try {
@@ -707,13 +727,17 @@ export class Bot {
707
727
  }
708
728
  } catch (e: any) {
709
729
  this.apiError(e);
710
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIpushChanges with ${this.device.connectionType}`
711
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`,
730
+ this.errorLog(
731
+ `${this.device.deviceType}: ${this.accessory.displayName} failed openAPIpushChanges with ${this.device.connectionType}` +
732
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
712
733
  );
713
734
  }
714
735
  } else {
715
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No openAPIpushChanges.` + `On: ${this.On}, `
716
- + `OnCached: ${this.accessory.context.On}`);
736
+ this.debugLog(
737
+ `${this.device.deviceType}: ${this.accessory.displayName} No openAPIpushChanges.` +
738
+ `On: ${this.On}, ` +
739
+ `OnCached: ${this.accessory.context.On}`,
740
+ );
717
741
  }
718
742
  }
719
743
 
@@ -767,7 +791,6 @@ export class Bot {
767
791
  this.multiPressCount++;
768
792
  this.debugLog(`${this.device.deviceType} set to Multi-Press. Multi-Press count: ${this.multiPressCount}`);
769
793
  }
770
-
771
794
  }
772
795
  this.On = value;
773
796
  }
@@ -791,8 +814,9 @@ export class Bot {
791
814
  this.platform.Characteristic.CurrentDoorState,
792
815
  this.platform.Characteristic.CurrentDoorState.OPEN,
793
816
  );
794
- this.debugLog(`${this.device.deviceType}: `
795
- + `${this.accessory.displayName} updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open`);
817
+ this.debugLog(
818
+ `${this.device.deviceType}: ` + `${this.accessory.displayName} updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open`,
819
+ );
796
820
  } else {
797
821
  this.garageDoorService?.updateCharacteristic(
798
822
  this.platform.Characteristic.TargetDoorState,
@@ -802,8 +826,9 @@ export class Bot {
802
826
  this.platform.Characteristic.CurrentDoorState,
803
827
  this.platform.Characteristic.CurrentDoorState.CLOSED,
804
828
  );
805
- this.debugLog(`${this.device.deviceType}: `
806
- + `${this.accessory.displayName} updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open`);
829
+ this.debugLog(
830
+ `${this.device.deviceType}: ` + `${this.accessory.displayName} updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open`,
831
+ );
807
832
  }
808
833
  }
809
834
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Garage Door On: ${this.On}`);
@@ -877,16 +902,19 @@ export class Bot {
877
902
  this.platform.Characteristic.LockCurrentState,
878
903
  this.platform.Characteristic.LockCurrentState.UNSECURED,
879
904
  );
880
- this.debugLog(`${this.device.deviceType}: `
881
- + `${this.accessory.displayName} updateCharacteristic LockTargetState: UNSECURED, LockCurrentState: UNSECURED`);
905
+ this.debugLog(
906
+ `${this.device.deviceType}: ` +
907
+ `${this.accessory.displayName} updateCharacteristic LockTargetState: UNSECURED, LockCurrentState: UNSECURED`,
908
+ );
882
909
  } else {
883
910
  this.lockService?.updateCharacteristic(this.platform.Characteristic.LockTargetState, this.platform.Characteristic.LockTargetState.SECURED);
884
911
  this.lockService?.updateCharacteristic(
885
912
  this.platform.Characteristic.LockCurrentState,
886
913
  this.platform.Characteristic.LockCurrentState.SECURED,
887
914
  );
888
- this.debugLog(`${this.device.deviceType}: `
889
- + `${this.accessory.displayName} updateCharacteristic LockTargetState: SECURED, LockCurrentState: SECURED`);
915
+ this.debugLog(
916
+ `${this.device.deviceType}: ` + `${this.accessory.displayName} updateCharacteristic LockTargetState: SECURED, LockCurrentState: SECURED`,
917
+ );
890
918
  }
891
919
  }
892
920
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Lock On: ${this.On}`);
@@ -926,16 +954,20 @@ export class Bot {
926
954
  this.platform.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS,
927
955
  );
928
956
  this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState, 1);
929
- this.debugLog(`${this.device.deviceType}: `
930
- + `${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 1`);
957
+ this.debugLog(
958
+ `${this.device.deviceType}: ` +
959
+ `${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 1`,
960
+ );
931
961
  } else {
932
962
  this.statefulProgrammableSwitchService?.updateCharacteristic(
933
963
  this.platform.Characteristic.ProgrammableSwitchEvent,
934
964
  this.platform.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS,
935
965
  );
936
966
  this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState, 0);
937
- this.debugLog(`${this.device.deviceType}: `
938
- + `${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 0`);
967
+ this.debugLog(
968
+ `${this.device.deviceType}: ` +
969
+ `${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 0`,
970
+ );
939
971
  }
940
972
  }
941
973
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatefulProgrammableSwitch On: ${this.On}`);
@@ -1193,8 +1225,10 @@ export class Bot {
1193
1225
  this.offlineOff();
1194
1226
  break;
1195
1227
  case 171:
1196
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. `
1197
- + `Hub: ${this.device.hubDeviceId}`);
1228
+ this.errorLog(
1229
+ `${this.device.deviceType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
1230
+ `Hub: ${this.device.hubDeviceId}`,
1231
+ );
1198
1232
  this.offlineOff();
1199
1233
  break;
1200
1234
  case 190:
@@ -1210,8 +1244,10 @@ export class Bot {
1210
1244
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
1211
1245
  break;
1212
1246
  default:
1213
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode: `
1214
- + `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
1247
+ this.infoLog(
1248
+ `${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode: ` +
1249
+ `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
1250
+ );
1215
1251
  }
1216
1252
  }
1217
1253
 
@@ -1262,14 +1298,17 @@ export class Bot {
1262
1298
 
1263
1299
  FirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
1264
1300
  let FirmwareRevision: string;
1265
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
1266
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
1301
+ this.debugLog(
1302
+ `${this.device.deviceType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
1303
+ );
1267
1304
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
1268
1305
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
1269
- if (accessory.context.FirmwareRevision) {
1270
- FirmwareRevision = accessory.context.FirmwareRevision;
1271
- } else if (device.firmware) {
1306
+ if (device.firmware) {
1272
1307
  FirmwareRevision = device.firmware;
1308
+ } else if (device.version) {
1309
+ FirmwareRevision = JSON.stringify(device.version);
1310
+ } if (accessory.context.FirmwareRevision) {
1311
+ FirmwareRevision = accessory.context.FirmwareRevision;
1273
1312
  } else {
1274
1313
  FirmwareRevision = this.platform.version;
1275
1314
  }
@@ -1341,7 +1380,7 @@ export class Bot {
1341
1380
  config['maxRetry'] = device.maxRetry;
1342
1381
  }
1343
1382
  if (Object.entries(config).length !== 0) {
1344
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
1383
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
1345
1384
  }
1346
1385
  }
1347
1386