@switchbot/homebridge-switchbot 3.3.1-beta.3 → 3.3.1-beta.4

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 (126) hide show
  1. package/dist/device/blindtilt.d.ts +1 -1
  2. package/dist/device/blindtilt.d.ts.map +1 -1
  3. package/dist/device/blindtilt.js +3 -3
  4. package/dist/device/blindtilt.js.map +1 -1
  5. package/dist/device/bot.d.ts +1 -1
  6. package/dist/device/bot.d.ts.map +1 -1
  7. package/dist/device/bot.js +3 -3
  8. package/dist/device/bot.js.map +1 -1
  9. package/dist/device/ceilinglight.d.ts +1 -1
  10. package/dist/device/ceilinglight.d.ts.map +1 -1
  11. package/dist/device/ceilinglight.js +3 -3
  12. package/dist/device/ceilinglight.js.map +1 -1
  13. package/dist/device/contact.d.ts +1 -1
  14. package/dist/device/contact.d.ts.map +1 -1
  15. package/dist/device/contact.js +3 -3
  16. package/dist/device/contact.js.map +1 -1
  17. package/dist/device/curtain.d.ts +1 -1
  18. package/dist/device/curtain.d.ts.map +1 -1
  19. package/dist/device/curtain.js +3 -3
  20. package/dist/device/curtain.js.map +1 -1
  21. package/dist/device/hub.d.ts +1 -1
  22. package/dist/device/hub.d.ts.map +1 -1
  23. package/dist/device/hub.js +3 -3
  24. package/dist/device/hub.js.map +1 -1
  25. package/dist/device/humidifier.d.ts +1 -1
  26. package/dist/device/humidifier.d.ts.map +1 -1
  27. package/dist/device/humidifier.js +3 -3
  28. package/dist/device/humidifier.js.map +1 -1
  29. package/dist/device/iosensor.d.ts +1 -1
  30. package/dist/device/iosensor.d.ts.map +1 -1
  31. package/dist/device/iosensor.js +3 -3
  32. package/dist/device/iosensor.js.map +1 -1
  33. package/dist/device/lightstrip.d.ts +1 -1
  34. package/dist/device/lightstrip.d.ts.map +1 -1
  35. package/dist/device/lightstrip.js +3 -3
  36. package/dist/device/lightstrip.js.map +1 -1
  37. package/dist/device/lock.d.ts +1 -1
  38. package/dist/device/lock.d.ts.map +1 -1
  39. package/dist/device/lock.js +3 -3
  40. package/dist/device/lock.js.map +1 -1
  41. package/dist/device/meter.d.ts +1 -1
  42. package/dist/device/meter.d.ts.map +1 -1
  43. package/dist/device/meter.js +3 -3
  44. package/dist/device/meter.js.map +1 -1
  45. package/dist/device/meterplus.d.ts +1 -1
  46. package/dist/device/meterplus.d.ts.map +1 -1
  47. package/dist/device/meterplus.js +3 -3
  48. package/dist/device/meterplus.js.map +1 -1
  49. package/dist/device/motion.d.ts +1 -1
  50. package/dist/device/motion.d.ts.map +1 -1
  51. package/dist/device/motion.js +7 -3
  52. package/dist/device/motion.js.map +1 -1
  53. package/dist/device/plug.d.ts +1 -1
  54. package/dist/device/plug.d.ts.map +1 -1
  55. package/dist/device/plug.js +7 -3
  56. package/dist/device/plug.js.map +1 -1
  57. package/dist/device/robotvacuumcleaner.d.ts +1 -1
  58. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  59. package/dist/device/robotvacuumcleaner.js +7 -3
  60. package/dist/device/robotvacuumcleaner.js.map +1 -1
  61. package/dist/irdevice/airconditioner.d.ts +1 -1
  62. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  63. package/dist/irdevice/airconditioner.js +5 -5
  64. package/dist/irdevice/airconditioner.js.map +1 -1
  65. package/dist/irdevice/airpurifier.d.ts +1 -1
  66. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  67. package/dist/irdevice/airpurifier.js +2 -2
  68. package/dist/irdevice/airpurifier.js.map +1 -1
  69. package/dist/irdevice/camera.d.ts +1 -1
  70. package/dist/irdevice/camera.d.ts.map +1 -1
  71. package/dist/irdevice/camera.js +2 -2
  72. package/dist/irdevice/camera.js.map +1 -1
  73. package/dist/irdevice/fan.d.ts +1 -1
  74. package/dist/irdevice/fan.d.ts.map +1 -1
  75. package/dist/irdevice/fan.js +2 -2
  76. package/dist/irdevice/fan.js.map +1 -1
  77. package/dist/irdevice/light.d.ts +1 -1
  78. package/dist/irdevice/light.d.ts.map +1 -1
  79. package/dist/irdevice/light.js +2 -2
  80. package/dist/irdevice/light.js.map +1 -1
  81. package/dist/irdevice/other.d.ts +1 -1
  82. package/dist/irdevice/other.d.ts.map +1 -1
  83. package/dist/irdevice/other.js +2 -2
  84. package/dist/irdevice/other.js.map +1 -1
  85. package/dist/irdevice/tv.d.ts +1 -1
  86. package/dist/irdevice/tv.d.ts.map +1 -1
  87. package/dist/irdevice/tv.js +2 -2
  88. package/dist/irdevice/tv.js.map +1 -1
  89. package/dist/irdevice/vacuumcleaner.d.ts +1 -1
  90. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  91. package/dist/irdevice/vacuumcleaner.js +2 -2
  92. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  93. package/dist/irdevice/waterheater.d.ts +1 -1
  94. package/dist/irdevice/waterheater.d.ts.map +1 -1
  95. package/dist/irdevice/waterheater.js +2 -2
  96. package/dist/irdevice/waterheater.js.map +1 -1
  97. package/dist/platform.d.ts +5 -2
  98. package/dist/platform.d.ts.map +1 -1
  99. package/dist/platform.js +30 -3
  100. package/dist/platform.js.map +1 -1
  101. package/package.json +1 -1
  102. package/src/device/blindtilt.ts +3 -3
  103. package/src/device/bot.ts +3 -3
  104. package/src/device/ceilinglight.ts +3 -3
  105. package/src/device/contact.ts +3 -3
  106. package/src/device/curtain.ts +3 -3
  107. package/src/device/hub.ts +3 -3
  108. package/src/device/humidifier.ts +3 -3
  109. package/src/device/iosensor.ts +3 -3
  110. package/src/device/lightstrip.ts +3 -3
  111. package/src/device/lock.ts +3 -3
  112. package/src/device/meter.ts +3 -3
  113. package/src/device/meterplus.ts +3 -3
  114. package/src/device/motion.ts +7 -3
  115. package/src/device/plug.ts +7 -3
  116. package/src/device/robotvacuumcleaner.ts +7 -3
  117. package/src/irdevice/airconditioner.ts +5 -5
  118. package/src/irdevice/airpurifier.ts +2 -2
  119. package/src/irdevice/camera.ts +2 -2
  120. package/src/irdevice/fan.ts +2 -2
  121. package/src/irdevice/light.ts +2 -2
  122. package/src/irdevice/other.ts +2 -2
  123. package/src/irdevice/tv.ts +2 -2
  124. package/src/irdevice/vacuumcleaner.ts +2 -2
  125. package/src/irdevice/waterheater.ts +2 -2
  126. package/src/platform.ts +39 -4
@@ -97,7 +97,7 @@ export class Curtain {
97
97
  this.refreshRate(device);
98
98
  this.scan(device);
99
99
  this.setupMqtt(device);
100
- this.context();
100
+ this.deviceContext();
101
101
  this.deviceConfig(device);
102
102
 
103
103
  // this is subject we use to track when we need to POST changes to the SwitchBot API
@@ -1219,7 +1219,7 @@ export class Curtain {
1219
1219
 
1220
1220
  async offlineOff(): Promise<void> {
1221
1221
  if (this.device.offline) {
1222
- await this.context();
1222
+ await this.deviceContext();
1223
1223
  await this.updateHomeKitCharacteristics();
1224
1224
  }
1225
1225
  }
@@ -1236,7 +1236,7 @@ export class Curtain {
1236
1236
  //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
1237
1237
  }
1238
1238
 
1239
- async context() {
1239
+ async deviceContext() {
1240
1240
  if (this.accessory.context.CurrentPosition === undefined) {
1241
1241
  this.CurrentPosition = 0;
1242
1242
  } else {
package/src/device/hub.ts CHANGED
@@ -66,7 +66,7 @@ export class Hub {
66
66
  // default placeholders
67
67
  this.deviceLogs(device);
68
68
  this.refreshRate(device);
69
- this.context();
69
+ this.deviceContext();
70
70
  this.setupHistoryService(device);
71
71
  this.setupMqtt(device);
72
72
  this.deviceConfig(device);
@@ -666,7 +666,7 @@ export class Hub {
666
666
 
667
667
  async offlineOff(): Promise<void> {
668
668
  if (this.device.offline) {
669
- await this.context();
669
+ await this.deviceContext();
670
670
  await this.updateHomeKitCharacteristics();
671
671
  }
672
672
  }
@@ -701,7 +701,7 @@ export class Hub {
701
701
  return this.set_maxLux;
702
702
  }
703
703
 
704
- async context() {
704
+ async deviceContext() {
705
705
  if (this.CurrentRelativeHumidity === undefined) {
706
706
  this.CurrentRelativeHumidity = 0;
707
707
  } else {
@@ -75,7 +75,7 @@ export class Humidifier {
75
75
  this.deviceLogs(device);
76
76
  this.scan(device);
77
77
  this.refreshRate(device);
78
- this.context();
78
+ this.deviceContext();
79
79
  this.deviceConfig(device);
80
80
 
81
81
  // this is subject we use to track when we need to POST changes to the SwitchBot API
@@ -937,7 +937,7 @@ export class Humidifier {
937
937
  async offlineOff(): Promise<void> {
938
938
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} offline: ${this.device.offline}`);
939
939
  if (this.device.offline) {
940
- await this.context();
940
+ await this.deviceContext();
941
941
  if (this.CurrentTemperature === undefined) {
942
942
  this.CurrentTemperature = 0;
943
943
  }
@@ -959,7 +959,7 @@ export class Humidifier {
959
959
  }
960
960
  }
961
961
 
962
- async context() {
962
+ async deviceContext() {
963
963
  if (this.Active === undefined) {
964
964
  this.Active = this.hap.Characteristic.Active.ACTIVE;
965
965
  } else {
@@ -82,7 +82,7 @@ export class IOSensor {
82
82
  this.deviceLogs(device);
83
83
  this.scan(device);
84
84
  this.refreshRate(device);
85
- this.context();
85
+ this.deviceContext();
86
86
  this.setupHistoryService(device);
87
87
  this.setupMqtt(device);
88
88
  this.deviceConfig(device);
@@ -689,7 +689,7 @@ export class IOSensor {
689
689
 
690
690
  async offlineOff(): Promise<void> {
691
691
  if (this.device.offline) {
692
- await this.context();
692
+ await this.deviceContext();
693
693
  await this.updateHomeKitCharacteristics();
694
694
  }
695
695
  }
@@ -705,7 +705,7 @@ export class IOSensor {
705
705
  this.batteryService?.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, e);
706
706
  }
707
707
 
708
- async context() {
708
+ async deviceContext() {
709
709
  if (this.CurrentRelativeHumidity === undefined) {
710
710
  this.CurrentRelativeHumidity = 0;
711
711
  } else {
@@ -82,7 +82,7 @@ export class StripLight {
82
82
  this.deviceLogs(device);
83
83
  this.scan(device);
84
84
  this.refreshRate(device);
85
- this.context();
85
+ this.deviceContext();
86
86
  this.deviceConfig(device);
87
87
 
88
88
  // this is subject we use to track when we need to POST changes to the SwitchBot API
@@ -1108,7 +1108,7 @@ export class StripLight {
1108
1108
 
1109
1109
  async offlineOff(): Promise<void> {
1110
1110
  if (this.device.offline) {
1111
- await this.context();
1111
+ await this.deviceContext();
1112
1112
  await this.updateHomeKitCharacteristics();
1113
1113
  }
1114
1114
  }
@@ -1120,7 +1120,7 @@ export class StripLight {
1120
1120
  this.lightBulbService.updateCharacteristic(this.hap.Characteristic.Saturation, e);
1121
1121
  }
1122
1122
 
1123
- async context() {
1123
+ async deviceContext() {
1124
1124
  if (this.On === undefined) {
1125
1125
  this.On = false;
1126
1126
  } else {
@@ -69,7 +69,7 @@ export class Lock {
69
69
  this.deviceLogs(device);
70
70
  this.scan(device);
71
71
  this.refreshRate(device);
72
- this.context();
72
+ this.deviceContext();
73
73
  this.deviceConfig(device);
74
74
 
75
75
  // this is subject we use to track when we need to POST changes to the SwitchBot API
@@ -808,7 +808,7 @@ export class Lock {
808
808
 
809
809
  async offlineOff(): Promise<void> {
810
810
  if (this.device.offline) {
811
- await this.context();
811
+ await this.deviceContext();
812
812
  await this.updateHomeKitCharacteristics();
813
813
  }
814
814
  }
@@ -821,7 +821,7 @@ export class Lock {
821
821
  this.lockService.updateCharacteristic(this.hap.Characteristic.LockCurrentState, e);
822
822
  }
823
823
 
824
- async context() {
824
+ async deviceContext() {
825
825
  if (this.LockTargetState === undefined) {
826
826
  this.LockTargetState = false;
827
827
  } else {
@@ -72,7 +72,7 @@ export class Meter {
72
72
  this.deviceLogs(device);
73
73
  this.scan(device);
74
74
  this.refreshRate(device);
75
- this.context();
75
+ this.deviceContext();
76
76
  this.setupHistoryService(device);
77
77
  this.setupMqtt(device);
78
78
  this.deviceConfig(device);
@@ -682,7 +682,7 @@ export class Meter {
682
682
 
683
683
  async offlineOff(): Promise<void> {
684
684
  if (this.device.offline) {
685
- await this.context();
685
+ await this.deviceContext();
686
686
  await this.updateHomeKitCharacteristics();
687
687
  }
688
688
  }
@@ -698,7 +698,7 @@ export class Meter {
698
698
  this.batteryService?.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, e);
699
699
  }
700
700
 
701
- async context() {
701
+ async deviceContext() {
702
702
  if (this.CurrentRelativeHumidity === undefined) {
703
703
  this.CurrentRelativeHumidity = 0;
704
704
  } else {
@@ -77,7 +77,7 @@ export class MeterPlus {
77
77
  this.deviceLogs(device);
78
78
  this.scan(device);
79
79
  this.refreshRate(device);
80
- this.context();
80
+ this.deviceContext();
81
81
  this.setupHistoryService(device);
82
82
  this.setupMqtt(device);
83
83
  this.deviceConfig(device);
@@ -697,7 +697,7 @@ export class MeterPlus {
697
697
 
698
698
  async offlineOff(): Promise<void> {
699
699
  if (this.device.offline) {
700
- await this.context();
700
+ await this.deviceContext();
701
701
  await this.updateHomeKitCharacteristics();
702
702
  }
703
703
  }
@@ -713,7 +713,7 @@ export class MeterPlus {
713
713
  this.batteryService?.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, e);
714
714
  }
715
715
 
716
- async context() {
716
+ async deviceContext() {
717
717
  if (this.CurrentRelativeHumidity === undefined) {
718
718
  this.CurrentRelativeHumidity = 0;
719
719
  } else {
@@ -74,7 +74,7 @@ export class Motion {
74
74
  this.deviceLogs(device);
75
75
  this.scan(device);
76
76
  this.refreshRate(device);
77
- this.context();
77
+ this.deviceContext();
78
78
  this.deviceConfig(device);
79
79
 
80
80
  // this is subject we use to track when we need to POST changes to the SwitchBot API
@@ -629,7 +629,7 @@ export class Motion {
629
629
 
630
630
  async offlineOff(): Promise<void> {
631
631
  if (this.device.offline) {
632
- await this.context();
632
+ await this.deviceContext();
633
633
  await this.updateHomeKitCharacteristics();
634
634
  }
635
635
  }
@@ -643,12 +643,16 @@ export class Motion {
643
643
  }
644
644
  }
645
645
 
646
- async context() {
646
+ async deviceContext() {
647
647
  if (this.MotionDetected === undefined) {
648
648
  this.MotionDetected = false;
649
649
  } else {
650
650
  this.MotionDetected = this.accessory.context.MotionDetected;
651
651
  }
652
+ if (this.FirmwareRevision === undefined) {
653
+ this.FirmwareRevision = this.platform.version;
654
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
655
+ }
652
656
  }
653
657
 
654
658
  async refreshRate(device: device & devicesConfig): Promise<void> {
@@ -55,7 +55,7 @@ export class Plug {
55
55
  this.deviceLogs(device);
56
56
  this.scan(device);
57
57
  this.refreshRate(device);
58
- this.context();
58
+ this.deviceContext();
59
59
  this.deviceConfig(device);
60
60
 
61
61
  // this is subject we use to track when we need to POST changes to the SwitchBot API
@@ -656,7 +656,7 @@ export class Plug {
656
656
 
657
657
  async offlineOff(): Promise<void> {
658
658
  if (this.device.offline) {
659
- await this.context();
659
+ await this.deviceContext();
660
660
  await this.updateHomeKitCharacteristics();
661
661
  }
662
662
  }
@@ -665,12 +665,16 @@ export class Plug {
665
665
  this.outletService.updateCharacteristic(this.hap.Characteristic.On, e);
666
666
  }
667
667
 
668
- async context() {
668
+ async deviceContext() {
669
669
  if (this.On === undefined) {
670
670
  this.On = false;
671
671
  } else {
672
672
  this.On = this.accessory.context.On;
673
673
  }
674
+ if (this.FirmwareRevision === undefined) {
675
+ this.FirmwareRevision = this.platform.version;
676
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
677
+ }
674
678
  }
675
679
 
676
680
  async refreshRate(device: device & devicesConfig): Promise<void> {
@@ -62,7 +62,7 @@ export class RobotVacuumCleaner {
62
62
  this.deviceLogs(device);
63
63
  this.scan(device);
64
64
  this.refreshRate(device);
65
- this.context();
65
+ this.deviceContext();
66
66
  this.deviceConfig(device);
67
67
 
68
68
  // this is subject we use to track when we need to POST changes to the SwitchBot API
@@ -809,7 +809,7 @@ export class RobotVacuumCleaner {
809
809
 
810
810
  async offlineOff(): Promise<void> {
811
811
  if (this.device.offline) {
812
- await this.context();
812
+ await this.deviceContext();
813
813
  await this.updateHomeKitCharacteristics();
814
814
  }
815
815
  }
@@ -818,7 +818,7 @@ export class RobotVacuumCleaner {
818
818
  this.robotVacuumCleanerService.updateCharacteristic(this.hap.Characteristic.On, e);
819
819
  }
820
820
 
821
- async context() {
821
+ async deviceContext() {
822
822
  if (this.On === undefined) {
823
823
  this.On = false;
824
824
  } else {
@@ -829,6 +829,10 @@ export class RobotVacuumCleaner {
829
829
  } else {
830
830
  this.Brightness = this.accessory.context.Brightness;
831
831
  }
832
+ if (this.FirmwareRevision === undefined) {
833
+ this.FirmwareRevision = this.platform.version;
834
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
835
+ }
832
836
  }
833
837
 
834
838
  async refreshRate(device: device & devicesConfig): Promise<void> {
@@ -63,7 +63,7 @@ export class AirConditioner {
63
63
  this.hap = this.api.hap;
64
64
  // default placeholders
65
65
  this.deviceLogs(device);
66
- this.context();
66
+ this.deviceContext();
67
67
  this.disablePushOnChanges(device);
68
68
  this.disablePushOffChanges(device);
69
69
  this.disablePushDetailChanges(device);
@@ -209,7 +209,7 @@ export class AirConditioner {
209
209
  `${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerDetailsChanges Active: ${this.Active},` +
210
210
  ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`,
211
211
  );
212
- //await this.context();
212
+ //await this.deviceContext();
213
213
  if (this.CurrentMode === undefined) {
214
214
  this.CurrentMode = 1;
215
215
  }
@@ -243,7 +243,7 @@ export class AirConditioner {
243
243
 
244
244
  private async UpdateCurrentHeaterCoolerState() {
245
245
  if (this.Active === this.hap.Characteristic.Active.ACTIVE) {
246
- await this.context();
246
+ await this.deviceContext();
247
247
  if (this.ThresholdTemperature < this.CurrentTemperature &&
248
248
  this.TargetHeaterCoolerState !== this.hap.Characteristic.TargetHeaterCoolerState.HEAT) {
249
249
  this.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.COOLING;
@@ -439,7 +439,7 @@ export class AirConditioner {
439
439
  }
440
440
 
441
441
  async ThresholdTemperatureGet(): Promise<CharacteristicValue> {
442
- await this.context();
442
+ await this.deviceContext();
443
443
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get ThresholdTemperature: ${this.ThresholdTemperature}`);
444
444
  return this.ThresholdTemperature;
445
445
  }
@@ -665,7 +665,7 @@ export class AirConditioner {
665
665
  this.coolerService.updateCharacteristic(this.hap.Characteristic.CoolingThresholdTemperature, e);
666
666
  }
667
667
 
668
- async context(): Promise<void> {
668
+ async deviceContext(): Promise<void> {
669
669
  if (this.Active === undefined) {
670
670
  this.Active = this.hap.Characteristic.Active.INACTIVE;
671
671
  } else if (this.Active) {
@@ -54,7 +54,7 @@ export class AirPurifier {
54
54
  this.hap = this.api.hap;
55
55
  // default placeholders
56
56
  this.deviceLogs(device);
57
- this.context();
57
+ this.deviceContext();
58
58
  this.disablePushOnChanges(device);
59
59
  this.disablePushOffChanges(device);
60
60
  this.deviceConfig(device);
@@ -408,7 +408,7 @@ export class AirPurifier {
408
408
  this.airPurifierService.updateCharacteristic(this.hap.Characteristic.Active, e);
409
409
  }
410
410
 
411
- private context() {
411
+ private deviceContext() {
412
412
  if (this.Active === undefined) {
413
413
  this.Active = this.hap.Characteristic.Active.INACTIVE;
414
414
  } else {
@@ -36,7 +36,7 @@ export class Camera {
36
36
  this.hap = this.api.hap;
37
37
  // default placeholders
38
38
  this.deviceLogs(device);
39
- this.context();
39
+ this.deviceContext();
40
40
  this.disablePushOnChanges(device);
41
41
  this.disablePushOffChanges(device);
42
42
  this.deviceConfig(device);
@@ -289,7 +289,7 @@ export class Camera {
289
289
  this.switchService.updateCharacteristic(this.hap.Characteristic.On, e);
290
290
  }
291
291
 
292
- async context() {
292
+ async deviceContext() {
293
293
  if (this.On === undefined) {
294
294
  this.On = false;
295
295
  } else {
@@ -43,7 +43,7 @@ export class Fan {
43
43
  this.hap = this.api.hap;
44
44
  // default placeholders
45
45
  this.deviceLogs(device);
46
- this.context();
46
+ this.deviceContext();
47
47
  this.disablePushOnChanges(device);
48
48
  this.disablePushOffChanges(device);
49
49
  this.deviceConfig(device);
@@ -421,7 +421,7 @@ export class Fan {
421
421
  this.fanService.updateCharacteristic(this.hap.Characteristic.SwingMode, e);
422
422
  }
423
423
 
424
- async context() {
424
+ async deviceContext() {
425
425
  if (this.Active === undefined) {
426
426
  this.Active = this.hap.Characteristic.Active.INACTIVE;
427
427
  } else {
@@ -42,7 +42,7 @@ export class Light {
42
42
  this.hap = this.api.hap;
43
43
  // default placeholders
44
44
  this.deviceLogs(device);
45
- this.context();
45
+ this.deviceContext();
46
46
  this.disablePushOnChanges(device);
47
47
  this.disablePushOffChanges(device);
48
48
  this.deviceConfig(device);
@@ -437,7 +437,7 @@ export class Light {
437
437
  }
438
438
  }
439
439
 
440
- async context() {
440
+ async deviceContext() {
441
441
  if (this.On === undefined) {
442
442
  this.On = false;
443
443
  } else {
@@ -47,7 +47,7 @@ export class Others {
47
47
  // default placeholders
48
48
  this.deviceLogs(device);
49
49
  this.deviceType(device);
50
- this.context();
50
+ this.deviceContext();
51
51
  this.disablePushOnChanges(device);
52
52
  this.disablePushOffChanges(device);
53
53
  this.deviceConfig(device);
@@ -910,7 +910,7 @@ export class Others {
910
910
  }
911
911
  }
912
912
 
913
- async context() {
913
+ async deviceContext() {
914
914
  if (this.On === undefined) {
915
915
  this.On = true;
916
916
  } else {
@@ -39,7 +39,7 @@ export class TV {
39
39
  this.hap = this.api.hap;
40
40
  // default placeholders
41
41
  this.deviceLogs(device);
42
- this.context();
42
+ this.deviceContext();
43
43
  this.disablePushOnChanges(device);
44
44
  this.disablePushOffChanges(device);
45
45
  this.disablePushDetailChanges(device);
@@ -555,7 +555,7 @@ export class TV {
555
555
  this.tvService.updateCharacteristic(this.hap.Characteristic.ActiveIdentifier, e);
556
556
  }
557
557
 
558
- async context() {
558
+ async deviceContext() {
559
559
  if (this.Active === undefined) {
560
560
  this.Active = this.hap.Characteristic.Active.INACTIVE;
561
561
  } else {
@@ -36,7 +36,7 @@ export class VacuumCleaner {
36
36
  this.hap = this.api.hap;
37
37
  // default placeholders
38
38
  this.deviceLogs(device);
39
- this.context();
39
+ this.deviceContext();
40
40
  this.disablePushOnChanges(device);
41
41
  this.disablePushOffChanges(device);
42
42
  this.deviceConfig(device);
@@ -285,7 +285,7 @@ export class VacuumCleaner {
285
285
  this.switchService.updateCharacteristic(this.hap.Characteristic.On, e);
286
286
  }
287
287
 
288
- async context() {
288
+ async deviceContext() {
289
289
  if (this.On === undefined) {
290
290
  this.On = false;
291
291
  } else {
@@ -36,7 +36,7 @@ export class WaterHeater {
36
36
  this.hap = this.api.hap;
37
37
  // default placeholders
38
38
  this.deviceLogs(device);
39
- this.context();
39
+ this.deviceContext();
40
40
  this.disablePushOnChanges(device);
41
41
  this.disablePushOffChanges(device);
42
42
  this.deviceConfig(device);
@@ -294,7 +294,7 @@ export class WaterHeater {
294
294
  this.valveService.updateCharacteristic(this.hap.Characteristic.Active, e);
295
295
  }
296
296
 
297
- async context(): Promise<void> {
297
+ async deviceContext(): Promise<void> {
298
298
  if (this.Active === undefined) {
299
299
  this.Active = this.hap.Characteristic.Active.INACTIVE;
300
300
  } else {
package/src/platform.ts CHANGED
@@ -52,11 +52,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
52
52
  public readonly api: API;
53
53
  public readonly log: Logging;
54
54
 
55
- version = process.env.npm_package_version || '2.13.0';
55
+ version!: string;
56
56
  Logging?: string;
57
57
  debugMode!: boolean;
58
- platformLogging?: string;
58
+ platformConfig!: SwitchBotPlatformConfig['options'];
59
+ platformLogging!: SwitchBotPlatformConfig['logging'];
59
60
  config!: SwitchBotPlatformConfig;
61
+
60
62
  webhookEventListener: http.Server | null = null;
61
63
  mqttClient: MqttClient | null = null;
62
64
 
@@ -84,7 +86,10 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
84
86
  credentials: config.credentials as object,
85
87
  options: config.options as object,
86
88
  };
87
- this.logType();
89
+ this.platformLogging = this.config.options?.logging ?? 'standard';
90
+ this.platformConfigOptions();
91
+ this.platformLogs();
92
+ this.getVersion();
88
93
  this.debugLog(`Finished initializing platform: ${config.name}`);
89
94
 
90
95
  // verify the config
@@ -2569,7 +2574,37 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
2569
2574
  return switchbot;
2570
2575
  }
2571
2576
 
2572
- logType() {
2577
+ async getVersion() {
2578
+ const json = JSON.parse(
2579
+ readFileSync(
2580
+ new URL('../package.json', import.meta.url),
2581
+ 'utf-8',
2582
+ ),
2583
+ );
2584
+ this.debugLog(`Plugin Version: ${json.version}`);
2585
+ this.version = json.version;
2586
+ }
2587
+
2588
+ async platformConfigOptions() {
2589
+ const platformConfig: SwitchBotPlatformConfig['options'] = {};
2590
+ if (this.config.options) {
2591
+ if (this.config.options.logging) {
2592
+ platformConfig.logging = this.config.options.logging;
2593
+ }
2594
+ if (this.config.options.refreshRate) {
2595
+ platformConfig.refreshRate = this.config.options.refreshRate;
2596
+ }
2597
+ if (this.config.options.pushRate) {
2598
+ platformConfig.pushRate = this.config.options.pushRate;
2599
+ }
2600
+ if (Object.entries(platformConfig).length !== 0) {
2601
+ this.debugLog(`Platform Config: ${JSON.stringify(platformConfig)}`);
2602
+ }
2603
+ this.platformConfig = platformConfig;
2604
+ }
2605
+ }
2606
+
2607
+ async platformLogs() {
2573
2608
  this.debugMode = process.argv.includes('-D') || process.argv.includes('--debug');
2574
2609
  if (this.config.options?.logging === 'debug' || this.config.options?.logging === 'standard' || this.config.options?.logging === 'none') {
2575
2610
  this.platformLogging = this.config.options!.logging;