@switchbot/homebridge-switchbot 2.9.1-beta.3 → 2.9.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 +0 -3
  2. package/dist/device/blindtilt.d.ts.map +1 -1
  3. package/dist/device/blindtilt.js +7 -58
  4. package/dist/device/blindtilt.js.map +1 -1
  5. package/dist/device/bot.d.ts +0 -3
  6. package/dist/device/bot.d.ts.map +1 -1
  7. package/dist/device/bot.js +7 -81
  8. package/dist/device/bot.js.map +1 -1
  9. package/dist/device/ceilinglight.d.ts +0 -3
  10. package/dist/device/ceilinglight.d.ts.map +1 -1
  11. package/dist/device/ceilinglight.js +14 -58
  12. package/dist/device/ceilinglight.js.map +1 -1
  13. package/dist/device/colorbulb.d.ts +0 -3
  14. package/dist/device/colorbulb.d.ts.map +1 -1
  15. package/dist/device/colorbulb.js +10 -54
  16. package/dist/device/colorbulb.js.map +1 -1
  17. package/dist/device/contact.d.ts +0 -3
  18. package/dist/device/contact.d.ts.map +1 -1
  19. package/dist/device/contact.js +7 -58
  20. package/dist/device/contact.js.map +1 -1
  21. package/dist/device/curtain.d.ts +0 -3
  22. package/dist/device/curtain.d.ts.map +1 -1
  23. package/dist/device/curtain.js +7 -58
  24. package/dist/device/curtain.js.map +1 -1
  25. package/dist/device/hub.d.ts +1 -4
  26. package/dist/device/hub.d.ts.map +1 -1
  27. package/dist/device/hub.js +7 -60
  28. package/dist/device/hub.js.map +1 -1
  29. package/dist/device/humidifier.d.ts +0 -3
  30. package/dist/device/humidifier.d.ts.map +1 -1
  31. package/dist/device/humidifier.js +10 -57
  32. package/dist/device/humidifier.js.map +1 -1
  33. package/dist/device/iosensor.d.ts +0 -3
  34. package/dist/device/iosensor.d.ts.map +1 -1
  35. package/dist/device/iosensor.js +7 -57
  36. package/dist/device/iosensor.js.map +1 -1
  37. package/dist/device/lightstrip.d.ts +0 -3
  38. package/dist/device/lightstrip.d.ts.map +1 -1
  39. package/dist/device/lightstrip.js +10 -54
  40. package/dist/device/lightstrip.js.map +1 -1
  41. package/dist/device/lock.d.ts +0 -3
  42. package/dist/device/lock.d.ts.map +1 -1
  43. package/dist/device/lock.js +13 -61
  44. package/dist/device/lock.js.map +1 -1
  45. package/dist/device/meter.d.ts +0 -3
  46. package/dist/device/meter.d.ts.map +1 -1
  47. package/dist/device/meter.js +7 -60
  48. package/dist/device/meter.js.map +1 -1
  49. package/dist/device/meterplus.d.ts +1 -4
  50. package/dist/device/meterplus.d.ts.map +1 -1
  51. package/dist/device/meterplus.js +7 -61
  52. package/dist/device/meterplus.js.map +1 -1
  53. package/dist/device/motion.d.ts +0 -3
  54. package/dist/device/motion.d.ts.map +1 -1
  55. package/dist/device/motion.js +3 -55
  56. package/dist/device/motion.js.map +1 -1
  57. package/dist/device/plug.d.ts +0 -3
  58. package/dist/device/plug.d.ts.map +1 -1
  59. package/dist/device/plug.js +3 -51
  60. package/dist/device/plug.js.map +1 -1
  61. package/dist/device/robotvacuumcleaner.d.ts +0 -3
  62. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  63. package/dist/device/robotvacuumcleaner.js +12 -61
  64. package/dist/device/robotvacuumcleaner.js.map +1 -1
  65. package/dist/irdevice/airconditioner.d.ts +0 -1
  66. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  67. package/dist/irdevice/airconditioner.js +6 -45
  68. package/dist/irdevice/airconditioner.js.map +1 -1
  69. package/dist/irdevice/airpurifier.d.ts +0 -1
  70. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  71. package/dist/irdevice/airpurifier.js +6 -45
  72. package/dist/irdevice/airpurifier.js.map +1 -1
  73. package/dist/irdevice/camera.d.ts +0 -1
  74. package/dist/irdevice/camera.d.ts.map +1 -1
  75. package/dist/irdevice/camera.js +6 -45
  76. package/dist/irdevice/camera.js.map +1 -1
  77. package/dist/irdevice/fan.d.ts +0 -1
  78. package/dist/irdevice/fan.d.ts.map +1 -1
  79. package/dist/irdevice/fan.js +6 -45
  80. package/dist/irdevice/fan.js.map +1 -1
  81. package/dist/irdevice/light.d.ts +0 -1
  82. package/dist/irdevice/light.d.ts.map +1 -1
  83. package/dist/irdevice/light.js +6 -45
  84. package/dist/irdevice/light.js.map +1 -1
  85. package/dist/irdevice/other.d.ts +0 -1
  86. package/dist/irdevice/other.d.ts.map +1 -1
  87. package/dist/irdevice/other.js +6 -45
  88. package/dist/irdevice/other.js.map +1 -1
  89. package/dist/irdevice/tv.d.ts +0 -1
  90. package/dist/irdevice/tv.d.ts.map +1 -1
  91. package/dist/irdevice/tv.js +6 -45
  92. package/dist/irdevice/tv.js.map +1 -1
  93. package/dist/irdevice/vacuumcleaner.d.ts +0 -1
  94. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  95. package/dist/irdevice/vacuumcleaner.js +6 -45
  96. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  97. package/dist/irdevice/waterheater.d.ts +0 -1
  98. package/dist/irdevice/waterheater.d.ts.map +1 -1
  99. package/dist/irdevice/waterheater.js +6 -45
  100. package/dist/irdevice/waterheater.js.map +1 -1
  101. package/package.json +8 -8
  102. package/src/device/blindtilt.ts +7 -57
  103. package/src/device/bot.ts +7 -71
  104. package/src/device/ceilinglight.ts +14 -59
  105. package/src/device/colorbulb.ts +10 -54
  106. package/src/device/contact.ts +7 -58
  107. package/src/device/curtain.ts +7 -57
  108. package/src/device/hub.ts +7 -61
  109. package/src/device/humidifier.ts +10 -58
  110. package/src/device/iosensor.ts +7 -57
  111. package/src/device/lightstrip.ts +10 -54
  112. package/src/device/lock.ts +13 -62
  113. package/src/device/meter.ts +7 -59
  114. package/src/device/meterplus.ts +7 -61
  115. package/src/device/motion.ts +3 -54
  116. package/src/device/plug.ts +3 -50
  117. package/src/device/robotvacuumcleaner.ts +12 -61
  118. package/src/irdevice/airconditioner.ts +6 -44
  119. package/src/irdevice/airpurifier.ts +6 -46
  120. package/src/irdevice/camera.ts +6 -46
  121. package/src/irdevice/fan.ts +6 -46
  122. package/src/irdevice/light.ts +6 -46
  123. package/src/irdevice/other.ts +6 -46
  124. package/src/irdevice/tv.ts +6 -46
  125. package/src/irdevice/vacuumcleaner.ts +6 -46
  126. package/src/irdevice/waterheater.ts +6 -46
@@ -4,7 +4,6 @@ import { MqttClient } from 'mqtt';
4
4
  import { hostname } from 'os';
5
5
  import { interval } from 'rxjs';
6
6
  import { request } from 'undici';
7
- import { Context } from 'vm';
8
7
  import { SwitchBotPlatform } from '../platform';
9
8
  import { Devices, ad, device, deviceStatus, devicesConfig, serviceData, temperature } from '../settings';
10
9
  import { sleep } from '../utils';
@@ -78,20 +77,8 @@ export class Meter {
78
77
  .getService(this.platform.Service.AccessoryInformation)!
79
78
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
80
79
  .setCharacteristic(this.platform.Characteristic.Model, 'METERTH-S1')
81
- .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
82
-
83
- if (accessory.context.FirmwareRevision) {
84
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName}`
85
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
86
- accessory
87
- .getService(this.platform.Service.AccessoryInformation)!
88
- .setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
89
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
90
- .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
91
- .updateValue(accessory.context.FirmwareRevision);
92
- } else {
93
- this.setFirmwareRevision(accessory, device);
94
- }
80
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
81
+ .setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
95
82
 
96
83
  // Temperature Sensor Service
97
84
  if (device.meter?.hide_temperature) {
@@ -254,6 +241,7 @@ export class Meter {
254
241
 
255
242
  // FirmwareRevision
256
243
  this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
244
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
257
245
  }
258
246
 
259
247
  /**
@@ -439,24 +427,6 @@ export class Meter {
439
427
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
440
428
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
441
429
  }
442
- // FirmwareRevision
443
- if (this.FirmwareRevision === undefined) {
444
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
445
- } else {
446
- if (this.device.mqttURL) {
447
- mqttmessage.push(`"FirmwareRevision": ${this.FirmwareRevision}`);
448
- }
449
- this.accessory.context.FirmwareRevision = this.FirmwareRevision;
450
- this.batteryService.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
451
- if (!this.device.meter?.hide_humidity) {
452
- this.humidityService!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
453
- }
454
- if (!this.device.meter?.hide_temperature) {
455
- this.temperatureService!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
456
- }
457
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
458
- + `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
459
- }
460
430
 
461
431
  // MQTT
462
432
  if (this.device.mqttURL) {
@@ -629,32 +599,6 @@ export class Meter {
629
599
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
630
600
  }
631
601
 
632
- async setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig) {
633
- await this.refreshStatus();
634
- if (device.firmware) {
635
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
636
- accessory.context.FirmwareRevision = device.firmware;
637
- this.FirmwareRevision = accessory.context.FirmwareRevision;
638
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
639
- } else if (device.version) {
640
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version: ${device.version}`);
641
- accessory.context.FirmwareRevision = device.version;
642
- this.FirmwareRevision = accessory.context.FirmwareRevision;
643
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version, FirmwareRevision: ${this.FirmwareRevision}`);
644
- } else {
645
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
646
- accessory.context.FirmwareRevision = this.platform.version;
647
- this.FirmwareRevision = accessory.context.FirmwareRevision;
648
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version, FirmwareRevision: ${this.FirmwareRevision}`);
649
- }
650
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
651
- accessory
652
- .getService(this.platform.Service.AccessoryInformation)!
653
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
654
- .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
655
- .updateValue(this.FirmwareRevision);
656
- }
657
-
658
602
  async context() {
659
603
  if (this.CurrentRelativeHumidity === undefined) {
660
604
  this.CurrentRelativeHumidity = 0;
@@ -677,6 +621,10 @@ export class Meter {
677
621
  } else {
678
622
  this.StatusLowBattery = this.accessory.context.StatusLowBattery;
679
623
  }
624
+ if (this.FirmwareRevision === undefined) {
625
+ this.FirmwareRevision = this.platform.version;
626
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
627
+ }
680
628
  }
681
629
 
682
630
  async refreshRate(device: device & devicesConfig): Promise<void> {
@@ -4,7 +4,6 @@ import { MqttClient } from 'mqtt';
4
4
  import { hostname } from 'os';
5
5
  import { interval } from 'rxjs';
6
6
  import { request } from 'undici';
7
- import { Context } from 'vm';
8
7
  import { SwitchBotPlatform } from '../platform';
9
8
  import { Devices, ad, device, deviceStatus, devicesConfig, serviceData, temperature } from '../settings';
10
9
  import { sleep } from '../utils';
@@ -67,7 +66,7 @@ export class MeterPlus {
67
66
  this.logs(device);
68
67
  this.scan(device);
69
68
  this.refreshRate(device);
70
- this.context(accessory, device);
69
+ this.context();
71
70
  this.setupHistoryService(device);
72
71
  this.setupMqtt(device);
73
72
  this.config(device);
@@ -80,20 +79,8 @@ export class MeterPlus {
80
79
  .getService(this.platform.Service.AccessoryInformation)!
81
80
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
82
81
  .setCharacteristic(this.platform.Characteristic.Model, this.model(device))
83
- .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
84
-
85
- if (accessory.context.FirmwareRevision) {
86
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName}`
87
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
88
- accessory
89
- .getService(this.platform.Service.AccessoryInformation)!
90
- .setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
91
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
92
- .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
93
- .updateValue(accessory.context.FirmwareRevision);
94
- } else {
95
- this.setFirmwareRevision(accessory, device);
96
- }
82
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
83
+ .setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
97
84
 
98
85
  // Temperature Sensor Service
99
86
  if (device.meter?.hide_temperature) {
@@ -256,6 +243,7 @@ export class MeterPlus {
256
243
 
257
244
  // FirmwareRevision
258
245
  this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
246
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
259
247
  }
260
248
 
261
249
  /**
@@ -444,25 +432,6 @@ export class MeterPlus {
444
432
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
445
433
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
446
434
  }
447
- // FirmwareRevision
448
- if (this.FirmwareRevision === undefined) {
449
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
450
- } else {
451
- if (this.device.mqttURL) {
452
- mqttmessage.push(`"FirmwareRevision": ${this.FirmwareRevision}`);
453
- }
454
- this.accessory.context.FirmwareRevision = this.FirmwareRevision;
455
-
456
- this.batteryService.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
457
- if (!this.device.meter?.hide_humidity) {
458
- this.humidityService!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
459
- }
460
- if (!this.device.meter?.hide_temperature) {
461
- this.temperatureService!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
462
- }
463
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
464
- + `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
465
- }
466
435
 
467
436
  // MQTT
468
437
  if (this.device.mqttURL) {
@@ -629,7 +598,7 @@ export class MeterPlus {
629
598
 
630
599
  async offlineOff(): Promise<void> {
631
600
  if (this.device.offline) {
632
- await this.context(this.accessory, this.device);
601
+ await this.context();
633
602
  await this.updateHomeKitCharacteristics();
634
603
  }
635
604
  }
@@ -645,28 +614,7 @@ export class MeterPlus {
645
614
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
646
615
  }
647
616
 
648
- async setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig) {
649
- await this.refreshStatus();
650
- if (device.firmware) {
651
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
652
- accessory.context.FirmwareRevision = device.firmware;
653
- this.FirmwareRevision = accessory.context.FirmwareRevision;
654
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
655
- } else {
656
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version: ${device.version}`);
657
- accessory.context.FirmwareRevision = device.version;
658
- this.FirmwareRevision = accessory.context.FirmwareRevision;
659
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version, FirmwareRevision: ${this.FirmwareRevision}`);
660
- }
661
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
662
- accessory
663
- .getService(this.platform.Service.AccessoryInformation)!
664
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
665
- .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
666
- .updateValue(this.FirmwareRevision);
667
- }
668
-
669
- async context(accessory, device) {
617
+ async context() {
670
618
  if (this.CurrentRelativeHumidity === undefined) {
671
619
  this.CurrentRelativeHumidity = 0;
672
620
  } else {
@@ -690,9 +638,7 @@ export class MeterPlus {
690
638
  }
691
639
  if (this.FirmwareRevision === undefined) {
692
640
  this.FirmwareRevision = this.platform.version;
693
- } else {
694
- this.setFirmwareRevision(accessory, device);
695
- this.FirmwareRevision = this.accessory.context.FirmwareRevision;
641
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
696
642
  }
697
643
  }
698
644
 
@@ -1,4 +1,3 @@
1
- import { Context } from 'vm';
2
1
  import { request } from 'undici';
3
2
  import { sleep } from '../utils';
4
3
  import { interval, Subject } from 'rxjs';
@@ -79,20 +78,8 @@ export class Motion {
79
78
  .getService(this.platform.Service.AccessoryInformation)!
80
79
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
81
80
  .setCharacteristic(this.platform.Characteristic.Model, 'W1101500')
82
- .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
83
-
84
- if (accessory.context.FirmwareRevision) {
85
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName}`
86
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
87
- accessory
88
- .getService(this.platform.Service.AccessoryInformation)!
89
- .setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
90
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
91
- .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
92
- .updateValue(accessory.context.FirmwareRevision);
93
- } else {
94
- this.setFirmwareRevision(accessory, device);
95
- }
81
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
82
+ .setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
96
83
 
97
84
  // get the Battery service if it exists, otherwise create a new Motion service
98
85
  // you can create multiple services for each accessory
@@ -240,6 +227,7 @@ export class Motion {
240
227
 
241
228
  // FirmwareRevision
242
229
  this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
230
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
243
231
  }
244
232
 
245
233
  /**
@@ -412,19 +400,6 @@ export class Motion {
412
400
  );
413
401
  }
414
402
  }
415
- // FirmwareRevision
416
- if (this.FirmwareRevision === undefined) {
417
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
418
- } else {
419
- this.accessory.context.FirmwareRevision = this.FirmwareRevision;
420
- this.motionSensorService.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
421
- this.batteryService.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
422
- if (!this.device.motion?.hide_lightsensor) {
423
- this.lightSensorService!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
424
- }
425
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
426
- + `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
427
- }
428
403
  }
429
404
 
430
405
  async stopScanning(switchbot: any) {
@@ -573,32 +548,6 @@ export class Motion {
573
548
  }
574
549
  }
575
550
 
576
- async setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig) {
577
- await this.refreshStatus();
578
- if (device.firmware) {
579
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
580
- accessory.context.FirmwareRevision = device.firmware;
581
- this.FirmwareRevision = accessory.context.FirmwareRevision;
582
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
583
- } else if (device.version) {
584
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version: ${device.version}`);
585
- accessory.context.FirmwareRevision = device.version;
586
- this.FirmwareRevision = accessory.context.FirmwareRevision;
587
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version, FirmwareRevision: ${this.FirmwareRevision}`);
588
- } else {
589
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
590
- accessory.context.FirmwareRevision = this.platform.version;
591
- this.FirmwareRevision = accessory.context.FirmwareRevision;
592
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version, FirmwareRevision: ${this.FirmwareRevision}`);
593
- }
594
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
595
- accessory
596
- .getService(this.platform.Service.AccessoryInformation)!
597
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
598
- .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
599
- .updateValue(this.FirmwareRevision);
600
- }
601
-
602
551
  async context() {
603
552
  if (this.MotionDetected === undefined) {
604
553
  this.MotionDetected = false;
@@ -1,4 +1,3 @@
1
- import { Context } from 'vm';
2
1
  import { request } from 'undici';
3
2
  import { sleep } from '../utils';
4
3
  import { interval, Subject } from 'rxjs';
@@ -60,20 +59,8 @@ export class Plug {
60
59
  .getService(this.platform.Service.AccessoryInformation)!
61
60
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
62
61
  .setCharacteristic(this.platform.Characteristic.Model, this.model(device))
63
- .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
64
-
65
- if (accessory.context.FirmwareRevision) {
66
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName}`
67
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
68
- accessory
69
- .getService(this.platform.Service.AccessoryInformation)!
70
- .setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
71
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
72
- .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
73
- .updateValue(accessory.context.FirmwareRevision);
74
- } else {
75
- this.setFirmwareRevision(accessory, device);
76
- }
62
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
63
+ .setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
77
64
 
78
65
  // get the Outlet service if it exists, otherwise create a new Outlet service
79
66
  // you can create multiple services for each accessory
@@ -167,6 +154,7 @@ export class Plug {
167
154
 
168
155
  // FirmwareRevision
169
156
  this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
157
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
170
158
  }
171
159
 
172
160
  /**
@@ -435,15 +423,6 @@ export class Plug {
435
423
  this.outletService.updateCharacteristic(this.platform.Characteristic.On, this.On);
436
424
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
437
425
  }
438
- // FirmwareRevision
439
- if (this.FirmwareRevision === undefined) {
440
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
441
- } else {
442
- this.accessory.context.FirmwareRevision = this.FirmwareRevision;
443
- this.outletService.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
444
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
445
- + `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
446
- }
447
426
  }
448
427
 
449
428
  async stopScanning(switchbot: any) {
@@ -597,32 +576,6 @@ export class Plug {
597
576
  this.outletService.updateCharacteristic(this.platform.Characteristic.On, e);
598
577
  }
599
578
 
600
- async setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig) {
601
- await this.refreshStatus();
602
- if (device.firmware) {
603
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
604
- accessory.context.FirmwareRevision = device.firmware;
605
- this.FirmwareRevision = accessory.context.FirmwareRevision;
606
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
607
- } else if (device.version) {
608
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version: ${device.version}`);
609
- accessory.context.FirmwareRevision = device.version;
610
- this.FirmwareRevision = accessory.context.FirmwareRevision;
611
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version, FirmwareRevision: ${this.FirmwareRevision}`);
612
- } else {
613
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
614
- accessory.context.FirmwareRevision = this.platform.version;
615
- this.FirmwareRevision = accessory.context.FirmwareRevision;
616
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version, FirmwareRevision: ${this.FirmwareRevision}`);
617
- }
618
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
619
- accessory
620
- .getService(this.platform.Service.AccessoryInformation)!
621
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
622
- .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
623
- .updateValue(this.FirmwareRevision);
624
- }
625
-
626
579
  async context() {
627
580
  if (this.On === undefined) {
628
581
  this.On = false;
@@ -1,5 +1,3 @@
1
- /* eslint-disable brace-style */
2
- import { Context } from 'vm';
3
1
  import { request } from 'undici';
4
2
  import { sleep } from '../utils';
5
3
  import { interval, Subject } from 'rxjs';
@@ -68,20 +66,8 @@ export class RobotVacuumCleaner {
68
66
  .getService(this.platform.Service.AccessoryInformation)!
69
67
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
70
68
  .setCharacteristic(this.platform.Characteristic.Model, this.model(device))
71
- .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
72
-
73
- if (accessory.context.FirmwareRevision) {
74
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName}`
75
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
76
- accessory
77
- .getService(this.platform.Service.AccessoryInformation)!
78
- .setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
79
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
80
- .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
81
- .updateValue(accessory.context.FirmwareRevision);
82
- } else {
83
- this.setFirmwareRevision(accessory, device);
84
- }
69
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
70
+ .setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
85
71
 
86
72
  // get the Lightbulb service if it exists, otherwise create a new Lightbulb service
87
73
  // you can create multiple services for each accessory
@@ -166,9 +152,9 @@ export class RobotVacuumCleaner {
166
152
  async parseStatus(): Promise<void> {
167
153
  if (!this.device.enableCloudService && this.OpenAPI) {
168
154
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} parseStatus enableCloudService: ${this.device.enableCloudService}`);
169
- } /*if (this.BLE) {
170
- await this.BLEparseStatus();
171
- } else*/ else if (this.OpenAPI && this.platform.config.credentials?.token) {
155
+ /*} else if (this.BLE) {
156
+ await this.BLEparseStatus();*/
157
+ } else if (this.OpenAPI && this.platform.config.credentials?.token) {
172
158
  await this.openAPIparseStatus();
173
159
  } else {
174
160
  await this.offlineOff();
@@ -213,6 +199,7 @@ export class RobotVacuumCleaner {
213
199
 
214
200
  // FirmwareRevision
215
201
  this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
202
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
216
203
  }
217
204
 
218
205
  /**
@@ -221,9 +208,9 @@ export class RobotVacuumCleaner {
221
208
  async refreshStatus(): Promise<void> {
222
209
  if (!this.device.enableCloudService && this.OpenAPI) {
223
210
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus enableCloudService: ${this.device.enableCloudService}`);
224
- } /*if (this.BLE) {
225
- await this.BLERefreshStatus();
226
- } else*/ else if (this.OpenAPI && this.platform.config.credentials?.token) {
211
+ /*} else if (this.BLE) {
212
+ await this.BLERefreshStatus();*/
213
+ } else if (this.OpenAPI && this.platform.config.credentials?.token) {
227
214
  await this.openAPIRefreshStatus();
228
215
  } else {
229
216
  await this.offlineOff();
@@ -341,9 +328,9 @@ export class RobotVacuumCleaner {
341
328
  async pushChanges(): Promise<void> {
342
329
  if (!this.device.enableCloudService && this.OpenAPI) {
343
330
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
344
- } /* if (this.BLE) {
345
- await this.BLEpushChanges();
346
- } else*/ else if (this.OpenAPI && this.platform.config.credentials?.token) {
331
+ /*} else if (this.BLE) {
332
+ await this.BLEpushChanges();*/
333
+ } else if (this.OpenAPI && this.platform.config.credentials?.token) {
347
334
  await this.openAPIpushChanges();
348
335
  } else {
349
336
  await this.offlineOff();
@@ -599,16 +586,6 @@ export class RobotVacuumCleaner {
599
586
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
600
587
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
601
588
  }
602
- // FirmwareRevision
603
- if (this.FirmwareRevision === undefined) {
604
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
605
- } else {
606
- this.accessory.context.FirmwareRevision = this.FirmwareRevision;
607
- this.batteryService.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
608
- this.robotVacuumCleanerService.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
609
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
610
- + `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
611
- }
612
589
  }
613
590
 
614
591
  async stopScanning(switchbot: any) {
@@ -761,32 +738,6 @@ export class RobotVacuumCleaner {
761
738
  this.robotVacuumCleanerService.updateCharacteristic(this.platform.Characteristic.On, e);
762
739
  }
763
740
 
764
- async setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig) {
765
- await this.refreshStatus();
766
- if (device.firmware) {
767
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
768
- accessory.context.FirmwareRevision = device.firmware;
769
- this.FirmwareRevision = accessory.context.FirmwareRevision;
770
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
771
- } else if (device.version) {
772
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version: ${device.version}`);
773
- accessory.context.FirmwareRevision = device.version;
774
- this.FirmwareRevision = accessory.context.FirmwareRevision;
775
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version, FirmwareRevision: ${this.FirmwareRevision}`);
776
- } else {
777
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
778
- accessory.context.FirmwareRevision = this.platform.version;
779
- this.FirmwareRevision = accessory.context.FirmwareRevision;
780
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version, FirmwareRevision: ${this.FirmwareRevision}`);
781
- }
782
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
783
- accessory
784
- .getService(this.platform.Service.AccessoryInformation)!
785
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
786
- .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
787
- .updateValue(this.FirmwareRevision);
788
- }
789
-
790
741
  async context() {
791
742
  if (this.On === undefined) {
792
743
  this.On = false;
@@ -62,20 +62,8 @@ export class AirConditioner {
62
62
  .getService(this.platform.Service.AccessoryInformation)!
63
63
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
64
64
  .setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
65
- .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
66
-
67
- if (accessory.context.FirmwareRevision) {
68
- this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
69
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
70
- accessory
71
- .getService(this.platform.Service.AccessoryInformation)!
72
- .setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
73
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
74
- .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
75
- .updateValue(accessory.context.FirmwareRevision);
76
- } else {
77
- this.setFirmwareRevision(accessory, device);
78
- }
65
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
66
+ .setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
79
67
 
80
68
  // get the Television service if it exists, otherwise create a new Television service
81
69
  // you can create multiple services for each accessory
@@ -524,16 +512,6 @@ export class AirConditioner {
524
512
  `${this.device.remoteType}: ${this.accessory.displayName}` + ` updateCharacteristic ThresholdTemperature: ${this.ThresholdTemperature}`,
525
513
  );
526
514
  }
527
- // FirmwareRevision
528
- if (this.FirmwareRevision === undefined) {
529
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
530
- } else {
531
- this.accessory.context.FirmwareRevision = this.FirmwareRevision;
532
- this.accessory.getService(this.platform.Service.AccessoryInformation)!
533
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
534
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} `
535
- + `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
536
- }
537
515
  }
538
516
 
539
517
  async disablePushOnChanges(device: irdevice & irDevicesConfig): Promise<void> {
@@ -641,26 +619,6 @@ export class AirConditioner {
641
619
  this.coolerService.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, e);
642
620
  }
643
621
 
644
- async setFirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig) {
645
- if (device.firmware) {
646
- this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
647
- accessory.context.FirmwareRevision = device.firmware;
648
- this.FirmwareRevision = accessory.context.FirmwareRevision;
649
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
650
- } else {
651
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
652
- accessory.context.FirmwareRevision = this.platform.version;
653
- this.FirmwareRevision = accessory.context.FirmwareRevision;
654
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version, FirmwareRevision: ${this.FirmwareRevision}`);
655
- }
656
- this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
657
- accessory
658
- .getService(this.platform.Service.AccessoryInformation)!
659
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
660
- .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
661
- .updateValue(this.FirmwareRevision);
662
- }
663
-
664
622
  async context(): Promise<void> {
665
623
  if (this.Active === undefined) {
666
624
  this.Active = this.platform.Characteristic.Active.INACTIVE;
@@ -703,6 +661,10 @@ export class AirConditioner {
703
661
  this.CurrentRelativeHumidity = this.CurrentRelativeHumidity || this.accessory.context.CurrentRelativeHumidity;
704
662
  }
705
663
  }
664
+ if (this.FirmwareRevision === undefined) {
665
+ this.FirmwareRevision = this.platform.version;
666
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
667
+ }
706
668
  }
707
669
 
708
670
  async config(device: irdevice & irDevicesConfig): Promise<void> {