@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
package/src/device/hub.ts CHANGED
@@ -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, device, deviceStatus, devicesConfig } from '../settings';
10
9
 
@@ -56,7 +55,7 @@ export class Hub {
56
55
  // default placeholders
57
56
  this.logs(device);
58
57
  this.refreshRate(device);
59
- this.context(accessory, device);
58
+ this.context();
60
59
  this.setupHistoryService(device);
61
60
  this.setupMqtt(device);
62
61
  this.config(device);
@@ -72,20 +71,8 @@ export class Hub {
72
71
  .getService(this.platform.Service.AccessoryInformation)!
73
72
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
74
73
  .setCharacteristic(this.platform.Characteristic.Model, accessory.context.model)
75
- .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
76
-
77
- if (accessory.context.FirmwareRevision) {
78
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName}`
79
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
80
- accessory
81
- .getService(this.platform.Service.AccessoryInformation)!
82
- .setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
83
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
84
- .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
85
- .updateValue(accessory.context.FirmwareRevision);
86
- } else {
87
- this.setFirmwareRevision(accessory, device);
88
- }
74
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
75
+ .setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
89
76
 
90
77
  // Temperature Sensor Service
91
78
  if (device.hub?.hide_temperature) {
@@ -303,6 +290,7 @@ export class Hub {
303
290
 
304
291
  // FirmwareRevision
305
292
  this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
293
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
306
294
  }
307
295
 
308
296
  async refreshStatus(): Promise<void> {
@@ -412,25 +400,6 @@ export class Hub {
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
-
421
- if (!this.device.hub?.hide_humidity) {
422
- this.humidityService!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
423
- }
424
- if (!this.device.hub?.hide_temperature) {
425
- this.temperatureService!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
426
- }
427
- if (!this.device.hub?.hide_lightsensor) {
428
- this.lightSensorService!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
429
- }
430
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
431
- + `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
432
- }
433
-
434
403
  // MQTT
435
404
  if (this.device.mqttURL) {
436
405
  this.mqttPublish(`{${mqttmessage.join(',')}}`);
@@ -536,7 +505,7 @@ export class Hub {
536
505
 
537
506
  async offlineOff(): Promise<void> {
538
507
  if (this.device.offline) {
539
- await this.context(this.accessory, this.device);
508
+ await this.context();
540
509
  await this.updateHomeKitCharacteristics();
541
510
  }
542
511
  }
@@ -571,28 +540,7 @@ export class Hub {
571
540
  return this.set_maxLux;
572
541
  }
573
542
 
574
- async setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig) {
575
- await this.refreshStatus();
576
- if (device.firmware) {
577
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
578
- accessory.context.FirmwareRevision = device.firmware;
579
- this.FirmwareRevision = accessory.context.FirmwareRevision;
580
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
581
- } else {
582
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version: ${device.version}`);
583
- accessory.context.FirmwareRevision = device.version;
584
- this.FirmwareRevision = accessory.context.FirmwareRevision;
585
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version, FirmwareRevision: ${this.FirmwareRevision}`);
586
- }
587
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
588
- accessory
589
- .getService(this.platform.Service.AccessoryInformation)!
590
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
591
- .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
592
- .updateValue(this.FirmwareRevision);
593
- }
594
-
595
- async context(accessory, device) {
543
+ async context() {
596
544
  if (this.CurrentRelativeHumidity === undefined) {
597
545
  this.CurrentRelativeHumidity = 0;
598
546
  } else {
@@ -610,9 +558,7 @@ export class Hub {
610
558
  }
611
559
  if (this.FirmwareRevision === undefined) {
612
560
  this.FirmwareRevision = this.platform.version;
613
- } else {
614
- this.setFirmwareRevision(accessory, device);
615
- this.FirmwareRevision = this.accessory.context.FirmwareRevision;
561
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
616
562
  }
617
563
  }
618
564
 
@@ -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';
@@ -81,20 +79,8 @@ export class Humidifier {
81
79
  .getService(this.platform.Service.AccessoryInformation)!
82
80
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
83
81
  .setCharacteristic(this.platform.Characteristic.Model, 'W0801800')
84
- .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
85
-
86
- if (accessory.context.FirmwareRevision) {
87
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName}`
88
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
89
- accessory
90
- .getService(this.platform.Service.AccessoryInformation)!
91
- .setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
92
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
93
- .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
94
- .updateValue(accessory.context.FirmwareRevision);
95
- } else {
96
- this.setFirmwareRevision(accessory, device);
97
- }
82
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
83
+ .setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
98
84
 
99
85
  // get the service if it exists, otherwise create a new service
100
86
  // you can create multiple services for each accessory
@@ -294,6 +280,7 @@ export class Humidifier {
294
280
 
295
281
  // FirmwareRevision
296
282
  this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
283
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
297
284
  }
298
285
 
299
286
  /**
@@ -421,9 +408,9 @@ export class Humidifier {
421
408
  async pushChanges(): Promise<void> {
422
409
  if (!this.device.enableCloudService && this.OpenAPI) {
423
410
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
424
- } /*if (this.BLE) {
425
- await this.BLEpushChanges();
426
- } else*/ else if (this.OpenAPI && this.platform.config.credentials?.token) {
411
+ /*} else if (this.BLE) {
412
+ await this.BLEpushChanges();*/
413
+ } else if (this.OpenAPI && this.platform.config.credentials?.token) {
427
414
  await this.openAPIpushChanges();
428
415
  } else {
429
416
  await this.offlineOff();
@@ -747,19 +734,6 @@ export class Humidifier {
747
734
  this.accessory.context.CurrentTemperature = this.CurrentTemperature;
748
735
  }
749
736
  }
750
-
751
- // FirmwareRevision
752
- if (this.FirmwareRevision === undefined) {
753
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
754
- } else {
755
- this.accessory.context.FirmwareRevision = this.FirmwareRevision;
756
- this.humidifierService.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
757
- if (!this.device.humidifier?.hide_temperature) {
758
- this.temperatureservice!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
759
- }
760
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
761
- + `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
762
- }
763
737
  }
764
738
 
765
739
  async stopScanning(switchbot: any) {
@@ -895,32 +869,6 @@ export class Humidifier {
895
869
  }
896
870
  }
897
871
 
898
- async setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig) {
899
- await this.refreshStatus();
900
- if (device.firmware) {
901
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
902
- accessory.context.FirmwareRevision = device.firmware;
903
- this.FirmwareRevision = accessory.context.FirmwareRevision;
904
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
905
- } else if (device.version) {
906
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version: ${device.version}`);
907
- accessory.context.FirmwareRevision = device.version;
908
- this.FirmwareRevision = accessory.context.FirmwareRevision;
909
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version, FirmwareRevision: ${this.FirmwareRevision}`);
910
- } else {
911
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
912
- accessory.context.FirmwareRevision = this.platform.version;
913
- this.FirmwareRevision = accessory.context.FirmwareRevision;
914
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version, FirmwareRevision: ${this.FirmwareRevision}`);
915
- }
916
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
917
- accessory
918
- .getService(this.platform.Service.AccessoryInformation)!
919
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
920
- .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
921
- .updateValue(this.FirmwareRevision);
922
- }
923
-
924
872
  async context() {
925
873
  if (this.Active === undefined) {
926
874
  this.Active = this.platform.Characteristic.Active.ACTIVE;
@@ -961,6 +909,10 @@ export class Humidifier {
961
909
  } else {
962
910
  this.WaterLevel = this.accessory.context.WaterLevel;
963
911
  }
912
+ if (this.FirmwareRevision === undefined) {
913
+ this.FirmwareRevision = this.platform.version;
914
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
915
+ }
964
916
  }
965
917
 
966
918
  async refreshRate(device: device & devicesConfig): Promise<void> {
@@ -1,4 +1,3 @@
1
- import { Context } from 'vm';
2
1
  import { hostname } from 'os';
3
2
  import { request } from 'undici';
4
3
  import { sleep } from '../utils';
@@ -89,20 +88,8 @@ export class IOSensor {
89
88
  .getService(this.platform.Service.AccessoryInformation)!
90
89
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
91
90
  .setCharacteristic(this.platform.Characteristic.Model, 'WoIOSensor')
92
- .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
93
-
94
- if (accessory.context.FirmwareRevision) {
95
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName}`
96
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
97
- accessory
98
- .getService(this.platform.Service.AccessoryInformation)!
99
- .setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
100
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
101
- .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
102
- .updateValue(accessory.context.FirmwareRevision);
103
- } else {
104
- this.setFirmwareRevision(accessory, device);
105
- }
91
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
92
+ .setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
106
93
 
107
94
  // Temperature Sensor Service
108
95
  if (device.meter?.hide_temperature) {
@@ -265,6 +252,7 @@ export class IOSensor {
265
252
 
266
253
  // FirmwareRevision
267
254
  this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
255
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
268
256
  }
269
257
 
270
258
  /**
@@ -457,22 +445,6 @@ export class IOSensor {
457
445
  this.historyService?.addEntry(entry);
458
446
  }
459
447
  }
460
-
461
- // FirmwareRevision
462
- if (this.FirmwareRevision === undefined) {
463
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
464
- } else {
465
- this.accessory.context.FirmwareRevision = this.FirmwareRevision;
466
- this.batteryService.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
467
- if (this.device.meter?.hide_humidity) {
468
- this.humidityservice!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
469
- }
470
- if (this.device.meter?.hide_temperature) {
471
- this.temperatureservice!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
472
- }
473
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
474
- + `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
475
- }
476
448
  }
477
449
 
478
450
  /*
@@ -634,32 +606,6 @@ export class IOSensor {
634
606
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
635
607
  }
636
608
 
637
- async setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig) {
638
- await this.refreshStatus();
639
- if (device.firmware) {
640
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
641
- accessory.context.FirmwareRevision = device.firmware;
642
- this.FirmwareRevision = accessory.context.FirmwareRevision;
643
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
644
- } else if (device.version) {
645
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version: ${device.version}`);
646
- accessory.context.FirmwareRevision = device.version;
647
- this.FirmwareRevision = accessory.context.FirmwareRevision;
648
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version, FirmwareRevision: ${this.FirmwareRevision}`);
649
- } else {
650
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
651
- accessory.context.FirmwareRevision = this.platform.version;
652
- this.FirmwareRevision = accessory.context.FirmwareRevision;
653
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version, FirmwareRevision: ${this.FirmwareRevision}`);
654
- }
655
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
656
- accessory
657
- .getService(this.platform.Service.AccessoryInformation)!
658
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
659
- .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
660
- .updateValue(this.FirmwareRevision);
661
- }
662
-
663
609
  async context() {
664
610
  if (this.CurrentRelativeHumidity === undefined) {
665
611
  this.CurrentRelativeHumidity = 0;
@@ -682,6 +628,10 @@ export class IOSensor {
682
628
  } else {
683
629
  this.StatusLowBattery = this.accessory.context.StatusLowBattery;
684
630
  }
631
+ if (this.FirmwareRevision === undefined) {
632
+ this.FirmwareRevision = this.platform.version;
633
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
634
+ }
685
635
  }
686
636
 
687
637
  async refreshRate(device: device & devicesConfig): Promise<void> {
@@ -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';
@@ -86,20 +84,8 @@ export class StripLight {
86
84
  .getService(this.platform.Service.AccessoryInformation)!
87
85
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
88
86
  .setCharacteristic(this.platform.Characteristic.Model, 'W1701100')
89
- .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
90
-
91
- if (accessory.context.FirmwareRevision) {
92
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName}`
93
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
94
- accessory
95
- .getService(this.platform.Service.AccessoryInformation)!
96
- .setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
97
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
98
- .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
99
- .updateValue(accessory.context.FirmwareRevision);
100
- } else {
101
- this.setFirmwareRevision(accessory, device);
102
- }
87
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
88
+ .setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
103
89
 
104
90
  // get the Lightbulb service if it exists, otherwise create a new Lightbulb service
105
91
  // you can create multiple services for each accessory
@@ -289,6 +275,7 @@ export class StripLight {
289
275
 
290
276
  // FirmwareRevision
291
277
  this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
278
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
292
279
  }
293
280
 
294
281
  /**
@@ -419,9 +406,9 @@ export class StripLight {
419
406
  async pushChanges(): Promise<void> {
420
407
  if (!this.device.enableCloudService && this.OpenAPI) {
421
408
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
422
- } /*if (this.BLE) {
423
- await this.BLEpushChanges();
424
- } else*/ else if (this.OpenAPI && this.platform.config.credentials?.token) {
409
+ /* }else if (this.BLE) {
410
+ await this.BLEpushChanges();*/
411
+ } else if (this.OpenAPI && this.platform.config.credentials?.token) {
425
412
  await this.openAPIpushChanges();
426
413
  } else {
427
414
  await this.offlineOff();
@@ -870,15 +857,6 @@ export class StripLight {
870
857
  this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Saturation, this.Saturation);
871
858
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Saturation: ${this.Saturation}`);
872
859
  }
873
- // FirmwareRevision
874
- if (this.FirmwareRevision === undefined) {
875
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
876
- } else {
877
- this.accessory.context.FirmwareRevision = this.FirmwareRevision;
878
- this.lightBulbService.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
879
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
880
- + `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
881
- }
882
860
  }
883
861
 
884
862
  async stopScanning(switchbot: any) {
@@ -1034,32 +1012,6 @@ export class StripLight {
1034
1012
  this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Saturation, e);
1035
1013
  }
1036
1014
 
1037
- async setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig) {
1038
- await this.refreshStatus();
1039
- if (device.firmware) {
1040
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
1041
- accessory.context.FirmwareRevision = device.firmware;
1042
- this.FirmwareRevision = accessory.context.FirmwareRevision;
1043
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
1044
- } else if (device.version) {
1045
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version: ${device.version}`);
1046
- accessory.context.FirmwareRevision = device.version;
1047
- this.FirmwareRevision = accessory.context.FirmwareRevision;
1048
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version, FirmwareRevision: ${this.FirmwareRevision}`);
1049
- } else {
1050
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
1051
- accessory.context.FirmwareRevision = this.platform.version;
1052
- this.FirmwareRevision = accessory.context.FirmwareRevision;
1053
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version, FirmwareRevision: ${this.FirmwareRevision}`);
1054
- }
1055
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
1056
- accessory
1057
- .getService(this.platform.Service.AccessoryInformation)!
1058
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
1059
- .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
1060
- .updateValue(this.FirmwareRevision);
1061
- }
1062
-
1063
1015
  async context() {
1064
1016
  if (this.On === undefined) {
1065
1017
  this.On = false;
@@ -1088,6 +1040,10 @@ export class StripLight {
1088
1040
  }
1089
1041
  this.minKelvin = 2000;
1090
1042
  this.maxKelvin = 9000;
1043
+ if (this.FirmwareRevision === undefined) {
1044
+ this.FirmwareRevision = this.platform.version;
1045
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
1046
+ }
1091
1047
  }
1092
1048
 
1093
1049
  async refreshRate(device: device & devicesConfig): Promise<void> {
@@ -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';
@@ -74,20 +72,8 @@ export class Lock {
74
72
  .getService(this.platform.Service.AccessoryInformation)!
75
73
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
76
74
  .setCharacteristic(this.platform.Characteristic.Model, 'W1601700')
77
- .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
78
-
79
- if (accessory.context.FirmwareRevision) {
80
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName}`
81
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
82
- accessory
83
- .getService(this.platform.Service.AccessoryInformation)!
84
- .setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
85
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
86
- .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
87
- .updateValue(accessory.context.FirmwareRevision);
88
- } else {
89
- this.setFirmwareRevision(accessory, device);
90
- }
75
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
76
+ .setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
91
77
 
92
78
  // get the LockMechanism service if it exists, otherwise create a new LockMechanism service
93
79
  // you can create multiple services for each accessory
@@ -173,9 +159,9 @@ export class Lock {
173
159
  async parseStatus(): Promise<void> {
174
160
  if (!this.device.enableCloudService && this.OpenAPI) {
175
161
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} parseStatus enableCloudService: ${this.device.enableCloudService}`);
176
- } /*if (this.BLE) {
177
- await this.BLEparseStatus();
178
- } else*/ else if (this.OpenAPI && this.platform.config.credentials?.token) {
162
+ /* } else if (this.BLE) {
163
+ await this.BLEparseStatus();*/
164
+ } else if (this.OpenAPI && this.platform.config.credentials?.token) {
179
165
  await this.openAPIparseStatus();
180
166
  } else {
181
167
  await this.offlineOff();
@@ -251,6 +237,7 @@ export class Lock {
251
237
 
252
238
  // FirmwareRevision
253
239
  this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
240
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
254
241
  }
255
242
 
256
243
  /**
@@ -380,9 +367,9 @@ export class Lock {
380
367
  async pushChanges(): Promise<void> {
381
368
  if (!this.device.enableCloudService && this.OpenAPI) {
382
369
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
383
- } /*if (this.BLE) {
384
- await this.BLEpushChanges();
385
- } else*/ else if (this.OpenAPI && this.platform.config.credentials?.token) {
370
+ /*} else if (this.BLE) {
371
+ await this.BLEpushChanges();*/
372
+ } else if (this.OpenAPI && this.platform.config.credentials?.token) {
386
373
  await this.openAPIpushChanges();
387
374
  } else {
388
375
  await this.offlineOff();
@@ -542,20 +529,6 @@ export class Lock {
542
529
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
543
530
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
544
531
  }
545
-
546
- // FirmwareRevision
547
- if (this.FirmwareRevision === undefined) {
548
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
549
- } else {
550
- this.accessory.context.FirmwareRevision = this.FirmwareRevision;
551
- this.lockService.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
552
- this.batteryService.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
553
- if (this.device.lock?.hide_contactsensor) {
554
- this.contactSensorService!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
555
- }
556
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
557
- + `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
558
- }
559
532
  }
560
533
 
561
534
  async stopScanning(switchbot: any) {
@@ -672,38 +645,16 @@ export class Lock {
672
645
  this.lockService.updateCharacteristic(this.platform.Characteristic.LockCurrentState, e);
673
646
  }
674
647
 
675
- async setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig) {
676
- await this.refreshStatus();
677
- if (device.firmware) {
678
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
679
- accessory.context.FirmwareRevision = device.firmware;
680
- this.FirmwareRevision = accessory.context.FirmwareRevision;
681
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
682
- } else if (device.version) {
683
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version: ${device.version}`);
684
- accessory.context.FirmwareRevision = device.version;
685
- this.FirmwareRevision = accessory.context.FirmwareRevision;
686
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version, FirmwareRevision: ${this.FirmwareRevision}`);
687
- } else {
688
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
689
- accessory.context.FirmwareRevision = this.platform.version;
690
- this.FirmwareRevision = accessory.context.FirmwareRevision;
691
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version, FirmwareRevision: ${this.FirmwareRevision}`);
692
- }
693
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
694
- accessory
695
- .getService(this.platform.Service.AccessoryInformation)!
696
- .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
697
- .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
698
- .updateValue(this.FirmwareRevision);
699
- }
700
-
701
648
  async context() {
702
649
  if (this.LockTargetState === undefined) {
703
650
  this.LockTargetState = false;
704
651
  } else {
705
652
  this.LockTargetState = this.accessory.context.On;
706
653
  }
654
+ if (this.FirmwareRevision === undefined) {
655
+ this.FirmwareRevision = this.platform.version;
656
+ this.accessory.context.FirmwareRevision = this.FirmwareRevision;
657
+ }
707
658
  }
708
659
 
709
660
  async refreshRate(device: device & devicesConfig): Promise<void> {