@switchbot/homebridge-switchbot 2.8.2-beta.1 → 2.8.2

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 (129) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/config.schema.json +1 -1
  3. package/dist/device/blindtilt.d.ts +2 -1
  4. package/dist/device/blindtilt.d.ts.map +1 -1
  5. package/dist/device/blindtilt.js +39 -14
  6. package/dist/device/blindtilt.js.map +1 -1
  7. package/dist/device/bot.d.ts +2 -1
  8. package/dist/device/bot.d.ts.map +1 -1
  9. package/dist/device/bot.js +23 -17
  10. package/dist/device/bot.js.map +1 -1
  11. package/dist/device/ceilinglight.d.ts +2 -1
  12. package/dist/device/ceilinglight.d.ts.map +1 -1
  13. package/dist/device/ceilinglight.js +16 -14
  14. package/dist/device/ceilinglight.js.map +1 -1
  15. package/dist/device/colorbulb.d.ts +2 -1
  16. package/dist/device/colorbulb.d.ts.map +1 -1
  17. package/dist/device/colorbulb.js +21 -14
  18. package/dist/device/colorbulb.js.map +1 -1
  19. package/dist/device/contact.d.ts +2 -1
  20. package/dist/device/contact.d.ts.map +1 -1
  21. package/dist/device/contact.js +16 -14
  22. package/dist/device/contact.js.map +1 -1
  23. package/dist/device/curtain.d.ts +4 -3
  24. package/dist/device/curtain.d.ts.map +1 -1
  25. package/dist/device/curtain.js +36 -18
  26. package/dist/device/curtain.js.map +1 -1
  27. package/dist/device/hub.d.ts +2 -1
  28. package/dist/device/hub.d.ts.map +1 -1
  29. package/dist/device/hub.js +16 -14
  30. package/dist/device/hub.js.map +1 -1
  31. package/dist/device/humidifier.d.ts +5 -4
  32. package/dist/device/humidifier.d.ts.map +1 -1
  33. package/dist/device/humidifier.js +16 -14
  34. package/dist/device/humidifier.js.map +1 -1
  35. package/dist/device/iosensor.d.ts +2 -1
  36. package/dist/device/iosensor.d.ts.map +1 -1
  37. package/dist/device/iosensor.js +29 -14
  38. package/dist/device/iosensor.js.map +1 -1
  39. package/dist/device/lightstrip.d.ts +2 -1
  40. package/dist/device/lightstrip.d.ts.map +1 -1
  41. package/dist/device/lightstrip.js +21 -14
  42. package/dist/device/lightstrip.js.map +1 -1
  43. package/dist/device/lock.d.ts +2 -1
  44. package/dist/device/lock.d.ts.map +1 -1
  45. package/dist/device/lock.js +18 -15
  46. package/dist/device/lock.js.map +1 -1
  47. package/dist/device/meter.d.ts +3 -2
  48. package/dist/device/meter.d.ts.map +1 -1
  49. package/dist/device/meter.js +48 -26
  50. package/dist/device/meter.js.map +1 -1
  51. package/dist/device/meterplus.d.ts +3 -2
  52. package/dist/device/meterplus.d.ts.map +1 -1
  53. package/dist/device/meterplus.js +46 -23
  54. package/dist/device/meterplus.js.map +1 -1
  55. package/dist/device/motion.d.ts +5 -4
  56. package/dist/device/motion.d.ts.map +1 -1
  57. package/dist/device/motion.js +22 -19
  58. package/dist/device/motion.js.map +1 -1
  59. package/dist/device/plug.d.ts +2 -1
  60. package/dist/device/plug.d.ts.map +1 -1
  61. package/dist/device/plug.js +17 -14
  62. package/dist/device/plug.js.map +1 -1
  63. package/dist/device/robotvacuumcleaner.d.ts +2 -1
  64. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  65. package/dist/device/robotvacuumcleaner.js +19 -13
  66. package/dist/device/robotvacuumcleaner.js.map +1 -1
  67. package/dist/irdevice/airconditioner.d.ts +7 -19
  68. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  69. package/dist/irdevice/airconditioner.js +36 -18
  70. package/dist/irdevice/airconditioner.js.map +1 -1
  71. package/dist/irdevice/airpurifier.d.ts +4 -7
  72. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  73. package/dist/irdevice/airpurifier.js +26 -12
  74. package/dist/irdevice/airpurifier.js.map +1 -1
  75. package/dist/irdevice/camera.d.ts +4 -7
  76. package/dist/irdevice/camera.d.ts.map +1 -1
  77. package/dist/irdevice/camera.js +24 -12
  78. package/dist/irdevice/camera.js.map +1 -1
  79. package/dist/irdevice/fan.d.ts +4 -7
  80. package/dist/irdevice/fan.d.ts.map +1 -1
  81. package/dist/irdevice/fan.js +23 -12
  82. package/dist/irdevice/fan.js.map +1 -1
  83. package/dist/irdevice/light.d.ts +4 -7
  84. package/dist/irdevice/light.d.ts.map +1 -1
  85. package/dist/irdevice/light.js +24 -12
  86. package/dist/irdevice/light.js.map +1 -1
  87. package/dist/irdevice/other.d.ts +4 -7
  88. package/dist/irdevice/other.d.ts.map +1 -1
  89. package/dist/irdevice/other.js +24 -12
  90. package/dist/irdevice/other.js.map +1 -1
  91. package/dist/irdevice/tv.d.ts +5 -10
  92. package/dist/irdevice/tv.d.ts.map +1 -1
  93. package/dist/irdevice/tv.js +27 -14
  94. package/dist/irdevice/tv.js.map +1 -1
  95. package/dist/irdevice/vacuumcleaner.d.ts +4 -7
  96. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  97. package/dist/irdevice/vacuumcleaner.js +24 -12
  98. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  99. package/dist/irdevice/waterheater.d.ts +6 -16
  100. package/dist/irdevice/waterheater.d.ts.map +1 -1
  101. package/dist/irdevice/waterheater.js +28 -16
  102. package/dist/irdevice/waterheater.js.map +1 -1
  103. package/package.json +3 -3
  104. package/src/device/blindtilt.ts +41 -16
  105. package/src/device/bot.ts +25 -17
  106. package/src/device/ceilinglight.ts +20 -14
  107. package/src/device/colorbulb.ts +23 -14
  108. package/src/device/contact.ts +20 -14
  109. package/src/device/curtain.ts +41 -21
  110. package/src/device/hub.ts +20 -14
  111. package/src/device/humidifier.ts +23 -17
  112. package/src/device/iosensor.ts +33 -14
  113. package/src/device/lightstrip.ts +23 -14
  114. package/src/device/lock.ts +22 -15
  115. package/src/device/meter.ts +52 -27
  116. package/src/device/meterplus.ts +51 -26
  117. package/src/device/motion.ts +31 -30
  118. package/src/device/plug.ts +20 -14
  119. package/src/device/robotvacuumcleaner.ts +21 -13
  120. package/src/irdevice/airconditioner.ts +36 -18
  121. package/src/irdevice/airpurifier.ts +26 -12
  122. package/src/irdevice/camera.ts +24 -12
  123. package/src/irdevice/fan.ts +23 -12
  124. package/src/irdevice/light.ts +24 -12
  125. package/src/irdevice/other.ts +24 -12
  126. package/src/irdevice/tv.ts +27 -14
  127. package/src/irdevice/vacuumcleaner.ts +24 -12
  128. package/src/irdevice/waterheater.ts +28 -16
  129. package/.github/npm-version-script.js +0 -81
@@ -14,15 +14,16 @@ import { device, devicesConfig, serviceData, deviceStatus, ad, Devices } from '.
14
14
  */
15
15
  export class Motion {
16
16
  // Services
17
- motionSensorService: Service;
18
- lightSensorService?: Service;
19
17
  batteryService: Service;
18
+ motionSensorService!: Service;
19
+ lightSensorService?: Service;
20
20
 
21
21
  // Characteristic Values
22
- MotionDetected!: CharacteristicValue;
23
- CurrentAmbientLightLevel!: CharacteristicValue;
24
22
  BatteryLevel!: CharacteristicValue;
23
+ MotionDetected!: CharacteristicValue;
25
24
  StatusLowBattery!: CharacteristicValue;
25
+ FirmwareRevision!: CharacteristicValue;
26
+ CurrentAmbientLightLevel!: CharacteristicValue;
26
27
 
27
28
  // OpenAPI Others
28
29
  OpenAPI_BatteryLevel: deviceStatus['battery'];
@@ -38,11 +39,6 @@ export class Motion {
38
39
  // BLE Others
39
40
  scanning!: boolean;
40
41
  BLE_IsConnected?: boolean;
41
- /*is_light!: any; //serviceData['is_light'];
42
- tested!: any;
43
- led!: any;
44
- iot!: any;
45
- sense_distance!: any;*/
46
42
 
47
43
  // Config
48
44
  set_minLux!: number;
@@ -84,9 +80,9 @@ export class Motion {
84
80
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
85
81
  .setCharacteristic(this.platform.Characteristic.Model, 'W1101500')
86
82
  .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
87
- .setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision(accessory, device))
83
+ .setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.setFirmwareRevision(accessory, device))
88
84
  .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
89
- .updateValue(this.FirmwareRevision(accessory, device));
85
+ .updateValue(this.setFirmwareRevision(accessory, device));
90
86
 
91
87
  // get the Battery service if it exists, otherwise create a new Motion service
92
88
  // you can create multiple services for each accessory
@@ -218,19 +214,22 @@ export class Motion {
218
214
  }
219
215
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
220
216
  }
217
+
221
218
  // Battery
222
- if (this.OpenAPI_BatteryLevel === undefined) {
223
- this.OpenAPI_BatteryLevel = 100;
224
- }
225
- this.BatteryLevel = this.OpenAPI_BatteryLevel!;
219
+ this.BatteryLevel = Number(this.OpenAPI_BatteryLevel);
226
220
  if (this.BatteryLevel < 10) {
227
221
  this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
228
222
  } else {
229
223
  this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
230
224
  }
231
- this.debugLog(
232
- `${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel},` + ` StatusLowBattery: ${this.StatusLowBattery}`,
233
- );
225
+ if (Number.isNaN(this.BatteryLevel)) {
226
+ this.BatteryLevel = 100;
227
+ }
228
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel},`
229
+ + ` StatusLowBattery: ${this.StatusLowBattery}`);
230
+
231
+ // FirmwareRevision
232
+ this.FirmwareRevision = JSON.stringify(this.OpenAPI_FirmwareRevision);
234
233
  }
235
234
 
236
235
  /**
@@ -403,15 +402,16 @@ export class Motion {
403
402
  );
404
403
  }
405
404
  }
405
+
406
406
  // FirmwareRevision
407
- if (this.OpenAPI_FirmwareRevision === undefined) {
408
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
407
+ if (this.FirmwareRevision === undefined) {
408
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
409
409
  } else {
410
- this.accessory.context.OpenAPI_FirmwareRevision = this.OpenAPI_FirmwareRevision;
410
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
411
411
  this.accessory.getService(this.platform.Service.AccessoryInformation)!
412
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
412
+ .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
413
413
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
414
- + `updateCharacteristic FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
414
+ + `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
415
415
  }
416
416
  }
417
417
 
@@ -561,23 +561,24 @@ export class Motion {
561
561
  }
562
562
  }
563
563
 
564
- FirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
565
- let FirmwareRevision: string;
564
+ setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
565
+
566
566
  this.debugLog(
567
567
  `${this.device.deviceType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
568
568
  );
569
569
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
570
570
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
571
571
  if (device.firmware) {
572
- FirmwareRevision = device.firmware;
572
+ this.FirmwareRevision = device.firmware;
573
573
  } else if (device.version) {
574
- FirmwareRevision = JSON.stringify(device.version);
574
+ this.FirmwareRevision = JSON.stringify(device.version);
575
575
  } else if (accessory.context.FirmwareRevision) {
576
- FirmwareRevision = accessory.context.FirmwareRevision;
576
+ this.FirmwareRevision = accessory.context.FirmwareRevision;
577
577
  } else {
578
- FirmwareRevision = this.platform.version;
578
+ this.FirmwareRevision = this.platform.version;
579
579
  }
580
- return FirmwareRevision;
580
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
581
+ return this.FirmwareRevision;
581
582
  }
582
583
 
583
584
  async context() {
@@ -13,6 +13,7 @@ export class Plug {
13
13
 
14
14
  // Characteristic Values
15
15
  On!: CharacteristicValue;
16
+ FirmwareRevision!: CharacteristicValue;
16
17
 
17
18
  // OpenAPI Others
18
19
  OpenAPI_On: deviceStatus['power'];
@@ -60,9 +61,9 @@ export class Plug {
60
61
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
61
62
  .setCharacteristic(this.platform.Characteristic.Model, this.model(device))
62
63
  .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
63
- .setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision(accessory, device))
64
+ .setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.setFirmwareRevision(accessory, device))
64
65
  .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
65
- .updateValue(this.FirmwareRevision(accessory, device));
66
+ .updateValue(this.setFirmwareRevision(accessory, device));
66
67
 
67
68
  // get the Outlet service if it exists, otherwise create a new Outlet service
68
69
  // you can create multiple services for each accessory
@@ -153,6 +154,9 @@ export class Plug {
153
154
  this.On = false;
154
155
  }
155
156
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
157
+
158
+ // FirmwareRevision
159
+ this.FirmwareRevision = JSON.stringify(this.OpenAPI_FirmwareRevision);
156
160
  }
157
161
 
158
162
  /**
@@ -413,6 +417,7 @@ export class Plug {
413
417
  }
414
418
 
415
419
  async updateHomeKitCharacteristics(): Promise<void> {
420
+ // On
416
421
  if (this.On === undefined) {
417
422
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
418
423
  } else {
@@ -421,14 +426,14 @@ export class Plug {
421
426
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
422
427
  }
423
428
  // FirmwareRevision
424
- if (this.OpenAPI_FirmwareRevision === undefined) {
425
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
429
+ if (this.FirmwareRevision === undefined) {
430
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
426
431
  } else {
427
- this.accessory.context.OpenAPI_FirmwareRevision = this.OpenAPI_FirmwareRevision;
432
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
428
433
  this.accessory.getService(this.platform.Service.AccessoryInformation)!
429
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
434
+ .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
430
435
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
431
- + `updateCharacteristic FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
436
+ + `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
432
437
  }
433
438
  }
434
439
 
@@ -582,23 +587,24 @@ export class Plug {
582
587
  this.outletService.updateCharacteristic(this.platform.Characteristic.On, e);
583
588
  }
584
589
 
585
- FirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
586
- let FirmwareRevision: string;
590
+ setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
591
+
587
592
  this.debugLog(
588
593
  `${this.device.deviceType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
589
594
  );
590
595
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
591
596
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
592
597
  if (device.firmware) {
593
- FirmwareRevision = device.firmware;
598
+ this.FirmwareRevision = device.firmware;
594
599
  } else if (device.version) {
595
- FirmwareRevision = JSON.stringify(device.version);
600
+ this.FirmwareRevision = JSON.stringify(device.version);
596
601
  } else if (accessory.context.FirmwareRevision) {
597
- FirmwareRevision = accessory.context.FirmwareRevision;
602
+ this.FirmwareRevision = accessory.context.FirmwareRevision;
598
603
  } else {
599
- FirmwareRevision = this.platform.version;
604
+ this.FirmwareRevision = this.platform.version;
600
605
  }
601
- return FirmwareRevision;
606
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
607
+ return this.FirmwareRevision;
602
608
  }
603
609
 
604
610
  async context() {
@@ -18,6 +18,7 @@ export class RobotVacuumCleaner {
18
18
  Brightness!: CharacteristicValue;
19
19
  BatteryLevel!: CharacteristicValue;
20
20
  StatusLowBattery!: CharacteristicValue;
21
+ FirmwareRevision!: CharacteristicValue;
21
22
 
22
23
  // OpenAPI Status
23
24
  OpenAPI_On: deviceStatus['power'];
@@ -68,9 +69,9 @@ export class RobotVacuumCleaner {
68
69
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
69
70
  .setCharacteristic(this.platform.Characteristic.Model, this.model(device))
70
71
  .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
71
- .setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision(accessory, device))
72
+ .setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.setFirmwareRevision(accessory, device))
72
73
  .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
73
- .updateValue(this.FirmwareRevision(accessory, device));
74
+ .updateValue(this.setFirmwareRevision(accessory, device));
74
75
 
75
76
  // get the Lightbulb service if it exists, otherwise create a new Lightbulb service
76
77
  // you can create multiple services for each accessory
@@ -199,6 +200,9 @@ export class RobotVacuumCleaner {
199
200
  this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
200
201
  }
201
202
  this.debugLog(`${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}, StatusLowBattery: ${this.StatusLowBattery}`);
203
+
204
+ // FirmwareRevision
205
+ this.FirmwareRevision = JSON.stringify(this.OpenAPI_FirmwareRevision);
202
206
  }
203
207
 
204
208
  /**
@@ -553,6 +557,7 @@ export class RobotVacuumCleaner {
553
557
  }
554
558
 
555
559
  async updateHomeKitCharacteristics(): Promise<void> {
560
+ // On
556
561
  if (this.On === undefined) {
557
562
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
558
563
  } else {
@@ -560,6 +565,7 @@ export class RobotVacuumCleaner {
560
565
  this.robotVacuumCleanerService.updateCharacteristic(this.platform.Characteristic.On, this.On);
561
566
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
562
567
  }
568
+ // Brightness
563
569
  if (this.Brightness === undefined) {
564
570
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Brightness: ${this.Brightness}`);
565
571
  } else {
@@ -567,6 +573,7 @@ export class RobotVacuumCleaner {
567
573
  this.robotVacuumCleanerService.updateCharacteristic(this.platform.Characteristic.Brightness, this.Brightness);
568
574
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Brightness: ${this.Brightness}`);
569
575
  }
576
+ // BatteryLevel
570
577
  if (this.BatteryLevel === undefined) {
571
578
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
572
579
  } else {
@@ -574,6 +581,7 @@ export class RobotVacuumCleaner {
574
581
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel);
575
582
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
576
583
  }
584
+ // StatusLowBattery
577
585
  if (this.StatusLowBattery === undefined) {
578
586
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
579
587
  } else {
@@ -582,14 +590,14 @@ export class RobotVacuumCleaner {
582
590
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
583
591
  }
584
592
  // FirmwareRevision
585
- if (this.OpenAPI_FirmwareRevision === undefined) {
586
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
593
+ if (this.FirmwareRevision === undefined) {
594
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
587
595
  } else {
588
- this.accessory.context.OpenAPI_FirmwareRevision = this.OpenAPI_FirmwareRevision;
596
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
589
597
  this.accessory.getService(this.platform.Service.AccessoryInformation)!
590
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
598
+ .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
591
599
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
592
- + `updateCharacteristic FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
600
+ + `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
593
601
  }
594
602
  }
595
603
 
@@ -743,21 +751,21 @@ export class RobotVacuumCleaner {
743
751
  this.robotVacuumCleanerService.updateCharacteristic(this.platform.Characteristic.On, e);
744
752
  }
745
753
 
746
- FirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
747
- let FirmwareRevision: string;
754
+ setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
748
755
  this.debugLog(
749
756
  `${this.device.deviceType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
750
757
  );
751
758
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
752
759
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
753
760
  if (accessory.context.FirmwareRevision) {
754
- FirmwareRevision = accessory.context.FirmwareRevision;
761
+ this.FirmwareRevision = accessory.context.FirmwareRevision;
755
762
  } else if (device.firmware) {
756
- FirmwareRevision = device.firmware;
763
+ this.FirmwareRevision = device.firmware;
757
764
  } else {
758
- FirmwareRevision = this.platform.version;
765
+ this.FirmwareRevision = this.platform.version;
759
766
  }
760
- return FirmwareRevision;
767
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
768
+ return this.FirmwareRevision;
761
769
  }
762
770
 
763
771
  async context() {
@@ -15,6 +15,7 @@ export class AirConditioner {
15
15
  // Characteristic Values
16
16
  Active!: CharacteristicValue;
17
17
  RotationSpeed!: CharacteristicValue;
18
+ FirmwareRevision!: CharacteristicValue;
18
19
  CurrentTemperature!: CharacteristicValue;
19
20
  ThresholdTemperature!: CharacteristicValue;
20
21
  CurrentRelativeHumidity?: CharacteristicValue;
@@ -49,12 +50,12 @@ export class AirConditioner {
49
50
  public device: irdevice & irDevicesConfig,
50
51
  ) {
51
52
  // default placeholders
52
- this.logs({ device });
53
+ this.logs(device);
53
54
  this.context();
54
- this.disablePushOnChanges({ device });
55
- this.disablePushOffChanges({ device });
56
- this.disablePushDetailChanges({ device });
57
- this.config({ device });
55
+ this.disablePushOnChanges(device);
56
+ this.disablePushOffChanges(device);
57
+ this.disablePushDetailChanges(device);
58
+ this.config(device);
58
59
 
59
60
  // set accessory information
60
61
  accessory
@@ -62,9 +63,9 @@ export class AirConditioner {
62
63
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
63
64
  .setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
64
65
  .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
65
- .setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision({ accessory, device }))
66
+ .setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.setFirmwareRevision(accessory, device))
66
67
  .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
67
- .updateValue(this.FirmwareRevision({ accessory, device }));
68
+ .updateValue(this.setFirmwareRevision(accessory, device));
68
69
 
69
70
  // get the Television service if it exists, otherwise create a new Television service
70
71
  // you can create multiple services for each accessory
@@ -445,6 +446,7 @@ export class AirConditioner {
445
446
  }
446
447
 
447
448
  async updateHomeKitCharacteristics(): Promise<void> {
449
+ // Active
448
450
  if (this.Active === undefined) {
449
451
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Active}`);
450
452
  } else {
@@ -452,6 +454,7 @@ export class AirConditioner {
452
454
  this.coolerService?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
453
455
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
454
456
  }
457
+ // RotationSpeed
455
458
  if (this.RotationSpeed === undefined) {
456
459
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`);
457
460
  } else {
@@ -459,6 +462,7 @@ export class AirConditioner {
459
462
  this.coolerService?.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.RotationSpeed);
460
463
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`);
461
464
  }
465
+ // CurrentTemperature
462
466
  if (this.CurrentTemperature === undefined) {
463
467
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
464
468
  } else {
@@ -466,6 +470,7 @@ export class AirConditioner {
466
470
  this.coolerService?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
467
471
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
468
472
  }
473
+ // CurrentRelativeHumidity
469
474
  if (this.meter) {
470
475
  if (this.CurrentRelativeHumidity === undefined) {
471
476
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
@@ -477,6 +482,7 @@ export class AirConditioner {
477
482
  );
478
483
  }
479
484
  }
485
+ // TargetHeaterCoolerState
480
486
  if (this.TargetHeaterCoolerState === undefined) {
481
487
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
482
488
  } else {
@@ -486,6 +492,7 @@ export class AirConditioner {
486
492
  `${this.device.remoteType}: ${this.accessory.displayName}` + ` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
487
493
  );
488
494
  }
495
+ // CurrentHeaterCoolerState
489
496
  if (this.CurrentHeaterCoolerState === undefined) {
490
497
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
491
498
  } else {
@@ -496,6 +503,7 @@ export class AirConditioner {
496
503
  ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
497
504
  );
498
505
  }
506
+ // ThresholdTemperature
499
507
  if (this.ThresholdTemperature === undefined) {
500
508
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ThresholdTemperature: ${this.ThresholdTemperature}`);
501
509
  } else {
@@ -506,9 +514,19 @@ export class AirConditioner {
506
514
  `${this.device.remoteType}: ${this.accessory.displayName}` + ` updateCharacteristic ThresholdTemperature: ${this.ThresholdTemperature}`,
507
515
  );
508
516
  }
517
+ // FirmwareRevision
518
+ if (this.FirmwareRevision === undefined) {
519
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
520
+ } else {
521
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
522
+ this.accessory.getService(this.platform.Service.AccessoryInformation)!
523
+ .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
524
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} `
525
+ + `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
526
+ }
509
527
  }
510
528
 
511
- async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
529
+ async disablePushOnChanges(device: irdevice & irDevicesConfig): Promise<void> {
512
530
  if (device.disablePushOn === undefined) {
513
531
  this.disablePushOn = false;
514
532
  } else {
@@ -516,7 +534,7 @@ export class AirConditioner {
516
534
  }
517
535
  }
518
536
 
519
- async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
537
+ async disablePushOffChanges(device: irdevice & irDevicesConfig): Promise<void> {
520
538
  if (device.disablePushOff === undefined) {
521
539
  this.disablePushOff = false;
522
540
  } else {
@@ -524,7 +542,7 @@ export class AirConditioner {
524
542
  }
525
543
  }
526
544
 
527
- async disablePushDetailChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
545
+ async disablePushDetailChanges(device: irdevice & irDevicesConfig): Promise<void> {
528
546
  if (device.disablePushDetail === undefined) {
529
547
  this.disablePushDetail = false;
530
548
  } else {
@@ -613,21 +631,21 @@ export class AirConditioner {
613
631
  this.coolerService.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, e);
614
632
  }
615
633
 
616
- FirmwareRevision({ accessory, device }: { accessory: PlatformAccessory; device: irdevice & irDevicesConfig }): string {
617
- let FirmwareRevision: string;
634
+ setFirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): string {
618
635
  this.debugLog(
619
636
  `${this.device.remoteType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
620
637
  );
621
638
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
622
639
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
623
640
  if (accessory.context.FirmwareRevision) {
624
- FirmwareRevision = accessory.context.FirmwareRevision;
641
+ this.FirmwareRevision = accessory.context.FirmwareRevision;
625
642
  } else if (device.firmware) {
626
- FirmwareRevision = device.firmware;
643
+ this.FirmwareRevision = device.firmware;
627
644
  } else {
628
- FirmwareRevision = this.platform.version;
645
+ this.FirmwareRevision = this.platform.version!;
629
646
  }
630
- return FirmwareRevision;
647
+ this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
648
+ return JSON.stringify(this.FirmwareRevision);
631
649
  }
632
650
 
633
651
  async context(): Promise<void> {
@@ -674,7 +692,7 @@ export class AirConditioner {
674
692
  }
675
693
  }
676
694
 
677
- async config({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
695
+ async config(device: irdevice & irDevicesConfig): Promise<void> {
678
696
  let config = {};
679
697
  if (device.irair) {
680
698
  config = device.irair;
@@ -711,7 +729,7 @@ export class AirConditioner {
711
729
  }
712
730
  }
713
731
 
714
- async logs({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
732
+ async logs(device: irdevice & irDevicesConfig): Promise<void> {
715
733
  if (this.platform.debugMode) {
716
734
  this.deviceLogging = this.accessory.context.logging = 'debugMode';
717
735
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
@@ -18,6 +18,7 @@ export class AirPurifier {
18
18
  CurrentAPTemp!: CharacteristicValue;
19
19
  CurrentAPMode!: CharacteristicValue;
20
20
  RotationSpeed!: CharacteristicValue;
21
+ FirmwareRevision!: CharacteristicValue;
21
22
  CurrentAPFanSpeed!: CharacteristicValue;
22
23
  CurrentTemperature!: CharacteristicValue;
23
24
  CurrentAirPurifierState!: CharacteristicValue;
@@ -46,8 +47,8 @@ export class AirPurifier {
46
47
  // default placeholders
47
48
  this.logs(device);
48
49
  this.context();
49
- this.disablePushOnChanges({ device });
50
- this.disablePushOffChanges({ device });
50
+ this.disablePushOnChanges(device);
51
+ this.disablePushOffChanges(device);
51
52
  this.config(device);
52
53
 
53
54
  // set accessory information
@@ -56,9 +57,9 @@ export class AirPurifier {
56
57
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
57
58
  .setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
58
59
  .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
59
- .setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision(accessory, device))
60
+ .setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.setFirmwareRevision(accessory, device))
60
61
  .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
61
- .updateValue(this.FirmwareRevision(accessory, device));
62
+ .updateValue(this.setFirmwareRevision(accessory, device));
62
63
 
63
64
  // get the Television service if it exists, otherwise create a new Television service
64
65
  // you can create multiple services for each accessory
@@ -243,6 +244,7 @@ export class AirPurifier {
243
244
  }
244
245
 
245
246
  async updateHomeKitCharacteristics(): Promise<void> {
247
+ // Active
246
248
  if (this.Active === undefined) {
247
249
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Active}`);
248
250
  } else {
@@ -250,6 +252,7 @@ export class AirPurifier {
250
252
  this.airPurifierService?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
251
253
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
252
254
  }
255
+ // CurrentAirPurifierState
253
256
  if (this.CurrentAirPurifierState === undefined) {
254
257
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentAirPurifierState: ${this.CurrentAirPurifierState}`);
255
258
  } else {
@@ -259,6 +262,7 @@ export class AirPurifier {
259
262
  `${this.device.remoteType}: ${this.accessory.displayName}` + ` updateCharacteristic CurrentAirPurifierState: ${this.CurrentAirPurifierState}`,
260
263
  );
261
264
  }
265
+ // CurrentHeaterCoolerState
262
266
  if (this.CurrentHeaterCoolerState === undefined) {
263
267
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
264
268
  } else {
@@ -269,9 +273,19 @@ export class AirPurifier {
269
273
  ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
270
274
  );
271
275
  }
276
+ // FirmwareRevision
277
+ if (this.FirmwareRevision === undefined) {
278
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
279
+ } else {
280
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
281
+ this.accessory.getService(this.platform.Service.AccessoryInformation)!
282
+ .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
283
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} `
284
+ + `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
285
+ }
272
286
  }
273
287
 
274
- async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
288
+ async disablePushOnChanges(device: irdevice & irDevicesConfig): Promise<void> {
275
289
  if (device.disablePushOn === undefined) {
276
290
  this.disablePushOn = false;
277
291
  } else {
@@ -279,7 +293,7 @@ export class AirPurifier {
279
293
  }
280
294
  }
281
295
 
282
- async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
296
+ async disablePushOffChanges(device: irdevice & irDevicesConfig): Promise<void> {
283
297
  if (device.disablePushOff === undefined) {
284
298
  this.disablePushOff = false;
285
299
  } else {
@@ -364,21 +378,21 @@ export class AirPurifier {
364
378
  this.airPurifierService.updateCharacteristic(this.platform.Characteristic.Active, e);
365
379
  }
366
380
 
367
- FirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): string {
368
- let FirmwareRevision: string;
381
+ setFirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): string {
369
382
  this.debugLog(
370
383
  `${this.device.remoteType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
371
384
  );
372
385
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
373
386
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
374
387
  if (accessory.context.FirmwareRevision) {
375
- FirmwareRevision = accessory.context.FirmwareRevision;
388
+ this.FirmwareRevision = accessory.context.FirmwareRevision;
376
389
  } else if (device.firmware) {
377
- FirmwareRevision = device.firmware;
390
+ this.FirmwareRevision = device.firmware;
378
391
  } else {
379
- FirmwareRevision = this.platform.version;
392
+ this.FirmwareRevision = this.platform.version!;
380
393
  }
381
- return FirmwareRevision;
394
+ this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
395
+ return JSON.stringify(this.FirmwareRevision);
382
396
  }
383
397
 
384
398
  private context() {