@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
@@ -1,3 +1,4 @@
1
+ /* eslint-disable brace-style */
1
2
  import { Context } from 'vm';
2
3
  import { request } from 'undici';
3
4
  import { sleep } from '../utils';
@@ -24,6 +25,7 @@ export class CeilingLight {
24
25
  ColorTemperature?: CharacteristicValue;
25
26
 
26
27
  // OpenAPI Others
28
+ Version: deviceStatus['version'];
27
29
  power: deviceStatus['power'];
28
30
  color: deviceStatus['color'];
29
31
  brightness: deviceStatus['brightness'];
@@ -59,17 +61,22 @@ export class CeilingLight {
59
61
  doCeilingLightUpdate!: 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
76
  this.adaptiveLighting(device);
71
- this.config(device);
72
77
  this.context();
78
+ this.config(device);
79
+
73
80
  // this is subject we use to track when we need to POST changes to the SwitchBot API
74
81
  this.doCeilingLightUpdate = new Subject();
75
82
  this.ceilingLightUpdateInProgress = false;
@@ -202,8 +209,10 @@ export class CeilingLight {
202
209
  await this.pushChanges();
203
210
  } catch (e: any) {
204
211
  this.apiError(e);
205
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType} Connection,`
206
- + ` Error Message: ${JSON.stringify(e.message)}`);
212
+ this.errorLog(
213
+ `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType} Connection,` +
214
+ ` Error Message: ${JSON.stringify(e.message)}`,
215
+ );
207
216
  }
208
217
  this.ceilingLightUpdateInProgress = false;
209
218
  });
@@ -227,14 +236,16 @@ export class CeilingLight {
227
236
  async parseStatus(): Promise<void> {
228
237
  if (!this.device.enableCloudService && this.OpenAPI) {
229
238
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} parseStatus enableCloudService: ${this.device.enableCloudService}`);
230
- } else /*if (this.BLE) {
239
+ }
240
+ /*if (this.BLE) {
231
241
  await this.BLEparseStatus();
232
- } else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
242
+ } else*/ else if (this.OpenAPI && this.platform.config.credentials?.token) {
233
243
  await this.openAPIparseStatus();
234
244
  } else {
235
245
  await this.offlineOff();
236
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
237
- + ` ${this.device.connectionType}, parseStatus will not happen.`);
246
+ this.debugWarnLog(
247
+ `${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` + ` ${this.device.connectionType}, parseStatus will not happen.`,
248
+ );
238
249
  }
239
250
  }
240
251
 
@@ -275,8 +286,9 @@ export class CeilingLight {
275
286
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} blue: ${JSON.stringify(blue)}`);
276
287
 
277
288
  const [hue, saturation] = rgb2hs(Number(red), Number(green), Number(blue));
278
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
279
- + ` hs: ${JSON.stringify(rgb2hs(Number(red), Number(green), Number(blue)))}`);
289
+ this.debugLog(
290
+ `${this.device.deviceType}: ${this.accessory.displayName}` + ` hs: ${JSON.stringify(rgb2hs(Number(red), Number(green), Number(blue)))}`,
291
+ );
280
292
 
281
293
  // Hue
282
294
  this.Hue = hue;
@@ -305,14 +317,16 @@ export class CeilingLight {
305
317
  async refreshStatus(): Promise<void> {
306
318
  if (!this.device.enableCloudService && this.OpenAPI) {
307
319
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus enableCloudService: ${this.device.enableCloudService}`);
308
- } else/*if (this.BLE) {
320
+ } /*if (this.BLE) {
309
321
  await this.BLERefreshStatus();
310
- } else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
322
+ } else*/ else if (this.OpenAPI && this.platform.config.credentials?.token) {
311
323
  await this.openAPIRefreshStatus();
312
324
  } else {
313
325
  await this.offlineOff();
314
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
315
- + ` ${this.device.connectionType}, refreshStatus will not happen.`);
326
+ this.debugWarnLog(
327
+ `${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` +
328
+ ` ${this.device.connectionType}, refreshStatus will not happen.`,
329
+ );
316
330
  }
317
331
  }
318
332
 
@@ -337,8 +351,10 @@ export class CeilingLight {
337
351
  // Set an event hander
338
352
  switchbot.onadvertisement = async (ad: any) => {
339
353
  this.address = ad.address;
340
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},`
341
- + ` BLE Address Found: ${this.address}`);
354
+ this.debugLog(
355
+ `${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
356
+ ` BLE Address Found: ${this.address}`,
357
+ );
342
358
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
343
359
  this.serviceData = ad.serviceData;
344
360
  //this.state = ad.serviceData.state;
@@ -373,8 +389,10 @@ export class CeilingLight {
373
389
  })
374
390
  .catch(async (e: any) => {
375
391
  this.apiError(e);
376
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed BLERefreshStatus with ${this.device.connectionType}`
377
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
392
+ this.errorLog(
393
+ `${this.device.deviceType}: ${this.accessory.displayName} failed BLERefreshStatus with ${this.device.connectionType}` +
394
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
395
+ );
378
396
  await this.BLERefreshConnection(switchbot);
379
397
  });
380
398
  } else {
@@ -392,10 +410,7 @@ export class CeilingLight {
392
410
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
393
411
  this.statusCode(statusCode);
394
412
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
395
- this.debugLog(
396
- `${this.device.deviceType}: ${this.accessory.displayName
397
- } refreshStatus: ${JSON.stringify(deviceStatus)}`,
398
- );
413
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
399
414
  this.power = deviceStatus.body.power;
400
415
  this.color = deviceStatus.body.color;
401
416
  this.brightness = deviceStatus.body.brightness;
@@ -404,8 +419,10 @@ export class CeilingLight {
404
419
  this.updateHomeKitCharacteristics();
405
420
  } catch (e: any) {
406
421
  this.apiError(e);
407
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}`
408
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
422
+ this.errorLog(
423
+ `${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}` +
424
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
425
+ );
409
426
  }
410
427
  }
411
428
 
@@ -423,14 +440,15 @@ export class CeilingLight {
423
440
  async pushChanges(): Promise<void> {
424
441
  if (!this.device.enableCloudService && this.OpenAPI) {
425
442
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
426
- } else /*if (this.BLE) {
443
+ } /*if (this.BLE) {
427
444
  await this.BLEpushChanges();
428
- } else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
445
+ } else*/ else if (this.OpenAPI && this.platform.config.credentials?.token) {
429
446
  await this.openAPIpushChanges();
430
447
  } else {
431
448
  await this.offlineOff();
432
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
433
- + ` ${this.device.connectionType}, pushChanges will not happen.`);
449
+ this.debugWarnLog(
450
+ `${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` + ` ${this.device.connectionType}, pushChanges will not happen.`,
451
+ );
434
452
  }
435
453
  // Refresh the status from the API
436
454
  interval(15000)
@@ -476,14 +494,15 @@ export class CeilingLight {
476
494
  })
477
495
  .catch(async (e: any) => {
478
496
  this.apiError(e);
479
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed BLEpushChanges with ${this.device.connectionType}`
480
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
497
+ this.errorLog(
498
+ `${this.device.deviceType}: ${this.accessory.displayName} failed BLEpushChanges with ${this.device.connectionType}` +
499
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
500
+ );
481
501
  await this.BLEPushConnection();
482
502
  });
483
503
  } else {
484
504
  this.debugLog(
485
- `${this.device.deviceType}: ${this.accessory.displayName} No BLEpushChanges.` + `On: ${this.On}, `
486
- + `OnCached: ${this.accessory.context.On}`,
505
+ `${this.device.deviceType}: ${this.accessory.displayName} No BLEpushChanges.` + `On: ${this.On}, ` + `OnCached: ${this.accessory.context.On}`,
487
506
  );
488
507
  }
489
508
  }
@@ -498,9 +517,9 @@ export class CeilingLight {
498
517
  command = 'turnOff';
499
518
  }
500
519
  const bodyChange = JSON.stringify({
501
- 'command': `${command}`,
502
- 'parameter': 'default',
503
- 'commandType': 'command',
520
+ command: `${command}`,
521
+ parameter: 'default',
522
+ commandType: 'command',
504
523
  });
505
524
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
506
525
  try {
@@ -515,13 +534,17 @@ export class CeilingLight {
515
534
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
516
535
  } catch (e: any) {
517
536
  this.apiError(e);
518
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIpushChanges with ${this.device.connectionType}`
519
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`,
537
+ this.errorLog(
538
+ `${this.device.deviceType}: ${this.accessory.displayName} failed openAPIpushChanges with ${this.device.connectionType}` +
539
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
520
540
  );
521
541
  }
522
542
  } else {
523
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No openAPIpushChanges.` + `On: ${this.On}, `
524
- + `OnCached: ${this.accessory.context.On}`);
543
+ this.debugLog(
544
+ `${this.device.deviceType}: ${this.accessory.displayName} No openAPIpushChanges.` +
545
+ `On: ${this.On}, ` +
546
+ `OnCached: ${this.accessory.context.On}`,
547
+ );
525
548
  }
526
549
  // Push Hue & Saturation Update
527
550
  if (this.On) {
@@ -545,9 +568,9 @@ export class CeilingLight {
545
568
  const [red, green, blue] = hs2rgb(Number(this.Hue), Number(this.Saturation));
546
569
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} rgb: ${JSON.stringify([red, green, blue])}`);
547
570
  const bodyChange = JSON.stringify({
548
- 'command': 'setColor',
549
- 'parameter': `${red}:${green}:${blue}`,
550
- 'commandType': 'command',
571
+ command: 'setColor',
572
+ parameter: `${red}:${green}:${blue}`,
573
+ commandType: 'command',
551
574
  });
552
575
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
553
576
  try {
@@ -562,13 +585,16 @@ export class CeilingLight {
562
585
  this.debugLog(`Headers: ${JSON.stringify(headers)}`);
563
586
  } catch (e: any) {
564
587
  this.apiError(e);
565
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushHueSaturationChanges with ${this.device.connectionType}`
566
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`,
588
+ this.errorLog(
589
+ `${this.device.deviceType}: ${this.accessory.displayName} failed pushHueSaturationChanges with ${this.device.connectionType}` +
590
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
567
591
  );
568
592
  }
569
593
  } else {
570
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No pushHueSaturationChanges. Hue: ${this.Hue}, `
571
- + `HueCached: ${this.accessory.context.Hue}, Saturation: ${this.Saturation}, SaturationCached: ${this.accessory.context.Saturation}`);
594
+ this.debugLog(
595
+ `${this.device.deviceType}: ${this.accessory.displayName} No pushHueSaturationChanges. Hue: ${this.Hue}, ` +
596
+ `HueCached: ${this.accessory.context.Hue}, Saturation: ${this.Saturation}, SaturationCached: ${this.accessory.context.Saturation}`,
597
+ );
572
598
  }
573
599
  }
574
600
 
@@ -578,9 +604,9 @@ export class CeilingLight {
578
604
  const kelvin = Math.round(1000000 / Number(this.ColorTemperature));
579
605
  this.cacheKelvin = kelvin;
580
606
  const bodyChange = JSON.stringify({
581
- 'command': 'setColorTemperature',
582
- 'parameter': `${kelvin}`,
583
- 'commandType': 'command',
607
+ command: 'setColorTemperature',
608
+ parameter: `${kelvin}`,
609
+ commandType: 'command',
584
610
  });
585
611
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
586
612
  try {
@@ -595,13 +621,16 @@ export class CeilingLight {
595
621
  this.debugLog(`Headers: ${JSON.stringify(headers)}`);
596
622
  } catch (e: any) {
597
623
  this.apiError(e);
598
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushColorTemperatureChanges with ${this.device.connectionType}`
599
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`,
624
+ this.errorLog(
625
+ `${this.device.deviceType}: ${this.accessory.displayName} failed pushColorTemperatureChanges with ${this.device.connectionType}` +
626
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
600
627
  );
601
628
  }
602
629
  } else {
603
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No pushColorTemperatureChanges.` +
604
- `ColorTemperature: ${this.ColorTemperature}, ColorTemperatureCached: ${this.accessory.context.ColorTemperature}`);
630
+ this.debugLog(
631
+ `${this.device.deviceType}: ${this.accessory.displayName} No pushColorTemperatureChanges.` +
632
+ `ColorTemperature: ${this.ColorTemperature}, ColorTemperatureCached: ${this.accessory.context.ColorTemperature}`,
633
+ );
605
634
  }
606
635
  }
607
636
 
@@ -609,9 +638,9 @@ export class CeilingLight {
609
638
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushBrightnessChanges`);
610
639
  if (this.Brightness !== this.accessory.context.Brightness) {
611
640
  const bodyChange = JSON.stringify({
612
- 'command': 'setBrightness',
613
- 'parameter': `${this.Brightness}`,
614
- 'commandType': 'command',
641
+ command: 'setBrightness',
642
+ parameter: `${this.Brightness}`,
643
+ commandType: 'command',
615
644
  });
616
645
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
617
646
  try {
@@ -626,13 +655,17 @@ export class CeilingLight {
626
655
  this.debugLog(`Headers: ${JSON.stringify(headers)}`);
627
656
  } catch (e: any) {
628
657
  this.apiError(e);
629
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushBrightnessChanges with ${this.device.connectionType}`
630
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`,
658
+ this.errorLog(
659
+ `${this.device.deviceType}: ${this.accessory.displayName} failed pushBrightnessChanges with ${this.device.connectionType}` +
660
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
631
661
  );
632
662
  }
633
663
  } else {
634
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No pushBrightnessChanges.` + `Brightness: ${this.Brightness}, `
635
- + `BrightnessCached: ${this.accessory.context.Brightness}`);
664
+ this.debugLog(
665
+ `${this.device.deviceType}: ${this.accessory.displayName} No pushBrightnessChanges.` +
666
+ `Brightness: ${this.Brightness}, ` +
667
+ `BrightnessCached: ${this.accessory.context.Brightness}`,
668
+ );
636
669
  }
637
670
  }
638
671
 
@@ -884,8 +917,10 @@ export class CeilingLight {
884
917
  this.offlineOff();
885
918
  break;
886
919
  case 171:
887
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. `
888
- + `Hub: ${this.device.hubDeviceId}`);
920
+ this.errorLog(
921
+ `${this.device.deviceType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
922
+ `Hub: ${this.device.hubDeviceId}`,
923
+ );
889
924
  this.offlineOff();
890
925
  break;
891
926
  case 190:
@@ -901,8 +936,10 @@ export class CeilingLight {
901
936
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
902
937
  break;
903
938
  default:
904
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode: `
905
- + `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
939
+ this.infoLog(
940
+ `${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode: ` +
941
+ `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
942
+ );
906
943
  }
907
944
  }
908
945
 
@@ -923,14 +960,17 @@ export class CeilingLight {
923
960
 
924
961
  FirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
925
962
  let FirmwareRevision: string;
926
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
927
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
963
+ this.debugLog(
964
+ `${this.device.deviceType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
965
+ );
928
966
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
929
967
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
930
- if (accessory.context.FirmwareRevision) {
931
- FirmwareRevision = accessory.context.FirmwareRevision;
932
- } else if (device.firmware) {
968
+ if (device.firmware) {
933
969
  FirmwareRevision = device.firmware;
970
+ } else if (device.version) {
971
+ FirmwareRevision = JSON.stringify(device.version);
972
+ } else if (accessory.context.FirmwareRevision) {
973
+ FirmwareRevision = accessory.context.FirmwareRevision;
934
974
  } else {
935
975
  FirmwareRevision = this.platform.version;
936
976
  }
@@ -1004,7 +1044,7 @@ export class CeilingLight {
1004
1044
  config['maxRetry'] = device.maxRetry;
1005
1045
  }
1006
1046
  if (Object.entries(config).length !== 0) {
1007
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
1047
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
1008
1048
  }
1009
1049
  }
1010
1050