@switchbot/homebridge-switchbot 4.1.1-beta.2 → 4.1.1-beta.3

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 (96) hide show
  1. package/dist/device/blindtilt.js +102 -102
  2. package/dist/device/blindtilt.js.map +1 -1
  3. package/dist/device/bot.js +85 -85
  4. package/dist/device/bot.js.map +1 -1
  5. package/dist/device/ceilinglight.js +98 -98
  6. package/dist/device/ceilinglight.js.map +1 -1
  7. package/dist/device/colorbulb.js +140 -140
  8. package/dist/device/colorbulb.js.map +1 -1
  9. package/dist/device/contact.js +44 -44
  10. package/dist/device/contact.js.map +1 -1
  11. package/dist/device/curtain.js +82 -82
  12. package/dist/device/curtain.js.map +1 -1
  13. package/dist/device/device.d.ts +11 -11
  14. package/dist/device/device.d.ts.map +1 -1
  15. package/dist/device/device.js +41 -41
  16. package/dist/device/device.js.map +1 -1
  17. package/dist/device/fan.js +96 -96
  18. package/dist/device/fan.js.map +1 -1
  19. package/dist/device/hub.js +43 -43
  20. package/dist/device/hub.js.map +1 -1
  21. package/dist/device/humidifier.js +84 -84
  22. package/dist/device/humidifier.js.map +1 -1
  23. package/dist/device/iosensor.js +44 -44
  24. package/dist/device/iosensor.js.map +1 -1
  25. package/dist/device/lightstrip.js +119 -119
  26. package/dist/device/lightstrip.js.map +1 -1
  27. package/dist/device/lock.js +75 -75
  28. package/dist/device/lock.js.map +1 -1
  29. package/dist/device/meter.js +44 -44
  30. package/dist/device/meter.js.map +1 -1
  31. package/dist/device/meterplus.js +42 -42
  32. package/dist/device/meterplus.js.map +1 -1
  33. package/dist/device/meterpro.js +42 -42
  34. package/dist/device/meterpro.js.map +1 -1
  35. package/dist/device/motion.js +42 -42
  36. package/dist/device/motion.js.map +1 -1
  37. package/dist/device/plug.js +60 -60
  38. package/dist/device/plug.js.map +1 -1
  39. package/dist/device/robotvacuumcleaner.js +74 -74
  40. package/dist/device/robotvacuumcleaner.js.map +1 -1
  41. package/dist/device/waterdetector.js +44 -44
  42. package/dist/device/waterdetector.js.map +1 -1
  43. package/dist/irdevice/airconditioner.js +31 -31
  44. package/dist/irdevice/airconditioner.js.map +1 -1
  45. package/dist/irdevice/airpurifier.js +10 -10
  46. package/dist/irdevice/airpurifier.js.map +1 -1
  47. package/dist/irdevice/camera.js +9 -9
  48. package/dist/irdevice/camera.js.map +1 -1
  49. package/dist/irdevice/fan.js +11 -11
  50. package/dist/irdevice/fan.js.map +1 -1
  51. package/dist/irdevice/irdevice.js +11 -11
  52. package/dist/irdevice/irdevice.js.map +1 -1
  53. package/dist/irdevice/light.js +9 -9
  54. package/dist/irdevice/light.js.map +1 -1
  55. package/dist/irdevice/other.js +55 -55
  56. package/dist/irdevice/other.js.map +1 -1
  57. package/dist/irdevice/tv.js +33 -33
  58. package/dist/irdevice/tv.js.map +1 -1
  59. package/dist/irdevice/vacuumcleaner.js +9 -9
  60. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  61. package/dist/irdevice/waterheater.js +9 -9
  62. package/dist/irdevice/waterheater.js.map +1 -1
  63. package/dist/platform.js +228 -228
  64. package/dist/platform.js.map +1 -1
  65. package/package.json +1 -1
  66. package/src/device/blindtilt.ts +102 -102
  67. package/src/device/bot.ts +85 -85
  68. package/src/device/ceilinglight.ts +98 -98
  69. package/src/device/colorbulb.ts +140 -140
  70. package/src/device/contact.ts +44 -44
  71. package/src/device/curtain.ts +82 -82
  72. package/src/device/device.ts +41 -41
  73. package/src/device/fan.ts +96 -96
  74. package/src/device/hub.ts +43 -43
  75. package/src/device/humidifier.ts +84 -84
  76. package/src/device/iosensor.ts +44 -44
  77. package/src/device/lightstrip.ts +119 -119
  78. package/src/device/lock.ts +75 -75
  79. package/src/device/meter.ts +44 -44
  80. package/src/device/meterplus.ts +42 -42
  81. package/src/device/meterpro.ts +42 -42
  82. package/src/device/motion.ts +42 -42
  83. package/src/device/plug.ts +60 -60
  84. package/src/device/robotvacuumcleaner.ts +74 -74
  85. package/src/device/waterdetector.ts +44 -44
  86. package/src/irdevice/airconditioner.ts +31 -31
  87. package/src/irdevice/airpurifier.ts +10 -10
  88. package/src/irdevice/camera.ts +9 -9
  89. package/src/irdevice/fan.ts +11 -11
  90. package/src/irdevice/irdevice.ts +11 -11
  91. package/src/irdevice/light.ts +9 -9
  92. package/src/irdevice/other.ts +55 -55
  93. package/src/irdevice/tv.ts +33 -33
  94. package/src/irdevice/vacuumcleaner.ts +9 -9
  95. package/src/irdevice/waterheater.ts +9 -9
  96. package/src/platform.ts +228 -228
@@ -209,7 +209,7 @@ export class Curtain extends deviceBase {
209
209
  if (this.WindowCovering.PositionState === this.hap.Characteristic.PositionState.STOPPED) {
210
210
  return;
211
211
  }
212
- await this.debugLog(`Refresh Status When Moving, PositionState: ${this.WindowCovering.PositionState}`);
212
+ this.debugLog(`Refresh Status When Moving, PositionState: ${this.WindowCovering.PositionState}`);
213
213
  await this.refreshStatus();
214
214
  });
215
215
  // Watch for Curtain change events
@@ -224,7 +224,7 @@ export class Curtain extends deviceBase {
224
224
  }
225
225
  catch (e) {
226
226
  await this.apiError(e);
227
- await this.errorLog(`failed pushChanges with ${device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
227
+ this.errorLog(`failed pushChanges with ${device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
228
228
  }
229
229
  this.curtainUpdateInProgress = false;
230
230
  });
@@ -251,7 +251,7 @@ export class Curtain extends deviceBase {
251
251
  try {
252
252
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId);
253
253
  this.device.bleMac = formattedDeviceId;
254
- await this.debugLog(`bleMac: ${this.device.bleMac}`);
254
+ this.debugLog(`bleMac: ${this.device.bleMac}`);
255
255
  this.historyService = new this.platform.fakegatoAPI('custom', this.accessory, {
256
256
  log: this.platform.log,
257
257
  storage: 'fs',
@@ -282,7 +282,7 @@ export class Curtain extends deviceBase {
282
282
  this.updateHistory();
283
283
  }
284
284
  catch (error) {
285
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`);
285
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`);
286
286
  }
287
287
  }
288
288
  async updateHistory() {
@@ -296,8 +296,8 @@ export class Curtain extends deviceBase {
296
296
  }, 10 * 60 * 1000);
297
297
  }
298
298
  async BLEparseStatus() {
299
- await this.debugLog('BLEparseStatus');
300
- await this.debugLog(`(position, battery) = BLE:(${this.serviceData.position}, ${this.serviceData.battery}), current:(${this.WindowCovering.CurrentPosition}, ${this.Battery.BatteryLevel})`);
299
+ this.debugLog('BLEparseStatus');
300
+ this.debugLog(`(position, battery) = BLE:(${this.serviceData.position}, ${this.serviceData.battery}), current:(${this.WindowCovering.CurrentPosition}, ${this.Battery.BatteryLevel})`);
301
301
  // CurrentPosition
302
302
  this.WindowCovering.CurrentPosition = 100 - this.serviceData.position;
303
303
  await this.getCurrentPostion();
@@ -311,16 +311,16 @@ export class Curtain extends deviceBase {
311
311
  }
312
312
  // BatteryLevel
313
313
  this.Battery.BatteryLevel = this.serviceData.battery;
314
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
314
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
315
315
  // StatusLowBattery
316
316
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
317
317
  ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
318
318
  : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
319
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
319
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
320
320
  }
321
321
  async openAPIparseStatus() {
322
- await this.debugLog('openAPIparseStatus');
323
- await this.debugLog(`(slidePosition, battery, version) = OpenAPI:(${this.deviceStatus.slidePosition}, ${this.deviceStatus.battery}, ${this.deviceStatus.version}), current:(${this.WindowCovering.CurrentPosition}, ${this.Battery.BatteryLevel}, ${this.accessory.context.version})`);
322
+ this.debugLog('openAPIparseStatus');
323
+ this.debugLog(`(slidePosition, battery, version) = OpenAPI:(${this.deviceStatus.slidePosition}, ${this.deviceStatus.battery}, ${this.deviceStatus.version}), current:(${this.WindowCovering.CurrentPosition}, ${this.Battery.BatteryLevel}, ${this.accessory.context.version})`);
324
324
  // CurrentPosition
325
325
  this.WindowCovering.CurrentPosition = 100 - this.deviceStatus.slidePosition;
326
326
  await this.getCurrentPostion();
@@ -330,20 +330,20 @@ export class Curtain extends deviceBase {
330
330
  const set_maxLux = this.device.set_maxLux ?? 6001;
331
331
  const lightLevel = this.deviceStatus.lightLevel === 'bright' ? set_maxLux : set_minLux;
332
332
  this.LightSensor.CurrentAmbientLightLevel = await this.getLightLevel(lightLevel, set_minLux, set_maxLux, 2);
333
- await this.debugLog(`CurrentAmbientLightLevel: ${this.LightSensor.CurrentAmbientLightLevel}`);
333
+ this.debugLog(`CurrentAmbientLightLevel: ${this.LightSensor.CurrentAmbientLightLevel}`);
334
334
  }
335
335
  // BatteryLevel
336
336
  this.Battery.BatteryLevel = this.deviceStatus.battery;
337
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
337
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
338
338
  // StatusLowBattery
339
339
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
340
340
  ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
341
341
  : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
342
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
342
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
343
343
  // Firmware Version
344
344
  if (this.deviceStatus.version) {
345
345
  const version = this.deviceStatus.version.toString();
346
- await this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`);
346
+ this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`);
347
347
  const deviceVersion = version.replace(/^V|-.*$/g, '') ?? '0.0.0';
348
348
  this.accessory
349
349
  .getService(this.hap.Service.AccessoryInformation)
@@ -352,30 +352,30 @@ export class Curtain extends deviceBase {
352
352
  .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
353
353
  .updateValue(deviceVersion);
354
354
  this.accessory.context.version = deviceVersion;
355
- await this.debugSuccessLog(`version: ${this.accessory.context.version}`);
355
+ this.debugSuccessLog(`version: ${this.accessory.context.version}`);
356
356
  }
357
357
  }
358
358
  async parseStatusWebhook() {
359
- await this.debugLog('parseStatusWebhook');
360
- await this.debugLog(`(slidePosition, battery) = Webhook:(${this.webhookContext.slidePosition}, ${this.webhookContext.battery}), current:(${this.WindowCovering.CurrentPosition}, ${this.Battery.BatteryLevel})`);
359
+ this.debugLog('parseStatusWebhook');
360
+ this.debugLog(`(slidePosition, battery) = Webhook:(${this.webhookContext.slidePosition}, ${this.webhookContext.battery}), current:(${this.WindowCovering.CurrentPosition}, ${this.Battery.BatteryLevel})`);
361
361
  // CurrentPosition
362
362
  this.WindowCovering.CurrentPosition = 100 - this.webhookContext.slidePosition;
363
363
  await this.getCurrentPostion();
364
364
  // BatteryLevel
365
365
  this.Battery.BatteryLevel = this.webhookContext.battery;
366
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
366
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
367
367
  // StatusLowBattery
368
368
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
369
369
  ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
370
370
  : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
371
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
371
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
372
372
  }
373
373
  /**
374
374
  * Asks the SwitchBot API for the latest device information
375
375
  */
376
376
  async refreshStatus() {
377
377
  if (!this.device.enableCloudService && this.OpenAPI) {
378
- await this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`);
378
+ this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`);
379
379
  }
380
380
  else if (this.BLE) {
381
381
  await this.BLERefreshStatus();
@@ -385,11 +385,11 @@ export class Curtain extends deviceBase {
385
385
  }
386
386
  else {
387
387
  await this.offlineOff();
388
- await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`);
388
+ this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`);
389
389
  }
390
390
  }
391
391
  async BLERefreshStatus() {
392
- await this.debugLog('BLERefreshStatus');
392
+ this.debugLog('BLERefreshStatus');
393
393
  const switchBotBLE = await this.switchbotBLE();
394
394
  if (switchBotBLE === undefined) {
395
395
  await this.BLERefreshConnection(switchBotBLE);
@@ -407,79 +407,79 @@ export class Curtain extends deviceBase {
407
407
  await this.updateHomeKitCharacteristics();
408
408
  }
409
409
  else {
410
- await this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`);
410
+ this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`);
411
411
  await this.BLERefreshConnection(switchBotBLE);
412
412
  }
413
413
  })();
414
414
  }
415
415
  }
416
416
  async openAPIRefreshStatus() {
417
- await this.debugLog('openAPIRefreshStatus');
417
+ this.debugLog('openAPIRefreshStatus');
418
418
  try {
419
419
  const { body } = await this.deviceRefreshStatus();
420
420
  const deviceStatus = body;
421
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
421
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
422
422
  if (await this.successfulStatusCodes(deviceStatus)) {
423
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
423
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
424
424
  this.deviceStatus = deviceStatus.body;
425
425
  await this.openAPIparseStatus();
426
426
  await this.updateHomeKitCharacteristics();
427
427
  }
428
428
  else {
429
- await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
430
- await this.debugWarnLog(deviceStatus);
429
+ this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
430
+ this.debugWarnLog(deviceStatus);
431
431
  }
432
432
  }
433
433
  catch (e) {
434
434
  await this.apiError(e);
435
- await this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
435
+ this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
436
436
  }
437
437
  }
438
438
  async registerWebhook() {
439
439
  if (this.device.webhook) {
440
- await this.debugLog('is listening webhook.');
440
+ this.debugLog('is listening webhook.');
441
441
  this.platform.webhookEventHandler[this.device.deviceId] = async (context) => {
442
442
  try {
443
- await this.debugLog(`received Webhook: ${JSON.stringify(context)}`);
443
+ this.debugLog(`received Webhook: ${JSON.stringify(context)}`);
444
444
  this.webhookContext = context;
445
445
  await this.parseStatusWebhook();
446
446
  await this.updateHomeKitCharacteristics();
447
447
  }
448
448
  catch (e) {
449
- await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`);
449
+ this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`);
450
450
  }
451
451
  };
452
452
  }
453
453
  else {
454
- await this.debugLog('is not listening webhook.');
454
+ this.debugLog('is not listening webhook.');
455
455
  }
456
456
  }
457
457
  async registerPlatformBLE() {
458
- await this.debugLog('registerPlatformBLE');
458
+ this.debugLog('registerPlatformBLE');
459
459
  if (this.config.options?.BLE) {
460
- await this.debugLog('is listening to Platform BLE.');
460
+ this.debugLog('is listening to Platform BLE.');
461
461
  try {
462
462
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId);
463
463
  this.device.bleMac = formattedDeviceId;
464
- await this.debugLog(`bleMac: ${this.device.bleMac}`);
464
+ this.debugLog(`bleMac: ${this.device.bleMac}`);
465
465
  this.platform.bleEventHandler[this.device.bleMac] = async (context) => {
466
466
  try {
467
- await this.debugLog(`received BLE: ${JSON.stringify(context)}`);
467
+ this.debugLog(`received BLE: ${JSON.stringify(context)}`);
468
468
  this.serviceData = context;
469
469
  await this.BLEparseStatus();
470
470
  await this.updateHomeKitCharacteristics();
471
471
  }
472
472
  catch (e) {
473
- await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`);
473
+ this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`);
474
474
  }
475
475
  };
476
476
  }
477
477
  catch (error) {
478
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`);
478
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`);
479
479
  }
480
480
  }
481
481
  else {
482
- await this.debugLog('is not listening to Platform BLE');
482
+ this.debugLog('is not listening to Platform BLE');
483
483
  }
484
484
  }
485
485
  /**
@@ -487,7 +487,7 @@ export class Curtain extends deviceBase {
487
487
  */
488
488
  async pushChanges() {
489
489
  if (!this.device.enableCloudService && this.OpenAPI) {
490
- await this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`);
490
+ this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`);
491
491
  }
492
492
  else if (this.BLE) {
493
493
  await this.BLEpushChanges();
@@ -497,7 +497,7 @@ export class Curtain extends deviceBase {
497
497
  }
498
498
  else {
499
499
  await this.offlineOff();
500
- await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, pushChanges will not happen.`);
500
+ this.debugWarnLog(`Connection Type: ${this.device.connectionType}, pushChanges will not happen.`);
501
501
  }
502
502
  // Refresh the status from the API
503
503
  interval(15000)
@@ -508,58 +508,58 @@ export class Curtain extends deviceBase {
508
508
  });
509
509
  }
510
510
  async BLEpushChanges() {
511
- await this.debugLog('BLEpushChanges');
511
+ this.debugLog('BLEpushChanges');
512
512
  if (this.WindowCovering.TargetPosition !== this.WindowCovering.CurrentPosition) {
513
513
  const switchBotBLE = await this.platform.connectBLE(this.accessory, this.device);
514
514
  try {
515
515
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId);
516
516
  this.device.bleMac = formattedDeviceId;
517
- await this.debugLog(`bleMac: ${this.device.bleMac}`);
517
+ this.debugLog(`bleMac: ${this.device.bleMac}`);
518
518
  const { setPositionMode, Mode } = await this.setPerformance();
519
519
  const adjustedMode = setPositionMode === 1 ? 0x01 : 0xFF;
520
- await this.debugLog(`Mode: ${Mode}, setPositionMode: ${setPositionMode}`);
520
+ this.debugLog(`Mode: ${Mode}, setPositionMode: ${setPositionMode}`);
521
521
  if (switchBotBLE !== false) {
522
522
  switchBotBLE
523
523
  .discover({ model: this.device.bleModel, quick: true, id: this.device.bleMac })
524
524
  .then(async (device_list) => {
525
525
  const deviceList = device_list;
526
526
  return await this.retryBLE({
527
- max: await this.maxRetryBLE(),
527
+ max: this.maxRetryBLE(),
528
528
  fn: async () => {
529
529
  return await deviceList[0].runToPos(100 - Number(this.WindowCovering.TargetPosition), adjustedMode);
530
530
  },
531
531
  });
532
532
  })
533
533
  .then(async () => {
534
- await this.successLog(`TargetPostion: ${this.WindowCovering.TargetPosition} sent over SwitchBot BLE, sent successfully`);
534
+ this.successLog(`TargetPostion: ${this.WindowCovering.TargetPosition} sent over SwitchBot BLE, sent successfully`);
535
535
  await this.updateHomeKitCharacteristics();
536
536
  })
537
537
  .catch(async (e) => {
538
538
  await this.apiError(e);
539
- await this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
539
+ this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
540
540
  await this.BLEPushConnection();
541
541
  });
542
542
  }
543
543
  else {
544
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`);
544
+ this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`);
545
545
  await this.BLEPushConnection();
546
546
  }
547
547
  }
548
548
  catch (error) {
549
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`);
549
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`);
550
550
  }
551
551
  }
552
552
  else {
553
- await this.debugLog(`No changes (BLEpushChanges), TargetPosition: ${this.WindowCovering.TargetPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
553
+ this.debugLog(`No changes (BLEpushChanges), TargetPosition: ${this.WindowCovering.TargetPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
554
554
  }
555
555
  }
556
556
  async openAPIpushChanges() {
557
- await this.debugLog('openAPIpushChanges');
557
+ this.debugLog('openAPIpushChanges');
558
558
  if (this.WindowCovering.TargetPosition !== this.WindowCovering.CurrentPosition || this.device.disableCaching) {
559
- await this.debugLog(`Pushing ${this.WindowCovering.TargetPosition}`);
559
+ this.debugLog(`Pushing ${this.WindowCovering.TargetPosition}`);
560
560
  const adjustedTargetPosition = 100 - Number(this.WindowCovering.TargetPosition);
561
561
  const { setPositionMode, Mode } = await this.setPerformance();
562
- await this.debugLog(`Mode: ${Mode}, setPositionMode: ${setPositionMode}`);
562
+ this.debugLog(`Mode: ${Mode}, setPositionMode: ${setPositionMode}`);
563
563
  const adjustedMode = setPositionMode || 'ff';
564
564
  let bodyChange;
565
565
  if (this.WindowCovering.HoldPosition) {
@@ -576,13 +576,13 @@ export class Curtain extends deviceBase {
576
576
  commandType: 'command',
577
577
  };
578
578
  }
579
- await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
579
+ this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
580
580
  try {
581
- const { body } = await this.pushChangeRequest(bodyChange);
582
- const deviceStatus = await body;
583
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
581
+ const response = await this.pushChangeRequest(bodyChange);
582
+ const deviceStatus = response.body;
583
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
584
584
  if (await this.successfulStatusCodes(deviceStatus)) {
585
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
585
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
586
586
  await this.updateHomeKitCharacteristics();
587
587
  }
588
588
  else {
@@ -591,11 +591,11 @@ export class Curtain extends deviceBase {
591
591
  }
592
592
  catch (e) {
593
593
  await this.apiError(e);
594
- await this.errorLog(`failed openAPIpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
594
+ this.errorLog(`failed openAPIpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
595
595
  }
596
596
  }
597
597
  else {
598
- await this.debugLog(`No changes (openAPIpushChanges), CurrentPosition: ${this.WindowCovering.CurrentPosition}, TargetPosition: ${this.WindowCovering.TargetPosition}`);
598
+ this.debugLog(`No changes (openAPIpushChanges), CurrentPosition: ${this.WindowCovering.CurrentPosition}, TargetPosition: ${this.WindowCovering.TargetPosition}`);
599
599
  }
600
600
  }
601
601
  /**
@@ -603,10 +603,10 @@ export class Curtain extends deviceBase {
603
603
  */
604
604
  async TargetPositionSet(value) {
605
605
  if (this.WindowCovering.TargetPosition !== this.accessory.context.TargetPosition) {
606
- await this.infoLog(`Set TargetPosition: ${value}`);
606
+ this.infoLog(`Set TargetPosition: ${value}`);
607
607
  }
608
608
  else {
609
- await this.debugLog(`No Changes, TargetPosition: ${value}`);
609
+ this.debugLog(`No Changes, TargetPosition: ${value}`);
610
610
  }
611
611
  // Set HoldPosition to false when TargetPosition is changed
612
612
  this.WindowCovering.HoldPosition = false;
@@ -621,17 +621,17 @@ export class Curtain extends deviceBase {
621
621
  if (this.WindowCovering.TargetPosition > this.WindowCovering.CurrentPosition) {
622
622
  this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.INCREASING;
623
623
  this.setNewTarget = true;
624
- await this.debugLog(`value: ${this.WindowCovering.TargetPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
624
+ this.debugLog(`value: ${this.WindowCovering.TargetPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
625
625
  }
626
626
  else if (this.WindowCovering.TargetPosition < this.WindowCovering.CurrentPosition) {
627
627
  this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.DECREASING;
628
628
  this.setNewTarget = true;
629
- await this.debugLog(`value: ${this.WindowCovering.TargetPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
629
+ this.debugLog(`value: ${this.WindowCovering.TargetPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
630
630
  }
631
631
  else {
632
632
  this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.STOPPED;
633
633
  this.setNewTarget = false;
634
- await this.debugLog(`value: ${this.WindowCovering.TargetPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
634
+ this.debugLog(`value: ${this.WindowCovering.TargetPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
635
635
  }
636
636
  this.WindowCovering.Service.setCharacteristic(this.hap.Characteristic.PositionState, this.WindowCovering.PositionState);
637
637
  this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.PositionState).updateValue(this.WindowCovering.PositionState);
@@ -640,10 +640,10 @@ export class Curtain extends deviceBase {
640
640
  * The minimum time depends on the network control latency.
641
641
  */
642
642
  clearTimeout(this.setNewTargetTimer);
643
- await this.debugLog(`deviceUpdateRate: ${this.deviceUpdateRate}`);
643
+ this.debugLog(`deviceUpdateRate: ${this.deviceUpdateRate}`);
644
644
  if (this.setNewTarget) {
645
645
  this.setNewTargetTimer = setTimeout(async () => {
646
- await this.debugLog(`setNewTarget ${this.setNewTarget} timeout`);
646
+ this.debugLog(`setNewTarget ${this.setNewTarget} timeout`);
647
647
  this.setNewTarget = false;
648
648
  }, this.deviceUpdateRate * 1000);
649
649
  }
@@ -707,14 +707,14 @@ export class Curtain extends deviceBase {
707
707
  }
708
708
  async BLEPushConnection() {
709
709
  if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
710
- await this.warnLog('Using OpenAPI Connection to Push Changes');
710
+ this.warnLog('Using OpenAPI Connection to Push Changes');
711
711
  await this.openAPIpushChanges();
712
712
  }
713
713
  }
714
714
  async BLERefreshConnection(switchbot) {
715
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
715
+ this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
716
716
  if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
717
- await this.warnLog('Using OpenAPI Connection to Refresh Status');
717
+ this.warnLog('Using OpenAPI Connection to Refresh Status');
718
718
  await this.openAPIRefreshStatus();
719
719
  }
720
720
  }
@@ -754,7 +754,7 @@ export class Curtain extends deviceBase {
754
754
  }
755
755
  async getCurrentPostion() {
756
756
  await this.setMinMax();
757
- await this.debugLog(`CurrentPosition ${this.WindowCovering.CurrentPosition}`);
757
+ this.debugLog(`CurrentPosition ${this.WindowCovering.CurrentPosition}`);
758
758
  this.hasLoggedStandby = this.hasLoggedStandby ?? false;
759
759
  if (this.deviceStatus ? (this.setNewTarget || this.deviceStatus.moving) : this.setNewTarget) {
760
760
  this.hasLoggedStandby = false;
@@ -762,36 +762,36 @@ export class Curtain extends deviceBase {
762
762
  this.curtainMoving = true;
763
763
  await this.setMinMax();
764
764
  if (this.WindowCovering.TargetPosition > this.WindowCovering.CurrentPosition) {
765
- await this.debugLog(`Closing, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
765
+ this.debugLog(`Closing, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
766
766
  this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.INCREASING;
767
767
  this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.PositionState).updateValue(this.WindowCovering.PositionState);
768
- await this.debugLog(`Increasing, PositionState: ${this.WindowCovering.PositionState}`);
768
+ this.debugLog(`Increasing, PositionState: ${this.WindowCovering.PositionState}`);
769
769
  }
770
770
  else if (this.WindowCovering.TargetPosition < this.WindowCovering.CurrentPosition) {
771
- await this.debugLog(`Opening, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
771
+ this.debugLog(`Opening, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
772
772
  this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.DECREASING;
773
773
  this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.PositionState).updateValue(this.WindowCovering.PositionState);
774
- await this.debugLog(`Decreasing, PositionState: ${this.WindowCovering.PositionState}`);
774
+ this.debugLog(`Decreasing, PositionState: ${this.WindowCovering.PositionState}`);
775
775
  }
776
776
  else {
777
- await this.debugLog(`Standby, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
777
+ this.debugLog(`Standby, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
778
778
  this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.STOPPED;
779
779
  this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.PositionState).updateValue(this.WindowCovering.PositionState);
780
- await this.debugLog(`Stopped, PositionState: ${this.WindowCovering.PositionState}`);
780
+ this.debugLog(`Stopped, PositionState: ${this.WindowCovering.PositionState}`);
781
781
  }
782
782
  }
783
783
  else {
784
784
  if (!this.hasLoggedStandby) {
785
- await this.infoLog('Standby ...');
785
+ this.infoLog('Standby ...');
786
786
  this.hasLoggedStandby = true;
787
787
  }
788
788
  this.curtainMoving = false;
789
- await this.debugLog(`Standby, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
789
+ this.debugLog(`Standby, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
790
790
  this.WindowCovering.TargetPosition = this.WindowCovering.CurrentPosition;
791
791
  this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.STOPPED;
792
- await this.debugLog(`Stopped, PositionState: ${this.WindowCovering.PositionState}`);
792
+ this.debugLog(`Stopped, PositionState: ${this.WindowCovering.PositionState}`);
793
793
  }
794
- await this.debugLog(`CurrentPosition: ${this.WindowCovering.CurrentPosition}, TargetPosition: ${this.WindowCovering.TargetPosition}, PositionState: ${this.WindowCovering.PositionState},`);
794
+ this.debugLog(`CurrentPosition: ${this.WindowCovering.CurrentPosition}, TargetPosition: ${this.WindowCovering.TargetPosition}, PositionState: ${this.WindowCovering.PositionState},`);
795
795
  }
796
796
  async setMinMax() {
797
797
  if (this.device.set_min) {