@switchbot/homebridge-switchbot 3.5.1-beta.10 → 3.5.1-beta.11

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 (54) hide show
  1. package/dist/device/ceilinglight.d.ts.map +1 -1
  2. package/dist/device/ceilinglight.js +3 -4
  3. package/dist/device/ceilinglight.js.map +1 -1
  4. package/dist/device/colorbulb.js +1 -1
  5. package/dist/device/colorbulb.js.map +1 -1
  6. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  7. package/dist/irdevice/airconditioner.js +45 -51
  8. package/dist/irdevice/airconditioner.js.map +1 -1
  9. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  10. package/dist/irdevice/airpurifier.js +17 -17
  11. package/dist/irdevice/airpurifier.js.map +1 -1
  12. package/dist/irdevice/camera.d.ts.map +1 -1
  13. package/dist/irdevice/camera.js +9 -9
  14. package/dist/irdevice/camera.js.map +1 -1
  15. package/dist/irdevice/fan.d.ts.map +1 -1
  16. package/dist/irdevice/fan.js +19 -19
  17. package/dist/irdevice/fan.js.map +1 -1
  18. package/dist/irdevice/irdevice.d.ts +22 -10
  19. package/dist/irdevice/irdevice.d.ts.map +1 -1
  20. package/dist/irdevice/irdevice.js +89 -67
  21. package/dist/irdevice/irdevice.js.map +1 -1
  22. package/dist/irdevice/light.d.ts.map +1 -1
  23. package/dist/irdevice/light.js +15 -17
  24. package/dist/irdevice/light.js.map +1 -1
  25. package/dist/irdevice/other.d.ts.map +1 -1
  26. package/dist/irdevice/other.js +76 -76
  27. package/dist/irdevice/other.js.map +1 -1
  28. package/dist/irdevice/tv.d.ts.map +1 -1
  29. package/dist/irdevice/tv.js +35 -35
  30. package/dist/irdevice/tv.js.map +1 -1
  31. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  32. package/dist/irdevice/vacuumcleaner.js +9 -9
  33. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  34. package/dist/irdevice/waterheater.d.ts.map +1 -1
  35. package/dist/irdevice/waterheater.js +9 -9
  36. package/dist/irdevice/waterheater.js.map +1 -1
  37. package/dist/platform.d.ts +1 -1
  38. package/dist/platform.d.ts.map +1 -1
  39. package/dist/platform.js +202 -201
  40. package/dist/platform.js.map +1 -1
  41. package/package.json +1 -1
  42. package/src/device/ceilinglight.ts +3 -6
  43. package/src/device/colorbulb.ts +1 -1
  44. package/src/irdevice/airconditioner.ts +45 -51
  45. package/src/irdevice/airpurifier.ts +17 -17
  46. package/src/irdevice/camera.ts +9 -9
  47. package/src/irdevice/fan.ts +19 -19
  48. package/src/irdevice/irdevice.ts +92 -68
  49. package/src/irdevice/light.ts +15 -17
  50. package/src/irdevice/other.ts +76 -76
  51. package/src/irdevice/tv.ts +35 -35
  52. package/src/irdevice/vacuumcleaner.ts +9 -9
  53. package/src/irdevice/waterheater.ts +9 -9
  54. package/src/platform.ts +202 -201
package/dist/platform.js CHANGED
@@ -117,7 +117,7 @@ export class SwitchBotPlatform {
117
117
  }
118
118
  catch (e) {
119
119
  this.errorLog(`Failed to Discover, Error Message: ${e.message}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
120
- this.debugErrorLog(`Failed to Discover, Error: ${e}`);
120
+ await this.debugErrorLog(`Failed to Discover, Error: ${e}`);
121
121
  }
122
122
  });
123
123
  this.setupMqtt();
@@ -138,7 +138,7 @@ export class SwitchBotPlatform {
138
138
  this.mqttClient.subscribe('homebridge-switchbot/webhook/+');
139
139
  this.mqttClient.on('message', async (topic, message) => {
140
140
  try {
141
- await this.debugLog(`Received Webhook via MQTT: ${topic}=${message}`);
141
+ await await this.debugLog(`Received Webhook via MQTT: ${topic}=${message}`);
142
142
  const context = JSON.parse(message.toString());
143
143
  this.webhookEventHandler[context.deviceMac]?.(context);
144
144
  }
@@ -168,7 +168,7 @@ export class SwitchBotPlatform {
168
168
  request.on('data', async (data) => {
169
169
  try {
170
170
  const body = JSON.parse(data);
171
- this.debugLog(`Received Webhook: ${JSON.stringify(body)}`);
171
+ await this.debugLog(`Received Webhook: ${JSON.stringify(body)}`);
172
172
  if (this.config.options?.mqttURL) {
173
173
  const mac = body.context.deviceMac
174
174
  ?.toLowerCase()
@@ -211,9 +211,9 @@ export class SwitchBotPlatform {
211
211
  }),
212
212
  });
213
213
  const response = await body.json();
214
- this.debugLog(`setupWebhook: url:${url}`);
215
- this.debugLog(`setupWebhook: body:${JSON.stringify(response)}`);
216
- this.debugLog(`setupWebhook: statusCode:${statusCode}`);
214
+ await this.debugLog(`setupWebhook: url:${url}`);
215
+ await this.debugLog(`setupWebhook: body:${JSON.stringify(response)}`);
216
+ await this.debugLog(`setupWebhook: statusCode:${statusCode}`);
217
217
  if (statusCode !== 200 || response?.statusCode !== 100) {
218
218
  this.errorLog(`Failed to configure webhook. Existing webhook well be overridden. HTTP:${statusCode} API:${response?.statusCode} `
219
219
  + `message:${response?.message}`);
@@ -233,9 +233,9 @@ export class SwitchBotPlatform {
233
233
  }),
234
234
  });
235
235
  const response = await body.json();
236
- this.debugLog(`updateWebhook: url:${url}`);
237
- this.debugLog(`updateWebhook: body:${JSON.stringify(response)}`);
238
- this.debugLog(`updateWebhook: statusCode:${statusCode}`);
236
+ await this.debugLog(`updateWebhook: url:${url}`);
237
+ await this.debugLog(`updateWebhook: body:${JSON.stringify(response)}`);
238
+ await this.debugLog(`updateWebhook: statusCode:${statusCode}`);
239
239
  if (statusCode !== 200 || response?.statusCode !== 100) {
240
240
  this.errorLog(`Failed to update webhook. HTTP:${statusCode} API:${response?.statusCode} message:${response?.message}`);
241
241
  }
@@ -252,8 +252,8 @@ export class SwitchBotPlatform {
252
252
  }),
253
253
  });
254
254
  const response = await body.json();
255
- this.debugLog(`queryWebhook: body:${JSON.stringify(response)}`);
256
- this.debugLog(`queryWebhook: statusCode:${statusCode}`);
255
+ await this.debugLog(`queryWebhook: body:${JSON.stringify(response)}`);
256
+ await this.debugLog(`queryWebhook: statusCode:${statusCode}`);
257
257
  if (statusCode !== 200 || response?.statusCode !== 100) {
258
258
  this.errorLog(`Failed to query webhook. HTTP:${statusCode} API:${response?.statusCode} message:${response?.message}`);
259
259
  }
@@ -275,7 +275,7 @@ export class SwitchBotPlatform {
275
275
  }),
276
276
  });
277
277
  const response = await body.json();
278
- this.debugLog(`deleteWebhook: url:${url}, body:${JSON.stringify(response)}, statusCode:${statusCode}`);
278
+ await this.debugLog(`deleteWebhook: url:${url}, body:${JSON.stringify(response)}, statusCode:${statusCode}`);
279
279
  if (statusCode !== 200 || response?.statusCode !== 100) {
280
280
  this.errorLog(`Failed to delete webhook. HTTP:${statusCode} API:${response?.statusCode} message:${response?.message}`);
281
281
  }
@@ -293,8 +293,8 @@ export class SwitchBotPlatform {
293
293
  * This function is invoked when homebridge restores cached accessories from disk at startup.
294
294
  * It should be used to setup event handlers for characteristics and update respective values.
295
295
  */
296
- configureAccessory(accessory) {
297
- this.debugLog(`Loading accessory from cache: ${accessory.displayName}`);
296
+ async configureAccessory(accessory) {
297
+ await this.debugLog(`Loading accessory from cache: ${accessory.displayName}`);
298
298
  // add the restored accessory to the accessories cache so we can track if it has already been registered
299
299
  this.accessories.push(accessory);
300
300
  }
@@ -316,7 +316,7 @@ export class SwitchBotPlatform {
316
316
  platformConfig['pushRate'] = this.config.options.pushRate;
317
317
  }
318
318
  if (Object.entries(platformConfig).length !== 0) {
319
- this.debugWarnLog(`Platform Config: ${JSON.stringify(platformConfig)}`);
319
+ await this.debugWarnLog(`Platform Config: ${JSON.stringify(platformConfig)}`);
320
320
  }
321
321
  if (this.config.options) {
322
322
  // Device Config
@@ -431,7 +431,7 @@ export class SwitchBotPlatform {
431
431
  if (pluginConfig.credentials.token) {
432
432
  pluginConfig.credentials.openToken = undefined;
433
433
  }
434
- this.debugWarnLog(`token: ${pluginConfig.credentials.token}`);
434
+ await this.debugWarnLog(`token: ${pluginConfig.credentials.token}`);
435
435
  // save the config, ensuring we maintain pretty json
436
436
  writeFileSync(this.api.user.configPath(), JSON.stringify(currentConfig, null, 4));
437
437
  this.verifyConfig();
@@ -471,29 +471,29 @@ export class SwitchBotPlatform {
471
471
  let retryCount = 0;
472
472
  const maxRetries = this.maxRetries; // Maximum number of retries
473
473
  const delayBetweenRetries = this.delayBetweenRetries; // Delay between retries in milliseconds
474
- this.debugWarnLog(`Retry Count: ${retryCount}`);
475
- this.debugWarnLog(`Max Retries: ${maxRetries}`);
476
- this.debugWarnLog(`Delay Between Retries: ${delayBetweenRetries}`);
474
+ await this.debugWarnLog(`Retry Count: ${retryCount}`);
475
+ await this.debugWarnLog(`Max Retries: ${maxRetries}`);
476
+ await this.debugWarnLog(`Delay Between Retries: ${delayBetweenRetries}`);
477
477
  while (retryCount < maxRetries) {
478
478
  try {
479
479
  const { body, statusCode } = await request(Devices, {
480
480
  headers: this.generateHeaders(),
481
481
  });
482
- this.debugWarnLog(`statusCode: ${statusCode}`);
482
+ await this.debugWarnLog(`statusCode: ${statusCode}`);
483
483
  const devicesAPI = await body.json();
484
- this.debugWarnLog(`devicesAPI: ${JSON.stringify(devicesAPI)}`);
485
- this.debugWarnLog(`devicesAPI Body: ${JSON.stringify(devicesAPI.body)}`);
486
- this.debugWarnLog(`devicesAPI StatusCode: ${devicesAPI.statusCode}`);
484
+ await this.debugWarnLog(`devicesAPI: ${JSON.stringify(devicesAPI)}`);
485
+ await this.debugWarnLog(`devicesAPI Body: ${JSON.stringify(devicesAPI.body)}`);
486
+ await this.debugWarnLog(`devicesAPI StatusCode: ${devicesAPI.statusCode}`);
487
487
  if ((statusCode === 200 || statusCode === 100) && (devicesAPI.statusCode === 200 || devicesAPI.statusCode === 100)) {
488
- this.debugErrorLog(`statusCode: ${statusCode} & devicesAPI StatusCode: ${devicesAPI.statusCode}`);
488
+ await this.debugErrorLog(`statusCode: ${statusCode} & devicesAPI StatusCode: ${devicesAPI.statusCode}`);
489
489
  // SwitchBot Devices
490
490
  const deviceLists = devicesAPI.body.deviceList;
491
- this.debugWarnLog(`DeviceLists: ${JSON.stringify(deviceLists)}`);
492
- this.debugWarnLog(`DeviceLists Length: ${deviceLists.length}`);
491
+ await this.debugWarnLog(`DeviceLists: ${JSON.stringify(deviceLists)}`);
492
+ await this.debugWarnLog(`DeviceLists Length: ${deviceLists.length}`);
493
493
  if (!this.config.options?.devices) {
494
- this.debugLog(`SwitchBot Device Config Not Set: ${JSON.stringify(this.config.options?.devices)}`);
494
+ await this.debugLog(`SwitchBot Device Config Not Set: ${JSON.stringify(this.config.options?.devices)}`);
495
495
  if (deviceLists.length === 0) {
496
- this.debugLog(`SwitchBot API Currently Doesn't Have Any Devices With Cloud Services Enabled: ${JSON.stringify(devicesAPI.body)}`);
496
+ await this.debugLog(`SwitchBot API Has No Devices With Cloud Services Enabled: ${JSON.stringify(devicesAPI.body)}`);
497
497
  }
498
498
  else {
499
499
  const devices = deviceLists.map((v) => v);
@@ -508,9 +508,9 @@ export class SwitchBotPlatform {
508
508
  }
509
509
  }
510
510
  else if (this.config.credentials?.token && this.config.options.devices) {
511
- this.debugLog(`SwitchBot Device Config Set: ${JSON.stringify(this.config.options?.devices)}`);
511
+ await this.debugLog(`SwitchBot Device Config Set: ${JSON.stringify(this.config.options?.devices)}`);
512
512
  if (deviceLists.length === 0) {
513
- this.debugLog(`SwitchBot API Currently Doesn't Have Any Devices With Cloud Services Enabled: ${JSON.stringify(devicesAPI.body)}`);
513
+ await this.debugLog(`SwitchBot API Has No Devices With Cloud Services Enabled: ${JSON.stringify(devicesAPI.body)}`);
514
514
  }
515
515
  else {
516
516
  const deviceConfigs = this.config.options?.devices;
@@ -519,7 +519,7 @@ export class SwitchBotPlatform {
519
519
  ...itm,
520
520
  }));
521
521
  const devices = mergeBydeviceId(deviceLists, deviceConfigs);
522
- this.debugLog(`SwitchBot Devices: ${JSON.stringify(devices)}`);
522
+ await this.debugLog(`SwitchBot Devices: ${JSON.stringify(devices)}`);
523
523
  for (const device of devices) {
524
524
  if (!device.deviceType) {
525
525
  device.deviceType = device.configDeviceType;
@@ -541,12 +541,12 @@ export class SwitchBotPlatform {
541
541
  this.infoLog(`Total SwitchBot Devices Found: ${devicesAPI.body.deviceList.length}`);
542
542
  }
543
543
  else {
544
- this.debugLog(`Total SwitchBot Devices Found: ${devicesAPI.body.deviceList.length}`);
544
+ await this.debugLog(`Total SwitchBot Devices Found: ${devicesAPI.body.deviceList.length}`);
545
545
  }
546
546
  // IR Devices
547
547
  const irDeviceLists = devicesAPI.body.infraredRemoteList;
548
548
  if (!this.config.options?.irdevices) {
549
- this.debugLog(`IR Device Config Not Set: ${JSON.stringify(this.config.options?.irdevices)}`);
549
+ await this.debugLog(`IR Device Config Not Set: ${JSON.stringify(this.config.options?.irdevices)}`);
550
550
  const devices = irDeviceLists.map((v) => v);
551
551
  for (const device of devices) {
552
552
  if (device.remoteType) {
@@ -555,14 +555,14 @@ export class SwitchBotPlatform {
555
555
  }
556
556
  }
557
557
  else {
558
- this.debugLog(`IR Device Config Set: ${JSON.stringify(this.config.options?.irdevices)}`);
558
+ await this.debugLog(`IR Device Config Set: ${JSON.stringify(this.config.options?.irdevices)}`);
559
559
  const irDeviceConfig = this.config.options?.irdevices;
560
560
  const mergeIRBydeviceId = (a1, a2) => a1.map((itm) => ({
561
561
  ...a2.find((item) => item.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') === itm.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') && item),
562
562
  ...itm,
563
563
  }));
564
564
  const devices = mergeIRBydeviceId(irDeviceLists, irDeviceConfig);
565
- this.debugLog(`IR Devices: ${JSON.stringify(devices)}`);
565
+ await this.debugLog(`IR Devices: ${JSON.stringify(devices)}`);
566
566
  for (const device of devices) {
567
567
  this.createIRDevice(device);
568
568
  }
@@ -571,7 +571,7 @@ export class SwitchBotPlatform {
571
571
  this.infoLog(`Total IR Devices Found: ${devicesAPI.body.infraredRemoteList.length}`);
572
572
  }
573
573
  else {
574
- this.debugLog(`Total IR Devices Found: ${devicesAPI.body.infraredRemoteList.length}`);
574
+ await this.debugLog(`Total IR Devices Found: ${devicesAPI.body.infraredRemoteList.length}`);
575
575
  }
576
576
  break;
577
577
  }
@@ -588,12 +588,12 @@ export class SwitchBotPlatform {
588
588
  catch (e) {
589
589
  retryCount++;
590
590
  this.debugErrorLog(`Failed to Discover Devices, Error Message: ${JSON.stringify(e.message)}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
591
- this.debugErrorLog(`Failed to Discover Devices, Error: ${e}`);
591
+ await this.debugErrorLog(`Failed to Discover Devices, Error: ${e}`);
592
592
  }
593
593
  }
594
594
  }
595
595
  else if (!this.config.credentials?.token && this.config.options?.devices) {
596
- this.debugLog(`SwitchBot Device Manual Config Set: ${JSON.stringify(this.config.options?.devices)}`);
596
+ await this.debugLog(`SwitchBot Device Manual Config Set: ${JSON.stringify(this.config.options?.devices)}`);
597
597
  const deviceConfigs = this.config.options?.devices;
598
598
  const devices = deviceConfigs.map((v) => v);
599
599
  for (const device of devices) {
@@ -608,73 +608,73 @@ export class SwitchBotPlatform {
608
608
  this.errorLog('Neither SwitchBot Token or Device Config are not set.');
609
609
  }
610
610
  }
611
- createDevice(device) {
611
+ async createDevice(device) {
612
612
  switch (device.deviceType) {
613
613
  case 'Humidifier':
614
- this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
614
+ await this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
615
615
  this.createHumidifier(device);
616
616
  break;
617
617
  case 'Hub Mini':
618
- this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
618
+ await this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
619
619
  break;
620
620
  case 'Hub Plus':
621
- this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
621
+ await this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
622
622
  break;
623
623
  case 'Hub 2':
624
- this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
624
+ await this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
625
625
  this.createHub2(device);
626
626
  break;
627
627
  case 'Bot':
628
- this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
628
+ await this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
629
629
  this.createBot(device);
630
630
  break;
631
631
  case 'Meter':
632
- this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
632
+ await this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
633
633
  this.createMeter(device);
634
634
  break;
635
635
  case 'MeterPlus':
636
636
  case 'Meter Plus (JP)':
637
- this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
637
+ await this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
638
638
  this.createMeterPlus(device);
639
639
  break;
640
640
  case 'WoIOSensor':
641
- this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
641
+ await this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
642
642
  this.createIOSensor(device);
643
643
  break;
644
644
  case 'Water Detector':
645
- this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
645
+ await this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
646
646
  this.createWaterDetector(device);
647
647
  break;
648
648
  case 'Motion Sensor':
649
- this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
649
+ await this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
650
650
  this.createMotion(device);
651
651
  break;
652
652
  case 'Contact Sensor':
653
- this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
653
+ await this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
654
654
  this.createContact(device);
655
655
  break;
656
656
  case 'Curtain':
657
657
  case 'Curtain3':
658
- this.debugLog(`Discovered ${device.deviceType} ${device.deviceName}: ${device.deviceId}`);
658
+ await this.debugLog(`Discovered ${device.deviceType} ${device.deviceName}: ${device.deviceId}`);
659
659
  this.createCurtain(device);
660
660
  break;
661
661
  case 'Blind Tilt':
662
- this.debugLog(`Discovered ${device.deviceType} ${device.deviceName}: ${device.deviceId}`);
662
+ await this.debugLog(`Discovered ${device.deviceType} ${device.deviceName}: ${device.deviceId}`);
663
663
  this.createBlindTilt(device);
664
664
  break;
665
665
  case 'Plug':
666
666
  case 'Plug Mini (US)':
667
667
  case 'Plug Mini (JP)':
668
- this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
668
+ await this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
669
669
  this.createPlug(device);
670
670
  break;
671
671
  case 'Smart Lock':
672
672
  case 'Smart Lock Pro':
673
- this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
673
+ await this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
674
674
  this.createLock(device);
675
675
  break;
676
676
  case 'Color Bulb':
677
- this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
677
+ await this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
678
678
  this.createColorBulb(device);
679
679
  break;
680
680
  case 'K10+':
@@ -683,32 +683,32 @@ export class SwitchBotPlatform {
683
683
  case 'Robot Vacuum Cleaner S1':
684
684
  case 'Robot Vacuum Cleaner S1 Plus':
685
685
  case 'Robot Vacuum Cleaner S10':
686
- this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
686
+ await this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
687
687
  this.createRobotVacuumCleaner(device);
688
688
  break;
689
689
  case 'Ceiling Light':
690
690
  case 'Ceiling Light Pro':
691
- this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
691
+ await this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
692
692
  this.createCeilingLight(device);
693
693
  break;
694
694
  case 'Strip Light':
695
- this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
695
+ await this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
696
696
  this.createStripLight(device);
697
697
  break;
698
698
  case 'Battery Circulator Fan':
699
- this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
699
+ await this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
700
700
  this.createFan(device);
701
701
  break;
702
702
  case 'Remote':
703
703
  case 'Indoor Cam':
704
704
  case 'remote with screen+':
705
- this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}, is currently not supported, device: ${JSON.stringify(device)}`);
705
+ await this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}, is currently not supported, device: ${JSON.stringify(device)}`);
706
706
  break;
707
707
  default:
708
708
  this.warnLog(`Device: ${device.deviceName} with Device Type: ${device.deviceType}, is currently not supported.`, +`Submit Feature Requests Here: https://tinyurl.com/SwitchBotFeatureRequest, device: ${JSON.stringify(device)}`);
709
709
  }
710
710
  }
711
- createIRDevice(device) {
711
+ async createIRDevice(device) {
712
712
  if (device.connectionType === undefined) {
713
713
  device.connectionType = 'OpenAPI';
714
714
  }
@@ -725,7 +725,7 @@ export class SwitchBotPlatform {
725
725
  case 'DIY DVD':
726
726
  case 'Speaker':
727
727
  case 'DIY Speaker':
728
- this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
728
+ await this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
729
729
  if (device.external === undefined) {
730
730
  device.external = true;
731
731
  this.createTV(device);
@@ -736,45 +736,45 @@ export class SwitchBotPlatform {
736
736
  break;
737
737
  case 'Fan':
738
738
  case 'DIY Fan':
739
- this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
739
+ await this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
740
740
  this.createIRFan(device);
741
741
  break;
742
742
  case 'Air Conditioner':
743
743
  case 'DIY Air Conditioner':
744
- this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
744
+ await this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
745
745
  this.createAirConditioner(device);
746
746
  break;
747
747
  case 'Light':
748
748
  case 'DIY Light':
749
- this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
749
+ await this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
750
750
  this.createLight(device);
751
751
  break;
752
752
  case 'Air Purifier':
753
753
  case 'DIY Air Purifier':
754
- this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
754
+ await this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
755
755
  this.createAirPurifier(device);
756
756
  break;
757
757
  case 'Water Heater':
758
758
  case 'DIY Water Heater':
759
- this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
759
+ await this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
760
760
  this.createWaterHeater(device);
761
761
  break;
762
762
  case 'Vacuum Cleaner':
763
763
  case 'DIY Vacuum Cleaner':
764
- this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
764
+ await this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
765
765
  this.createVacuumCleaner(device);
766
766
  break;
767
767
  case 'Camera':
768
768
  case 'DIY Camera':
769
- this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
769
+ await this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
770
770
  this.createCamera(device);
771
771
  break;
772
772
  case 'Others':
773
- this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
773
+ await this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
774
774
  this.createOthers(device);
775
775
  break;
776
776
  default:
777
- this.debugLog(`Unsupported Device: ${JSON.stringify(device)}`);
777
+ await this.debugLog(`Unsupported Device: ${JSON.stringify(device)}`);
778
778
  this.warnLog(`Device: ${device.deviceName} with Device Type: ${device.remoteType}, is currently not supported.`);
779
779
  this.warnLog('Submit Feature Requests Here: ' + 'https://tinyurl.com/SwitchBotFeatureRequest');
780
780
  }
@@ -801,7 +801,7 @@ export class SwitchBotPlatform {
801
801
  // create the accessory handler for the restored accessory
802
802
  // this is imported from `platformAccessory.ts`
803
803
  new Humidifier(this, existingAccessory, device);
804
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
804
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
805
805
  }
806
806
  else {
807
807
  this.unregisterPlatformAccessories(existingAccessory);
@@ -827,13 +827,13 @@ export class SwitchBotPlatform {
827
827
  // create the accessory handler for the newly create accessory
828
828
  // this is imported from `platformAccessory.ts`
829
829
  new Humidifier(this, accessory, device);
830
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
830
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
831
831
  // publish device externally or link the accessory to your platform
832
832
  this.externalOrPlatform(device, accessory);
833
833
  this.accessories.push(accessory);
834
834
  }
835
835
  else {
836
- this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
836
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
837
837
  }
838
838
  }
839
839
  async createBot(device) {
@@ -858,7 +858,7 @@ export class SwitchBotPlatform {
858
858
  // create the accessory handler for the restored accessory
859
859
  // this is imported from `platformAccessory.ts`
860
860
  new Bot(this, existingAccessory, device);
861
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
861
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
862
862
  }
863
863
  else {
864
864
  this.unregisterPlatformAccessories(existingAccessory);
@@ -885,13 +885,13 @@ export class SwitchBotPlatform {
885
885
  // create the accessory handler for the newly create accessory
886
886
  // this is imported from `platformAccessory.ts`
887
887
  new Bot(this, accessory, device);
888
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
888
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
889
889
  // publish device externally or link the accessory to your platform
890
890
  this.externalOrPlatform(device, accessory);
891
891
  this.accessories.push(accessory);
892
892
  }
893
893
  else {
894
- this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
894
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
895
895
  }
896
896
  }
897
897
  async createMeter(device) {
@@ -916,7 +916,7 @@ export class SwitchBotPlatform {
916
916
  // create the accessory handler for the restored accessory
917
917
  // this is imported from `platformAccessory.ts`
918
918
  new Meter(this, existingAccessory, device);
919
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
919
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
920
920
  }
921
921
  else {
922
922
  this.unregisterPlatformAccessories(existingAccessory);
@@ -942,13 +942,13 @@ export class SwitchBotPlatform {
942
942
  // create the accessory handler for the newly create accessory
943
943
  // this is imported from `platformAccessory.ts`
944
944
  new Meter(this, accessory, device);
945
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
945
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
946
946
  // publish device externally or link the accessory to your platform
947
947
  this.externalOrPlatform(device, accessory);
948
948
  this.accessories.push(accessory);
949
949
  }
950
950
  else {
951
- this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
951
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
952
952
  }
953
953
  }
954
954
  async createMeterPlus(device) {
@@ -974,7 +974,7 @@ export class SwitchBotPlatform {
974
974
  // create the accessory handler for the restored accessory
975
975
  // this is imported from `platformAccessory.ts`
976
976
  new MeterPlus(this, existingAccessory, device);
977
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
977
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
978
978
  }
979
979
  else {
980
980
  this.unregisterPlatformAccessories(existingAccessory);
@@ -1000,13 +1000,13 @@ export class SwitchBotPlatform {
1000
1000
  // create the accessory handler for the newly create accessory
1001
1001
  // this is imported from `platformAccessory.ts`
1002
1002
  new MeterPlus(this, accessory, device);
1003
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1003
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1004
1004
  // publish device externally or link the accessory to your platform
1005
1005
  this.externalOrPlatform(device, accessory);
1006
1006
  this.accessories.push(accessory);
1007
1007
  }
1008
1008
  else {
1009
- this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1009
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1010
1010
  }
1011
1011
  }
1012
1012
  async createHub2(device) {
@@ -1032,7 +1032,7 @@ export class SwitchBotPlatform {
1032
1032
  // create the accessory handler for the restored accessory
1033
1033
  // this is imported from `platformAccessory.ts`
1034
1034
  new Hub(this, existingAccessory, device);
1035
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1035
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1036
1036
  }
1037
1037
  else {
1038
1038
  this.unregisterPlatformAccessories(existingAccessory);
@@ -1058,13 +1058,13 @@ export class SwitchBotPlatform {
1058
1058
  // create the accessory handler for the newly create accessory
1059
1059
  // this is imported from `platformAccessory.ts`
1060
1060
  new Hub(this, accessory, device);
1061
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1061
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1062
1062
  // publish device externally or link the accessory to your platform
1063
1063
  this.externalOrPlatform(device, accessory);
1064
1064
  this.accessories.push(accessory);
1065
1065
  }
1066
1066
  else {
1067
- this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1067
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1068
1068
  }
1069
1069
  }
1070
1070
  async createIOSensor(device) {
@@ -1089,7 +1089,7 @@ export class SwitchBotPlatform {
1089
1089
  // create the accessory handler for the restored accessory
1090
1090
  // this is imported from `platformAccessory.ts`
1091
1091
  new IOSensor(this, existingAccessory, device);
1092
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1092
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1093
1093
  }
1094
1094
  else {
1095
1095
  this.unregisterPlatformAccessories(existingAccessory);
@@ -1115,13 +1115,13 @@ export class SwitchBotPlatform {
1115
1115
  // create the accessory handler for the newly create accessory
1116
1116
  // this is imported from `platformAccessory.ts`
1117
1117
  new IOSensor(this, accessory, device);
1118
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1118
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1119
1119
  // publish device externally or link the accessory to your platform
1120
1120
  this.externalOrPlatform(device, accessory);
1121
1121
  this.accessories.push(accessory);
1122
1122
  }
1123
1123
  else {
1124
- this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1124
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1125
1125
  }
1126
1126
  }
1127
1127
  async createWaterDetector(device) {
@@ -1146,7 +1146,7 @@ export class SwitchBotPlatform {
1146
1146
  // create the accessory handler for the restored accessory
1147
1147
  // this is imported from `platformAccessory.ts`
1148
1148
  new WaterDetector(this, existingAccessory, device);
1149
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1149
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1150
1150
  }
1151
1151
  else {
1152
1152
  this.unregisterPlatformAccessories(existingAccessory);
@@ -1172,13 +1172,13 @@ export class SwitchBotPlatform {
1172
1172
  // create the accessory handler for the newly create accessory
1173
1173
  // this is imported from `platformAccessory.ts`
1174
1174
  new WaterDetector(this, accessory, device);
1175
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1175
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1176
1176
  // publish device externally or link the accessory to your platform
1177
1177
  this.externalOrPlatform(device, accessory);
1178
1178
  this.accessories.push(accessory);
1179
1179
  }
1180
1180
  else {
1181
- this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1181
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1182
1182
  }
1183
1183
  }
1184
1184
  async createMotion(device) {
@@ -1203,7 +1203,7 @@ export class SwitchBotPlatform {
1203
1203
  // create the accessory handler for the restored accessory
1204
1204
  // this is imported from `platformAccessory.ts`
1205
1205
  new Motion(this, existingAccessory, device);
1206
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1206
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1207
1207
  }
1208
1208
  else {
1209
1209
  this.unregisterPlatformAccessories(existingAccessory);
@@ -1229,13 +1229,13 @@ export class SwitchBotPlatform {
1229
1229
  // create the accessory handler for the newly create accessory
1230
1230
  // this is imported from `platformAccessory.ts`
1231
1231
  new Motion(this, accessory, device);
1232
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1232
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1233
1233
  // publish device externally or link the accessory to your platform
1234
1234
  this.externalOrPlatform(device, accessory);
1235
1235
  this.accessories.push(accessory);
1236
1236
  }
1237
1237
  else {
1238
- this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1238
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1239
1239
  }
1240
1240
  }
1241
1241
  async createContact(device) {
@@ -1260,7 +1260,7 @@ export class SwitchBotPlatform {
1260
1260
  // create the accessory handler for the restored accessory
1261
1261
  // this is imported from `platformAccessory.ts`
1262
1262
  new Contact(this, existingAccessory, device);
1263
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1263
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1264
1264
  }
1265
1265
  else {
1266
1266
  this.unregisterPlatformAccessories(existingAccessory);
@@ -1286,13 +1286,13 @@ export class SwitchBotPlatform {
1286
1286
  // create the accessory handler for the newly create accessory
1287
1287
  // this is imported from `platformAccessory.ts`
1288
1288
  new Contact(this, accessory, device);
1289
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1289
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1290
1290
  // publish device externally or link the accessory to your platform
1291
1291
  this.externalOrPlatform(device, accessory);
1292
1292
  this.accessories.push(accessory);
1293
1293
  }
1294
1294
  else {
1295
- this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1295
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1296
1296
  }
1297
1297
  }
1298
1298
  async createBlindTilt(device) {
@@ -1317,7 +1317,7 @@ export class SwitchBotPlatform {
1317
1317
  // create the accessory handler for the restored accessory
1318
1318
  // this is imported from `platformAccessory.ts`
1319
1319
  new BlindTilt(this, existingAccessory, device);
1320
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1320
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1321
1321
  }
1322
1322
  else {
1323
1323
  this.unregisterPlatformAccessories(existingAccessory);
@@ -1357,13 +1357,13 @@ export class SwitchBotPlatform {
1357
1357
  // create the accessory handler for the newly create accessory
1358
1358
  // this is imported from `platformAccessory.ts`
1359
1359
  new BlindTilt(this, accessory, device);
1360
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1360
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1361
1361
  // publish device externally or link the accessory to your platform
1362
1362
  this.externalOrPlatform(device, accessory);
1363
1363
  this.accessories.push(accessory);
1364
1364
  }
1365
1365
  else {
1366
- this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1366
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1367
1367
  }
1368
1368
  }
1369
1369
  async createCurtain(device) {
@@ -1388,7 +1388,7 @@ export class SwitchBotPlatform {
1388
1388
  // create the accessory handler for the restored accessory
1389
1389
  // this is imported from `platformAccessory.ts`
1390
1390
  new Curtain(this, existingAccessory, device);
1391
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1391
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1392
1392
  }
1393
1393
  else {
1394
1394
  this.unregisterPlatformAccessories(existingAccessory);
@@ -1428,13 +1428,13 @@ export class SwitchBotPlatform {
1428
1428
  // create the accessory handler for the newly create accessory
1429
1429
  // this is imported from `platformAccessory.ts`
1430
1430
  new Curtain(this, accessory, device);
1431
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1431
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1432
1432
  // publish device externally or link the accessory to your platform
1433
1433
  this.externalOrPlatform(device, accessory);
1434
1434
  this.accessories.push(accessory);
1435
1435
  }
1436
1436
  else {
1437
- this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1437
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1438
1438
  }
1439
1439
  }
1440
1440
  async createPlug(device) {
@@ -1459,7 +1459,7 @@ export class SwitchBotPlatform {
1459
1459
  // create the accessory handler for the restored accessory
1460
1460
  // this is imported from `platformAccessory.ts`
1461
1461
  new Plug(this, existingAccessory, device);
1462
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1462
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1463
1463
  }
1464
1464
  else {
1465
1465
  this.unregisterPlatformAccessories(existingAccessory);
@@ -1485,13 +1485,13 @@ export class SwitchBotPlatform {
1485
1485
  // create the accessory handler for the newly create accessory
1486
1486
  // this is imported from `platformAccessory.ts`
1487
1487
  new Plug(this, accessory, device);
1488
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1488
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1489
1489
  // publish device externally or link the accessory to your platform
1490
1490
  this.externalOrPlatform(device, accessory);
1491
1491
  this.accessories.push(accessory);
1492
1492
  }
1493
1493
  else {
1494
- this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1494
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1495
1495
  }
1496
1496
  }
1497
1497
  async createLock(device) {
@@ -1516,7 +1516,7 @@ export class SwitchBotPlatform {
1516
1516
  // create the accessory handler for the restored accessory
1517
1517
  // this is imported from `platformAccessory.ts`
1518
1518
  new Lock(this, existingAccessory, device);
1519
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1519
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1520
1520
  }
1521
1521
  else {
1522
1522
  this.unregisterPlatformAccessories(existingAccessory);
@@ -1542,13 +1542,13 @@ export class SwitchBotPlatform {
1542
1542
  // create the accessory handler for the newly create accessory
1543
1543
  // this is imported from `platformAccessory.ts`
1544
1544
  new Lock(this, accessory, device);
1545
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1545
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1546
1546
  // publish device externally or link the accessory to your platform
1547
1547
  this.externalOrPlatform(device, accessory);
1548
1548
  this.accessories.push(accessory);
1549
1549
  }
1550
1550
  else {
1551
- this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1551
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1552
1552
  }
1553
1553
  }
1554
1554
  async createColorBulb(device) {
@@ -1573,7 +1573,7 @@ export class SwitchBotPlatform {
1573
1573
  // create the accessory handler for the restored accessory
1574
1574
  // this is imported from `platformAccessory.ts`
1575
1575
  new ColorBulb(this, existingAccessory, device);
1576
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1576
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1577
1577
  }
1578
1578
  else {
1579
1579
  this.unregisterPlatformAccessories(existingAccessory);
@@ -1599,13 +1599,13 @@ export class SwitchBotPlatform {
1599
1599
  // create the accessory handler for the newly create accessory
1600
1600
  // this is imported from `platformAccessory.ts`
1601
1601
  new ColorBulb(this, accessory, device);
1602
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1602
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1603
1603
  // publish device externally or link the accessory to your platform
1604
1604
  this.externalOrPlatform(device, accessory);
1605
1605
  this.accessories.push(accessory);
1606
1606
  }
1607
1607
  else {
1608
- this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1608
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1609
1609
  }
1610
1610
  }
1611
1611
  async createCeilingLight(device) {
@@ -1630,7 +1630,7 @@ export class SwitchBotPlatform {
1630
1630
  // create the accessory handler for the restored accessory
1631
1631
  // this is imported from `platformAccessory.ts`
1632
1632
  new CeilingLight(this, existingAccessory, device);
1633
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1633
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1634
1634
  }
1635
1635
  else {
1636
1636
  this.unregisterPlatformAccessories(existingAccessory);
@@ -1656,13 +1656,13 @@ export class SwitchBotPlatform {
1656
1656
  // create the accessory handler for the newly create accessory
1657
1657
  // this is imported from `platformAccessory.ts`
1658
1658
  new CeilingLight(this, accessory, device);
1659
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1659
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1660
1660
  // publish device externally or link the accessory to your platform
1661
1661
  this.externalOrPlatform(device, accessory);
1662
1662
  this.accessories.push(accessory);
1663
1663
  }
1664
1664
  else {
1665
- this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1665
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1666
1666
  }
1667
1667
  }
1668
1668
  async createStripLight(device) {
@@ -1687,7 +1687,7 @@ export class SwitchBotPlatform {
1687
1687
  // create the accessory handler for the restored accessory
1688
1688
  // this is imported from `platformAccessory.ts`
1689
1689
  new StripLight(this, existingAccessory, device);
1690
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1690
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1691
1691
  }
1692
1692
  else {
1693
1693
  this.unregisterPlatformAccessories(existingAccessory);
@@ -1713,13 +1713,13 @@ export class SwitchBotPlatform {
1713
1713
  // create the accessory handler for the newly create accessory
1714
1714
  // this is imported from `platformAccessory.ts`
1715
1715
  new StripLight(this, accessory, device);
1716
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1716
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1717
1717
  // publish device externally or link the accessory to your platform
1718
1718
  this.externalOrPlatform(device, accessory);
1719
1719
  this.accessories.push(accessory);
1720
1720
  }
1721
1721
  else {
1722
- this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1722
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1723
1723
  }
1724
1724
  }
1725
1725
  async createFan(device) {
@@ -1744,7 +1744,7 @@ export class SwitchBotPlatform {
1744
1744
  // create the accessory handler for the restored accessory
1745
1745
  // this is imported from `platformAccessory.ts`
1746
1746
  new Fan(this, existingAccessory, device);
1747
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1747
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1748
1748
  }
1749
1749
  else {
1750
1750
  this.unregisterPlatformAccessories(existingAccessory);
@@ -1770,13 +1770,13 @@ export class SwitchBotPlatform {
1770
1770
  // create the accessory handler for the newly create accessory
1771
1771
  // this is imported from `platformAccessory.ts`
1772
1772
  new Fan(this, accessory, device);
1773
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1773
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1774
1774
  // publish device externally or link the accessory to your platform
1775
1775
  this.externalOrPlatform(device, accessory);
1776
1776
  this.accessories.push(accessory);
1777
1777
  }
1778
1778
  else {
1779
- this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1779
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1780
1780
  }
1781
1781
  }
1782
1782
  async createRobotVacuumCleaner(device) {
@@ -1801,7 +1801,7 @@ export class SwitchBotPlatform {
1801
1801
  // create the accessory handler for the restored accessory
1802
1802
  // this is imported from `platformAccessory.ts`
1803
1803
  new RobotVacuumCleaner(this, existingAccessory, device);
1804
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1804
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1805
1805
  }
1806
1806
  else {
1807
1807
  this.unregisterPlatformAccessories(existingAccessory);
@@ -1827,13 +1827,13 @@ export class SwitchBotPlatform {
1827
1827
  // create the accessory handler for the newly create accessory
1828
1828
  // this is imported from `platformAccessory.ts`
1829
1829
  new RobotVacuumCleaner(this, accessory, device);
1830
- this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1830
+ await this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1831
1831
  // publish device externally or link the accessory to your platform
1832
1832
  this.externalOrPlatform(device, accessory);
1833
1833
  this.accessories.push(accessory);
1834
1834
  }
1835
1835
  else {
1836
- this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1836
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1837
1837
  }
1838
1838
  }
1839
1839
  async createTV(device) {
@@ -1853,7 +1853,7 @@ export class SwitchBotPlatform {
1853
1853
  // create the accessory handler for the restored accessory
1854
1854
  // this is imported from `platformAccessory.ts`
1855
1855
  new TV(this, existingAccessory, device);
1856
- this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
1856
+ await this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
1857
1857
  }
1858
1858
  else if (!device.hide_device && device.hubDeviceId) {
1859
1859
  // the accessory does not yet exist, so we need to create it
@@ -1875,12 +1875,12 @@ export class SwitchBotPlatform {
1875
1875
  // create the accessory handler for the newly create accessory
1876
1876
  // this is imported from `platformAccessory.ts`
1877
1877
  new TV(this, accessory, device);
1878
- this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1878
+ await this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1879
1879
  this.externalOrPlatformIR(device, accessory);
1880
1880
  this.accessories.push(accessory);
1881
1881
  }
1882
1882
  else {
1883
- this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1883
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1884
1884
  }
1885
1885
  }
1886
1886
  async createIRFan(device) {
@@ -1905,7 +1905,7 @@ export class SwitchBotPlatform {
1905
1905
  // create the accessory handler for the restored accessory
1906
1906
  // this is imported from `platformAccessory.ts`
1907
1907
  new IRFan(this, existingAccessory, device);
1908
- this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
1908
+ await this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
1909
1909
  }
1910
1910
  else {
1911
1911
  this.unregisterPlatformAccessories(existingAccessory);
@@ -1931,13 +1931,13 @@ export class SwitchBotPlatform {
1931
1931
  // create the accessory handler for the newly create accessory
1932
1932
  // this is imported from `platformAccessory.ts`
1933
1933
  new IRFan(this, accessory, device);
1934
- this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1934
+ await this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1935
1935
  // publish device externally or link the accessory to your platform
1936
1936
  this.externalOrPlatformIR(device, accessory);
1937
1937
  this.accessories.push(accessory);
1938
1938
  }
1939
1939
  else {
1940
- this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1940
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1941
1941
  }
1942
1942
  }
1943
1943
  async createLight(device) {
@@ -1962,7 +1962,7 @@ export class SwitchBotPlatform {
1962
1962
  // create the accessory handler for the restored accessory
1963
1963
  // this is imported from `platformAccessory.ts`
1964
1964
  new Light(this, existingAccessory, device);
1965
- this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
1965
+ await this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
1966
1966
  }
1967
1967
  else {
1968
1968
  this.unregisterPlatformAccessories(existingAccessory);
@@ -1988,13 +1988,13 @@ export class SwitchBotPlatform {
1988
1988
  // create the accessory handler for the newly create accessory
1989
1989
  // this is imported from `platformAccessory.ts`
1990
1990
  new Light(this, accessory, device);
1991
- this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1991
+ await this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1992
1992
  // publish device externally or link the accessory to your platform
1993
1993
  this.externalOrPlatformIR(device, accessory);
1994
1994
  this.accessories.push(accessory);
1995
1995
  }
1996
1996
  else {
1997
- this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1997
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1998
1998
  }
1999
1999
  }
2000
2000
  async createAirConditioner(device) {
@@ -2019,7 +2019,7 @@ export class SwitchBotPlatform {
2019
2019
  // create the accessory handler for the restored accessory
2020
2020
  // this is imported from `platformAccessory.ts`
2021
2021
  new AirConditioner(this, existingAccessory, device);
2022
- this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
2022
+ await this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
2023
2023
  }
2024
2024
  else {
2025
2025
  this.unregisterPlatformAccessories(existingAccessory);
@@ -2045,13 +2045,13 @@ export class SwitchBotPlatform {
2045
2045
  // create the accessory handler for the newly create accessory
2046
2046
  // this is imported from `platformAccessory.ts`
2047
2047
  new AirConditioner(this, accessory, device);
2048
- this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
2048
+ await this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
2049
2049
  // publish device externally or link the accessory to your platform
2050
2050
  this.externalOrPlatformIR(device, accessory);
2051
2051
  this.accessories.push(accessory);
2052
2052
  }
2053
2053
  else {
2054
- this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
2054
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
2055
2055
  }
2056
2056
  }
2057
2057
  async createAirPurifier(device) {
@@ -2076,7 +2076,7 @@ export class SwitchBotPlatform {
2076
2076
  // create the accessory handler for the restored accessory
2077
2077
  // this is imported from `platformAccessory.ts`
2078
2078
  new AirPurifier(this, existingAccessory, device);
2079
- this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
2079
+ await this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
2080
2080
  }
2081
2081
  else {
2082
2082
  this.unregisterPlatformAccessories(existingAccessory);
@@ -2102,13 +2102,13 @@ export class SwitchBotPlatform {
2102
2102
  // create the accessory handler for the newly create accessory
2103
2103
  // this is imported from `platformAccessory.ts`
2104
2104
  new AirPurifier(this, accessory, device);
2105
- this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
2105
+ await this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
2106
2106
  // publish device externally or link the accessory to your platform
2107
2107
  this.externalOrPlatformIR(device, accessory);
2108
2108
  this.accessories.push(accessory);
2109
2109
  }
2110
2110
  else {
2111
- this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
2111
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
2112
2112
  }
2113
2113
  }
2114
2114
  async createWaterHeater(device) {
@@ -2133,7 +2133,7 @@ export class SwitchBotPlatform {
2133
2133
  // create the accessory handler for the restored accessory
2134
2134
  // this is imported from `platformAccessory.ts`
2135
2135
  new WaterHeater(this, existingAccessory, device);
2136
- this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
2136
+ await this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
2137
2137
  }
2138
2138
  else {
2139
2139
  this.unregisterPlatformAccessories(existingAccessory);
@@ -2159,13 +2159,13 @@ export class SwitchBotPlatform {
2159
2159
  // create the accessory handler for the newly create accessory
2160
2160
  // this is imported from `platformAccessory.ts`
2161
2161
  new WaterHeater(this, accessory, device);
2162
- this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
2162
+ await this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
2163
2163
  // publish device externally or link the accessory to your platform
2164
2164
  this.externalOrPlatformIR(device, accessory);
2165
2165
  this.accessories.push(accessory);
2166
2166
  }
2167
2167
  else {
2168
- this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
2168
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
2169
2169
  }
2170
2170
  }
2171
2171
  async createVacuumCleaner(device) {
@@ -2190,7 +2190,7 @@ export class SwitchBotPlatform {
2190
2190
  // create the accessory handler for the restored accessory
2191
2191
  // this is imported from `platformAccessory.ts`
2192
2192
  new VacuumCleaner(this, existingAccessory, device);
2193
- this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
2193
+ await this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
2194
2194
  }
2195
2195
  else {
2196
2196
  this.unregisterPlatformAccessories(existingAccessory);
@@ -2216,13 +2216,13 @@ export class SwitchBotPlatform {
2216
2216
  // create the accessory handler for the newly create accessory
2217
2217
  // this is imported from `platformAccessory.ts`
2218
2218
  new VacuumCleaner(this, accessory, device);
2219
- this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
2219
+ await this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
2220
2220
  // publish device externally or link the accessory to your platform
2221
2221
  this.externalOrPlatformIR(device, accessory);
2222
2222
  this.accessories.push(accessory);
2223
2223
  }
2224
2224
  else {
2225
- this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
2225
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
2226
2226
  }
2227
2227
  }
2228
2228
  async createCamera(device) {
@@ -2247,7 +2247,7 @@ export class SwitchBotPlatform {
2247
2247
  // create the accessory handler for the restored accessory
2248
2248
  // this is imported from `platformAccessory.ts`
2249
2249
  new Camera(this, existingAccessory, device);
2250
- this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
2250
+ await this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
2251
2251
  }
2252
2252
  else {
2253
2253
  this.unregisterPlatformAccessories(existingAccessory);
@@ -2273,13 +2273,13 @@ export class SwitchBotPlatform {
2273
2273
  // create the accessory handler for the newly create accessory
2274
2274
  // this is imported from `platformAccessory.ts`
2275
2275
  new Camera(this, accessory, device);
2276
- this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
2276
+ await this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
2277
2277
  // publish device externally or link the accessory to your platform
2278
2278
  this.externalOrPlatformIR(device, accessory);
2279
2279
  this.accessories.push(accessory);
2280
2280
  }
2281
2281
  else {
2282
- this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
2282
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
2283
2283
  }
2284
2284
  }
2285
2285
  async createOthers(device) {
@@ -2304,7 +2304,7 @@ export class SwitchBotPlatform {
2304
2304
  // create the accessory handler for the restored accessory
2305
2305
  // this is imported from `platformAccessory.ts`
2306
2306
  new Others(this, existingAccessory, device);
2307
- this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
2307
+ await this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
2308
2308
  }
2309
2309
  else {
2310
2310
  this.unregisterPlatformAccessories(existingAccessory);
@@ -2330,13 +2330,13 @@ export class SwitchBotPlatform {
2330
2330
  // create the accessory handler for the newly create accessory
2331
2331
  // this is imported from `platformAccessory.ts`
2332
2332
  new Others(this, accessory, device);
2333
- this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
2333
+ await this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
2334
2334
  // publish device externally or link the accessory to your platform
2335
2335
  this.externalOrPlatformIR(device, accessory);
2336
2336
  this.accessories.push(accessory);
2337
2337
  }
2338
2338
  else {
2339
- this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
2339
+ await this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
2340
2340
  }
2341
2341
  }
2342
2342
  async registerCurtains(device) {
@@ -2349,12 +2349,13 @@ export class SwitchBotPlatform {
2349
2349
  }*/
2350
2350
  let registerWindowCovering;
2351
2351
  if (isCurtainDevice(device)) {
2352
- this.debugWarnLog(`deviceName: ${device.deviceName} deviceId: ${device.deviceId}, curtainDevicesIds: ${device.curtainDevicesIds}, master: `
2353
- + `${device.master}, group: ${device.group}, disable_group: ${device.curtain?.disable_group}, connectionType: ${device.connectionType}`);
2352
+ await this.debugWarnLog(`deviceName: ${device.deviceName} deviceId: ${device.deviceId}, curtainDevicesIds: ${device.curtainDevicesIds},`
2353
+ + ` master: ${device.master}, group: ${device.group}, disable_group: ${device.curtain?.disable_group},`
2354
+ + ` connectionType: ${device.connectionType}`);
2354
2355
  registerWindowCovering = await this.registerWindowCovering(device);
2355
2356
  }
2356
2357
  else if (isBlindTiltDevice(device)) {
2357
- this.debugWarnLog(`deviceName: ${device.deviceName} deviceId: ${device.deviceId}, blindTiltDevicesIds: ${device.blindTiltDevicesIds},`
2358
+ await this.debugWarnLog(`deviceName: ${device.deviceName} deviceId: ${device.deviceId}, blindTiltDevicesIds: ${device.blindTiltDevicesIds},`
2358
2359
  + ` master: ${device.master}, group: ${device.group}, disable_group: ${device.curtain?.disable_group},`
2359
2360
  + ` connectionType: ${device.connectionType}`);
2360
2361
  registerWindowCovering = await this.registerWindowCovering(device);
@@ -2365,42 +2366,42 @@ export class SwitchBotPlatform {
2365
2366
  return registerWindowCovering;
2366
2367
  }
2367
2368
  async registerWindowCovering(device) {
2368
- this.debugLog(device.master);
2369
+ await this.debugLog(`master: ${device.master}`);
2369
2370
  let registerCurtain;
2370
2371
  if (device.master && device.group) {
2371
2372
  // OpenAPI: Master Curtains/Blind Tilt in Group
2372
2373
  registerCurtain = true;
2373
- this.debugLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] device.master: ${device.master}, device.group: ${device.group}`
2374
- + ` connectionType; ${device.connectionType}`);
2375
- this.debugWarnLog(`Device: ${device.deviceName} registerCurtains: ${registerCurtain}`);
2374
+ await this.debugLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] device.master: ${device.master},`
2375
+ + ` device.group: ${device.group} connectionType; ${device.connectionType}`);
2376
+ await this.debugWarnLog(`Device: ${device.deviceName} registerCurtains: ${registerCurtain}`);
2376
2377
  }
2377
2378
  else if (!device.master && device.curtain?.disable_group) {
2378
2379
  //!device.group && device.connectionType === 'BLE'
2379
2380
  // OpenAPI: Non-Master Curtains/Blind Tilts that has Disable Grouping Checked
2380
2381
  registerCurtain = true;
2381
- this.debugLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] device.master: ${device.master}, disable_group: `
2382
+ await this.debugLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] device.master: ${device.master}, disable_group: `
2382
2383
  + `${device.curtain?.disable_group}, connectionType; ${device.connectionType}`);
2383
- this.debugWarnLog(`Device: ${device.deviceName} registerCurtains: ${registerCurtain}`);
2384
+ await this.debugWarnLog(`Device: ${device.deviceName} registerCurtains: ${registerCurtain}`);
2384
2385
  }
2385
2386
  else if (device.master && !device.group) {
2386
2387
  // OpenAPI: Master Curtains/Blind Tilts not in Group
2387
2388
  registerCurtain = true;
2388
- this.debugLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] device.master: ${device.master}, device.group: ${device.group}`
2389
- + ` connectionType; ${device.connectionType}`);
2390
- this.debugWarnLog(`Device: ${device.deviceName} registerCurtains: ${registerCurtain}`);
2389
+ await this.debugLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] device.master: ${device.master},`
2390
+ + ` device.group: ${device.group} connectionType; ${device.connectionType}`);
2391
+ await this.debugWarnLog(`Device: ${device.deviceName} registerCurtains: ${registerCurtain}`);
2391
2392
  }
2392
2393
  else if (device.connectionType === 'BLE') {
2393
2394
  // BLE: Curtains/Blind Tilt
2394
2395
  registerCurtain = true;
2395
- this.debugLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] connectionType: ${device.connectionType}, `
2396
+ await this.debugLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] connectionType: ${device.connectionType}, `
2396
2397
  + ` group: ${device.group}`);
2397
- this.debugWarnLog(`Device: ${device.deviceName} registerCurtains: ${registerCurtain}`);
2398
+ await this.debugWarnLog(`Device: ${device.deviceName} registerCurtains: ${registerCurtain}`);
2398
2399
  }
2399
2400
  else {
2400
2401
  registerCurtain = false;
2401
- this.debugErrorLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] disable_group: ${device.curtain?.disable_group},`
2402
+ await this.debugErrorLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] disable_group: ${device.curtain?.disable_group},`
2402
2403
  + ` device.master: ${device.master}, device.group: ${device.group}`);
2403
- this.debugWarnLog(`Device: ${device.deviceName} registerCurtains: ${registerCurtain}, device.connectionType: ${device.connectionType}`);
2404
+ await this.debugWarnLog(`Device: ${device.deviceName} registerCurtains: ${registerCurtain}, device.connectionType: ${device.connectionType}`);
2404
2405
  }
2405
2406
  return registerCurtain;
2406
2407
  }
@@ -2423,17 +2424,17 @@ export class SwitchBotPlatform {
2423
2424
  case 'Curtain3':
2424
2425
  case 'Blind Tilt':
2425
2426
  registerDevice = await this.registerCurtains(device);
2426
- this.debugWarnLog(`Device: ${device.deviceName} ${device.deviceType} registerDevice: ${registerDevice}`);
2427
+ await this.debugWarnLog(`Device: ${device.deviceName} ${device.deviceType} registerDevice: ${registerDevice}`);
2427
2428
  break;
2428
2429
  default:
2429
2430
  registerDevice = true;
2430
- this.debugWarnLog(`Device: ${device.deviceName} registerDevice: ${registerDevice}`);
2431
+ await this.debugWarnLog(`Device: ${device.deviceName} registerDevice: ${registerDevice}`);
2431
2432
  }
2432
2433
  if (registerDevice === true) {
2433
- this.debugWarnLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will display in HomeKit`);
2434
+ await this.debugWarnLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will display in HomeKit`);
2434
2435
  }
2435
2436
  else {
2436
- this.debugErrorLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will not display in HomeKit`);
2437
+ await this.debugErrorLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will not display in HomeKit`);
2437
2438
  }
2438
2439
  }
2439
2440
  else if (!device.hide_device && device.deviceId && device.configDeviceType && device.configDeviceName && device.connectionType === 'BLE') {
@@ -2442,17 +2443,17 @@ export class SwitchBotPlatform {
2442
2443
  case 'Curtain3':
2443
2444
  case 'Blind Tilt':
2444
2445
  registerDevice = await this.registerCurtains(device);
2445
- this.debugWarnLog(`Device: ${device.deviceName} ${device.deviceType} registerDevice: ${registerDevice}`);
2446
+ await this.debugWarnLog(`Device: ${device.deviceName} ${device.deviceType} registerDevice: ${registerDevice}`);
2446
2447
  break;
2447
2448
  default:
2448
2449
  registerDevice = true;
2449
- this.debugWarnLog(`Device: ${device.deviceName} registerDevice: ${registerDevice}`);
2450
+ await this.debugWarnLog(`Device: ${device.deviceName} registerDevice: ${registerDevice}`);
2450
2451
  }
2451
2452
  if (registerDevice === true) {
2452
- this.debugWarnLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will display in HomeKit`);
2453
+ await this.debugWarnLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will display in HomeKit`);
2453
2454
  }
2454
2455
  else {
2455
- this.debugErrorLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will not display in HomeKit`);
2456
+ await this.debugErrorLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will not display in HomeKit`);
2456
2457
  }
2457
2458
  }
2458
2459
  else if (!device.hide_device && device.connectionType === 'OpenAPI') {
@@ -2461,17 +2462,17 @@ export class SwitchBotPlatform {
2461
2462
  case 'Curtain3':
2462
2463
  case 'Blind Tilt':
2463
2464
  registerDevice = await this.registerCurtains(device);
2464
- this.debugWarnLog(`Device: ${device.deviceName} ${device.deviceType} registerDevice: ${registerDevice}`);
2465
+ await this.debugWarnLog(`Device: ${device.deviceName} ${device.deviceType} registerDevice: ${registerDevice}`);
2465
2466
  break;
2466
2467
  default:
2467
2468
  registerDevice = true;
2468
- this.debugWarnLog(`Device: ${device.deviceName} registerDevice: ${registerDevice}`);
2469
+ await this.debugWarnLog(`Device: ${device.deviceName} registerDevice: ${registerDevice}`);
2469
2470
  }
2470
2471
  if (registerDevice === true) {
2471
- this.debugWarnLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will display in HomeKit`);
2472
+ await this.debugWarnLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will display in HomeKit`);
2472
2473
  }
2473
2474
  else {
2474
- this.debugErrorLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will not display in HomeKit`);
2475
+ await this.debugErrorLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will not display in HomeKit`);
2475
2476
  }
2476
2477
  }
2477
2478
  else if (!device.hide_device && device.connectionType === 'Disabled') {
@@ -2480,25 +2481,25 @@ export class SwitchBotPlatform {
2480
2481
  case 'Curtain3':
2481
2482
  case 'Blind Tilt':
2482
2483
  registerDevice = await this.registerCurtains(device);
2483
- this.debugWarnLog(`Device: ${device.deviceName} ${device.deviceType} registerDevice: ${registerDevice}`);
2484
+ await this.debugWarnLog(`Device: ${device.deviceName} ${device.deviceType} registerDevice: ${registerDevice}`);
2484
2485
  break;
2485
2486
  default:
2486
2487
  registerDevice = true;
2487
- this.debugWarnLog(`Device: ${device.deviceName} registerDevice: ${registerDevice}`);
2488
+ await this.debugWarnLog(`Device: ${device.deviceName} registerDevice: ${registerDevice}`);
2488
2489
  }
2489
- this.debugWarnLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will continue to display in HomeKit`);
2490
+ await this.debugWarnLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will continue to display in HomeKit`);
2490
2491
  }
2491
2492
  else if (!device.connectionType && !device.hide_device) {
2492
2493
  registerDevice = false;
2493
- this.debugErrorLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will not display in HomeKit`);
2494
+ await this.debugErrorLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will not display in HomeKit`);
2494
2495
  }
2495
2496
  else if (device.hide_device) {
2496
2497
  registerDevice = false;
2497
- this.debugErrorLog(`Device: ${device.deviceName} hide_device: ${device.hide_device}, will not display in HomeKit`);
2498
+ await this.debugErrorLog(`Device: ${device.deviceName} hide_device: ${device.hide_device}, will not display in HomeKit`);
2498
2499
  }
2499
2500
  else {
2500
2501
  registerDevice = false;
2501
- this.debugErrorLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, hide_device: `
2502
+ await this.debugErrorLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, hide_device: `
2502
2503
  + `${device.hide_device}, will not display in HomeKit`);
2503
2504
  }
2504
2505
  return registerDevice;
@@ -2510,21 +2511,21 @@ export class SwitchBotPlatform {
2510
2511
  * publish your TV as an external accessory.
2511
2512
  */
2512
2513
  if (device.external) {
2513
- this.debugWarnLog(`${accessory.displayName} External Accessory Mode`);
2514
+ await this.debugWarnLog(`${accessory.displayName} External Accessory Mode`);
2514
2515
  this.externalAccessory(accessory);
2515
2516
  }
2516
2517
  else {
2517
- this.debugLog(`${accessory.displayName} External Accessory Mode: ${device.external}`);
2518
+ await this.debugLog(`${accessory.displayName} External Accessory Mode: ${device.external}`);
2518
2519
  this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
2519
2520
  }
2520
2521
  }
2521
2522
  async externalOrPlatform(device, accessory) {
2522
2523
  if (device.external) {
2523
- this.debugWarnLog(`${accessory.displayName} External Accessory Mode`);
2524
- this.externalAccessory(accessory);
2524
+ await this.debugWarnLog(`${accessory.displayName} External Accessory Mode`);
2525
+ await this.externalAccessory(accessory);
2525
2526
  }
2526
2527
  else {
2527
- this.debugLog(`${accessory.displayName} External Accessory Mode: ${device.external}`);
2528
+ await this.debugLog(`${accessory.displayName} External Accessory Mode: ${device.external}`);
2528
2529
  this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
2529
2530
  }
2530
2531
  }
@@ -2558,10 +2559,10 @@ export class SwitchBotPlatform {
2558
2559
  await this.errorLog(`Requests reached the daily limit, statusCode: ${statusCode}`);
2559
2560
  break;
2560
2561
  case 100:
2561
- await this.debugLog(`Command successfully sent, statusCode: ${statusCode}`);
2562
+ await await this.debugLog(`Command successfully sent, statusCode: ${statusCode}`);
2562
2563
  break;
2563
2564
  case 200:
2564
- await this.debugLog(`Request successful, statusCode: ${statusCode}`);
2565
+ await await this.debugLog(`Request successful, statusCode: ${statusCode}`);
2565
2566
  break;
2566
2567
  case 400:
2567
2568
  await this.errorLog('Bad Request, The client has issued an invalid request. This is commonly used to specify validation errors in a request '
@@ -2613,14 +2614,14 @@ export class SwitchBotPlatform {
2613
2614
  return { body, statusCode };
2614
2615
  }
2615
2616
  else {
2616
- await this.debugLog(`Received status code: ${statusCode}`);
2617
+ await await this.debugLog(`Received status code: ${statusCode}`);
2617
2618
  }
2618
2619
  }
2619
2620
  catch (error) {
2620
2621
  await this.errorLog(`Error making request: ${error.message}`);
2621
2622
  }
2622
2623
  retryCount++;
2623
- await this.debugLog(`Retry attempt ${retryCount} of ${maxRetries}`);
2624
+ await await this.debugLog(`Retry attempt ${retryCount} of ${maxRetries}`);
2624
2625
  await sleep(delayBetweenRetries);
2625
2626
  }
2626
2627
  return { body: null, statusCode: -1 };
@@ -2631,7 +2632,7 @@ export class SwitchBotPlatform {
2631
2632
  try {
2632
2633
  const SwitchBot = (await import('node-switchbot')).SwitchBot;
2633
2634
  queueScheduler.schedule(() => (switchbot = new SwitchBot()));
2634
- await this.debugLog(`${device.deviceType}: ${accessory.displayName} 'node-switchbot' found: ${switchbot}`);
2635
+ await await this.debugLog(`${device.deviceType}: ${accessory.displayName} 'node-switchbot' found: ${switchbot}`);
2635
2636
  }
2636
2637
  catch (e) {
2637
2638
  switchbot = false;
@@ -2641,7 +2642,7 @@ export class SwitchBotPlatform {
2641
2642
  }
2642
2643
  async getVersion() {
2643
2644
  const json = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf-8'));
2644
- await this.debugLog(`Plugin Version: ${json.version}`);
2645
+ await await this.debugLog(`Plugin Version: ${json.version}`);
2645
2646
  this.version = json.version;
2646
2647
  }
2647
2648
  async getPlatformConfigSettings() {
@@ -2678,7 +2679,7 @@ export class SwitchBotPlatform {
2678
2679
  platformConfig.delayBetweenRetries = this.delayBetweenRetries / 1000;
2679
2680
  }
2680
2681
  if (Object.entries(platformConfig).length !== 0) {
2681
- await this.debugLog(`Platform Config: ${JSON.stringify(platformConfig)}`);
2682
+ await await this.debugLog(`Platform Config: ${JSON.stringify(platformConfig)}`);
2682
2683
  }
2683
2684
  this.platformConfig = platformConfig;
2684
2685
  }
@@ -2687,15 +2688,15 @@ export class SwitchBotPlatform {
2687
2688
  this.debugMode = process.argv.includes('-D') || process.argv.includes('--debug');
2688
2689
  if (this.config.options?.logging === 'debug' || this.config.options?.logging === 'standard' || this.config.options?.logging === 'none') {
2689
2690
  this.platformLogging = this.config.options.logging;
2690
- await this.debugWarnLog(`Using Config Logging: ${this.platformLogging}`);
2691
+ await await this.debugWarnLog(`Using Config Logging: ${this.platformLogging}`);
2691
2692
  }
2692
2693
  else if (this.debugMode) {
2693
2694
  this.platformLogging = 'debugMode';
2694
- await this.debugWarnLog(`Using ${this.platformLogging} Logging`);
2695
+ await await this.debugWarnLog(`Using ${this.platformLogging} Logging`);
2695
2696
  }
2696
2697
  else {
2697
2698
  this.platformLogging = 'standard';
2698
- await this.debugWarnLog(`Using ${this.platformLogging} Logging`);
2699
+ await await this.debugWarnLog(`Using ${this.platformLogging} Logging`);
2699
2700
  }
2700
2701
  }
2701
2702
  /**