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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/.prettierrc +1 -1
  2. package/.vscode/settings.json +1 -1
  3. package/CHANGELOG.md +10 -0
  4. package/config.schema.json +8 -0
  5. package/dist/device/blindtilt.d.ts +1 -0
  6. package/dist/device/blindtilt.d.ts.map +1 -1
  7. package/dist/device/blindtilt.js +58 -65
  8. package/dist/device/blindtilt.js.map +1 -1
  9. package/dist/device/bot.d.ts +1 -0
  10. package/dist/device/bot.d.ts.map +1 -1
  11. package/dist/device/bot.js +52 -55
  12. package/dist/device/bot.js.map +1 -1
  13. package/dist/device/ceilinglight.d.ts +1 -0
  14. package/dist/device/ceilinglight.d.ts.map +1 -1
  15. package/dist/device/ceilinglight.js +68 -68
  16. package/dist/device/ceilinglight.js.map +1 -1
  17. package/dist/device/colorbulb.d.ts +1 -0
  18. package/dist/device/colorbulb.d.ts.map +1 -1
  19. package/dist/device/colorbulb.js +76 -75
  20. package/dist/device/colorbulb.js.map +1 -1
  21. package/dist/device/contact.d.ts +2 -0
  22. package/dist/device/contact.d.ts.map +1 -1
  23. package/dist/device/contact.js +67 -59
  24. package/dist/device/contact.js.map +1 -1
  25. package/dist/device/curtain.d.ts +2 -0
  26. package/dist/device/curtain.d.ts.map +1 -1
  27. package/dist/device/curtain.js +81 -94
  28. package/dist/device/curtain.js.map +1 -1
  29. package/dist/device/hub.d.ts +9 -1
  30. package/dist/device/hub.d.ts.map +1 -1
  31. package/dist/device/hub.js +197 -30
  32. package/dist/device/hub.js.map +1 -1
  33. package/dist/device/humidifier.d.ts.map +1 -1
  34. package/dist/device/humidifier.js +58 -62
  35. package/dist/device/humidifier.js.map +1 -1
  36. package/dist/device/iosensor.d.ts +1 -0
  37. package/dist/device/iosensor.d.ts.map +1 -1
  38. package/dist/device/iosensor.js +28 -26
  39. package/dist/device/iosensor.js.map +1 -1
  40. package/dist/device/lightstrip.d.ts +1 -0
  41. package/dist/device/lightstrip.d.ts.map +1 -1
  42. package/dist/device/lightstrip.js +68 -67
  43. package/dist/device/lightstrip.js.map +1 -1
  44. package/dist/device/lock.d.ts +2 -0
  45. package/dist/device/lock.d.ts.map +1 -1
  46. package/dist/device/lock.js +51 -47
  47. package/dist/device/lock.js.map +1 -1
  48. package/dist/device/meter.d.ts +5 -3
  49. package/dist/device/meter.d.ts.map +1 -1
  50. package/dist/device/meter.js +75 -74
  51. package/dist/device/meter.js.map +1 -1
  52. package/dist/device/meterplus.d.ts +4 -3
  53. package/dist/device/meterplus.d.ts.map +1 -1
  54. package/dist/device/meterplus.js +74 -74
  55. package/dist/device/meterplus.js.map +1 -1
  56. package/dist/device/motion.d.ts +2 -0
  57. package/dist/device/motion.d.ts.map +1 -1
  58. package/dist/device/motion.js +66 -54
  59. package/dist/device/motion.js.map +1 -1
  60. package/dist/device/plug.d.ts +1 -0
  61. package/dist/device/plug.d.ts.map +1 -1
  62. package/dist/device/plug.js +39 -39
  63. package/dist/device/plug.js.map +1 -1
  64. package/dist/device/robotvacuumcleaner.d.ts +1 -0
  65. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  66. package/dist/device/robotvacuumcleaner.js +74 -53
  67. package/dist/device/robotvacuumcleaner.js.map +1 -1
  68. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  69. package/dist/irdevice/airconditioner.js +64 -66
  70. package/dist/irdevice/airconditioner.js.map +1 -1
  71. package/dist/irdevice/airpurifier.d.ts +1 -1
  72. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  73. package/dist/irdevice/airpurifier.js +32 -34
  74. package/dist/irdevice/airpurifier.js.map +1 -1
  75. package/dist/irdevice/camera.d.ts +1 -1
  76. package/dist/irdevice/camera.d.ts.map +1 -1
  77. package/dist/irdevice/camera.js +20 -23
  78. package/dist/irdevice/camera.js.map +1 -1
  79. package/dist/irdevice/fan.d.ts +2 -2
  80. package/dist/irdevice/fan.d.ts.map +1 -1
  81. package/dist/irdevice/fan.js +30 -32
  82. package/dist/irdevice/fan.js.map +1 -1
  83. package/dist/irdevice/light.d.ts +1 -1
  84. package/dist/irdevice/light.d.ts.map +1 -1
  85. package/dist/irdevice/light.js +26 -29
  86. package/dist/irdevice/light.js.map +1 -1
  87. package/dist/irdevice/other.d.ts +1 -1
  88. package/dist/irdevice/other.d.ts.map +1 -1
  89. package/dist/irdevice/other.js +22 -23
  90. package/dist/irdevice/other.js.map +1 -1
  91. package/dist/irdevice/tv.d.ts +2 -2
  92. package/dist/irdevice/tv.d.ts.map +1 -1
  93. package/dist/irdevice/tv.js +47 -50
  94. package/dist/irdevice/tv.js.map +1 -1
  95. package/dist/irdevice/vacuumcleaner.d.ts +1 -1
  96. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  97. package/dist/irdevice/vacuumcleaner.js +20 -23
  98. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  99. package/dist/irdevice/waterheater.d.ts +1 -1
  100. package/dist/irdevice/waterheater.d.ts.map +1 -1
  101. package/dist/irdevice/waterheater.js +22 -23
  102. package/dist/irdevice/waterheater.js.map +1 -1
  103. package/dist/platform.d.ts.map +1 -1
  104. package/dist/platform.js +46 -44
  105. package/dist/platform.js.map +1 -1
  106. package/dist/settings.d.ts +1 -0
  107. package/dist/settings.d.ts.map +1 -1
  108. package/dist/settings.js.map +1 -1
  109. package/dist/utils.js +1 -1
  110. package/dist/utils.js.map +1 -1
  111. package/package.json +3 -3
  112. package/src/device/blindtilt.ts +114 -78
  113. package/src/device/bot.ts +102 -63
  114. package/src/device/ceilinglight.ts +113 -73
  115. package/src/device/colorbulb.ts +144 -87
  116. package/src/device/contact.ts +98 -63
  117. package/src/device/curtain.ts +160 -134
  118. package/src/device/hub.ts +228 -39
  119. package/src/device/humidifier.ts +136 -85
  120. package/src/device/iosensor.ts +52 -32
  121. package/src/device/lightstrip.ts +118 -72
  122. package/src/device/lock.ts +85 -50
  123. package/src/device/meter.ts +104 -80
  124. package/src/device/meterplus.ts +103 -80
  125. package/src/device/motion.ts +95 -59
  126. package/src/device/plug.ts +70 -44
  127. package/src/device/robotvacuumcleaner.ts +107 -56
  128. package/src/irdevice/airconditioner.ts +116 -86
  129. package/src/irdevice/airpurifier.ts +60 -39
  130. package/src/irdevice/camera.ts +40 -28
  131. package/src/irdevice/fan.ts +52 -38
  132. package/src/irdevice/light.ts +48 -34
  133. package/src/irdevice/other.ts +44 -28
  134. package/src/irdevice/tv.ts +70 -56
  135. package/src/irdevice/vacuumcleaner.ts +40 -28
  136. package/src/irdevice/waterheater.ts +48 -32
  137. package/src/platform.ts +87 -56
  138. package/src/settings.ts +41 -40
  139. package/src/utils.ts +1 -1
@@ -27,6 +27,8 @@ export class Contact {
27
27
  StatusLowBattery!: CharacteristicValue;
28
28
 
29
29
  // OpenAPI others
30
+ Version: deviceStatus['version'];
31
+ Battery: deviceStatus['battery'];
30
32
  openState: deviceStatus['openState'];
31
33
  moveDetected: deviceStatus['moveDetected'];
32
34
  brightness: deviceStatus['brightness'];
@@ -59,16 +61,20 @@ export class Contact {
59
61
  doContactUpdate!: Subject<void>;
60
62
 
61
63
  // Connection
62
- private readonly BLE = (this.device.connectionType === 'BLE' || this.device.connectionType === 'BLE/OpenAPI');
63
- private readonly OpenAPI = (this.device.connectionType === 'OpenAPI' || this.device.connectionType === 'BLE/OpenAPI');
64
-
65
- constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: device & devicesConfig) {
64
+ private readonly BLE = this.device.connectionType === 'BLE' || this.device.connectionType === 'BLE/OpenAPI';
65
+ private readonly OpenAPI = this.device.connectionType === 'OpenAPI' || this.device.connectionType === 'BLE/OpenAPI';
66
+
67
+ constructor(
68
+ private readonly platform: SwitchBotPlatform,
69
+ private accessory: PlatformAccessory,
70
+ public device: device & devicesConfig,
71
+ ) {
66
72
  // default placeholders
67
73
  this.logs(device);
68
74
  this.scan(device);
69
75
  this.refreshRate(device);
70
- this.config(device);
71
76
  this.context();
77
+ this.config(device);
72
78
 
73
79
  // this is subject we use to track when we need to POST changes to the SwitchBot API
74
80
  this.doContactUpdate = new Subject();
@@ -141,17 +147,16 @@ export class Contact {
141
147
  }
142
148
 
143
149
  // Battery Service
144
- if (!this.BLE) {
145
- this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Battery Service`);
146
- this.batteryService = this.accessory.getService(this.platform.Service.Battery);
147
- accessory.removeService(this.batteryService!);
148
- } else if (this.BLE && !this.batteryService) {
150
+ if (!this.batteryService) {
149
151
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Battery Service`);
150
152
  (this.batteryService = this.accessory.getService(this.platform.Service.Battery) || this.accessory.addService(this.platform.Service.Battery)),
151
153
  `${accessory.displayName} Battery`;
152
154
 
153
155
  this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
154
- this.batteryService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Battery`);
156
+ if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
157
+ this.batteryService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Battery`);
158
+ }
159
+ this.batteryService.setCharacteristic(this.platform.Characteristic.ChargingState, this.platform.Characteristic.ChargingState.NOT_CHARGEABLE);
155
160
  } else {
156
161
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Battery Service Not Added`);
157
162
  }
@@ -179,8 +184,9 @@ export class Contact {
179
184
  await this.openAPIparseStatus();
180
185
  } else {
181
186
  await this.offlineOff();
182
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
183
- + ` ${this.device.connectionType}, parseStatus will not happen.`);
187
+ this.debugWarnLog(
188
+ `${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` + ` ${this.device.connectionType}, parseStatus will not happen.`,
189
+ );
184
190
  }
185
191
  }
186
192
 
@@ -200,15 +206,17 @@ export class Contact {
200
206
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} timeout no closed, doorstate: ${this.doorState}`);
201
207
  }
202
208
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ContactSensorState: ${this.ContactSensorState}`);
203
- if ((this.ContactSensorState !== this.accessory.context.ContactSensorState)
204
- && this.platform.Characteristic.ContactSensorState.CONTACT_NOT_DETECTED) {
209
+ if (
210
+ this.ContactSensorState !== this.accessory.context.ContactSensorState &&
211
+ this.platform.Characteristic.ContactSensorState.CONTACT_NOT_DETECTED
212
+ ) {
205
213
  this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Opened`);
206
214
  }
207
215
  // Movement
208
216
  if (!this.device.contact?.hide_motionsensor) {
209
217
  this.MotionDetected = Boolean(this.movement);
210
218
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} MotionDetected: ${this.MotionDetected}`);
211
- if ((this.MotionDetected !== this.accessory.context.MotionDetected) && this.MotionDetected) {
219
+ if (this.MotionDetected !== this.accessory.context.MotionDetected && this.MotionDetected) {
212
220
  this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Detected Motion`);
213
221
  }
214
222
  }
@@ -223,8 +231,10 @@ export class Contact {
223
231
  default:
224
232
  this.CurrentAmbientLightLevel = this.set_maxLux;
225
233
  }
226
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.is_light},` +
227
- ` CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
234
+ this.debugLog(
235
+ `${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.is_light},` +
236
+ ` CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`,
237
+ );
228
238
  if (this.CurrentAmbientLightLevel !== this.accessory.context.CurrentAmbientLightLevel) {
229
239
  this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
230
240
  }
@@ -239,8 +249,9 @@ export class Contact {
239
249
  } else {
240
250
  this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
241
251
  }
242
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}, `
243
- + `StatusLowBattery: ${this.StatusLowBattery}`);
252
+ this.debugLog(
253
+ `${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}, ` + `StatusLowBattery: ${this.StatusLowBattery}`,
254
+ );
244
255
  }
245
256
 
246
257
  async openAPIparseStatus(): Promise<void> {
@@ -274,6 +285,19 @@ export class Contact {
274
285
  }
275
286
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
276
287
  }
288
+ // Battery
289
+ if (this.battery === undefined) {
290
+ this.battery === 100;
291
+ }
292
+ this.BatteryLevel = Number(this.Battery);
293
+ if (this.BatteryLevel < 10) {
294
+ this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
295
+ } else {
296
+ this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
297
+ }
298
+ this.debugLog(
299
+ `${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}, ` + `StatusLowBattery: ${this.StatusLowBattery}`,
300
+ );
277
301
  }
278
302
 
279
303
  /**
@@ -288,8 +312,10 @@ export class Contact {
288
312
  await this.openAPIRefreshStatus();
289
313
  } else {
290
314
  await this.offlineOff();
291
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
292
- + ` ${this.device.connectionType}, refreshStatus will not happen.`);
315
+ this.debugWarnLog(
316
+ `${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` +
317
+ ` ${this.device.connectionType}, refreshStatus will not happen.`,
318
+ );
293
319
  }
294
320
  }
295
321
 
@@ -317,8 +343,10 @@ export class Contact {
317
343
  this.scanning = true;
318
344
  switchbot.onadvertisement = async (ad: any) => {
319
345
  this.address = ad.address;
320
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},`
321
- + ` BLE Address Found: ${this.address}`);
346
+ this.debugLog(
347
+ `${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
348
+ ` BLE Address Found: ${this.address}`,
349
+ );
322
350
  this.serviceData = ad.serviceData;
323
351
  this.movement = ad.serviceData.movement;
324
352
  this.tested = ad.serviceData.tested;
@@ -355,8 +383,10 @@ export class Contact {
355
383
  })
356
384
  .catch(async (e: any) => {
357
385
  this.apiError(e);
358
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed BLERefreshStatus with ${this.device.connectionType}`
359
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
386
+ this.errorLog(
387
+ `${this.device.deviceType}: ${this.accessory.displayName} failed BLERefreshStatus with ${this.device.connectionType}` +
388
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
389
+ );
360
390
  await this.BLERefreshConnection(switchbot);
361
391
  });
362
392
  } else {
@@ -374,19 +404,20 @@ export class Contact {
374
404
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
375
405
  this.statusCode(statusCode);
376
406
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
377
- this.debugLog(
378
- `${this.device.deviceType}: ${this.accessory.displayName
379
- } refreshStatus: ${JSON.stringify(deviceStatus)}`,
380
- );
407
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
381
408
  this.openState = deviceStatus.body.openState;
382
409
  this.moveDetected = deviceStatus.body.moveDetected;
383
410
  this.brightness = deviceStatus.body.brightness;
411
+ this.Battery = deviceStatus.body.battery!;
412
+ this.Version = deviceStatus.body.version!;
384
413
  this.openAPIparseStatus();
385
414
  this.updateHomeKitCharacteristics();
386
415
  } catch (e: any) {
387
416
  this.apiError(e);
388
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}`
389
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
417
+ this.errorLog(
418
+ `${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}` +
419
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
420
+ );
390
421
  }
391
422
  }
392
423
 
@@ -416,26 +447,25 @@ export class Contact {
416
447
  } else {
417
448
  this.accessory.context.CurrentAmbientLightLevel = this.CurrentAmbientLightLevel;
418
449
  this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, this.CurrentAmbientLightLevel);
419
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
420
- + ` updateCharacteristic CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`,
450
+ this.debugLog(
451
+ `${this.device.deviceType}: ${this.accessory.displayName}` +
452
+ ` updateCharacteristic CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`,
421
453
  );
422
454
  }
423
455
  }
424
- if (this.BLE) {
425
- if (this.BatteryLevel === undefined) {
426
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
427
- } else {
428
- this.accessory.context.BatteryLevel = this.BatteryLevel;
429
- this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel);
430
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
431
- }
432
- if (this.StatusLowBattery === undefined) {
433
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
434
- } else {
435
- this.accessory.context.StatusLowBattery = this.StatusLowBattery;
436
- this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
437
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
438
- }
456
+ if (this.BatteryLevel === undefined) {
457
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
458
+ } else {
459
+ this.accessory.context.BatteryLevel = this.BatteryLevel;
460
+ this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel);
461
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
462
+ }
463
+ if (this.StatusLowBattery === undefined) {
464
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
465
+ } else {
466
+ this.accessory.context.StatusLowBattery = this.StatusLowBattery;
467
+ this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
468
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
439
469
  }
440
470
  }
441
471
 
@@ -523,8 +553,10 @@ export class Contact {
523
553
  this.offlineOff();
524
554
  break;
525
555
  case 171:
526
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. `
527
- + `Hub: ${this.device.hubDeviceId}`);
556
+ this.errorLog(
557
+ `${this.device.deviceType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
558
+ `Hub: ${this.device.hubDeviceId}`,
559
+ );
528
560
  this.offlineOff();
529
561
  break;
530
562
  case 190:
@@ -540,8 +572,10 @@ export class Contact {
540
572
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
541
573
  break;
542
574
  default:
543
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode: `
544
- + `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
575
+ this.infoLog(
576
+ `${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode: ` +
577
+ `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
578
+ );
545
579
  }
546
580
  }
547
581
 
@@ -560,22 +594,23 @@ export class Contact {
560
594
  if (!this.device.contact?.hide_lightsensor) {
561
595
  this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, e);
562
596
  }
563
- if (this.BLE) {
564
- this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
565
- this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
566
- }
597
+ this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
598
+ this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
567
599
  }
568
600
 
569
601
  FirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
570
602
  let FirmwareRevision: string;
571
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
572
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
603
+ this.debugLog(
604
+ `${this.device.deviceType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
605
+ );
573
606
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
574
607
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
575
- if (accessory.context.FirmwareRevision) {
576
- FirmwareRevision = accessory.context.FirmwareRevision;
577
- } else if (device.firmware) {
608
+ if (device.firmware) {
578
609
  FirmwareRevision = device.firmware;
610
+ } else if (device.version) {
611
+ FirmwareRevision = JSON.stringify(device.version);
612
+ } else if (accessory.context.FirmwareRevision) {
613
+ FirmwareRevision = accessory.context.FirmwareRevision;
579
614
  } else {
580
615
  FirmwareRevision = this.platform.version;
581
616
  }
@@ -626,7 +661,7 @@ export class Contact {
626
661
  config['scanDuration'] = device.scanDuration;
627
662
  }
628
663
  if (Object.entries(config).length !== 0) {
629
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
664
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
630
665
  }
631
666
  }
632
667