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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/device/blindtilt.js +103 -103
  3. package/dist/device/blindtilt.js.map +1 -1
  4. package/dist/device/bot.js +84 -84
  5. package/dist/device/bot.js.map +1 -1
  6. package/dist/device/ceilinglight.js +97 -97
  7. package/dist/device/ceilinglight.js.map +1 -1
  8. package/dist/device/colorbulb.js +139 -139
  9. package/dist/device/colorbulb.js.map +1 -1
  10. package/dist/device/contact.js +47 -47
  11. package/dist/device/contact.js.map +1 -1
  12. package/dist/device/curtain.d.ts +1 -1
  13. package/dist/device/curtain.d.ts.map +1 -1
  14. package/dist/device/curtain.js +91 -89
  15. package/dist/device/curtain.js.map +1 -1
  16. package/dist/device/device.d.ts +12 -12
  17. package/dist/device/device.d.ts.map +1 -1
  18. package/dist/device/device.js +42 -42
  19. package/dist/device/device.js.map +1 -1
  20. package/dist/device/fan.js +95 -95
  21. package/dist/device/fan.js.map +1 -1
  22. package/dist/device/hub.js +46 -46
  23. package/dist/device/hub.js.map +1 -1
  24. package/dist/device/humidifier.js +84 -84
  25. package/dist/device/humidifier.js.map +1 -1
  26. package/dist/device/iosensor.js +44 -44
  27. package/dist/device/iosensor.js.map +1 -1
  28. package/dist/device/lightstrip.js +118 -118
  29. package/dist/device/lightstrip.js.map +1 -1
  30. package/dist/device/lock.js +74 -74
  31. package/dist/device/lock.js.map +1 -1
  32. package/dist/device/meter.js +44 -44
  33. package/dist/device/meter.js.map +1 -1
  34. package/dist/device/meterplus.js +42 -42
  35. package/dist/device/meterplus.js.map +1 -1
  36. package/dist/device/meterpro.js +42 -42
  37. package/dist/device/meterpro.js.map +1 -1
  38. package/dist/device/motion.js +44 -44
  39. package/dist/device/motion.js.map +1 -1
  40. package/dist/device/plug.d.ts.map +1 -1
  41. package/dist/device/plug.js +59 -59
  42. package/dist/device/plug.js.map +1 -1
  43. package/dist/device/robotvacuumcleaner.js +73 -73
  44. package/dist/device/robotvacuumcleaner.js.map +1 -1
  45. package/dist/device/waterdetector.js +44 -44
  46. package/dist/device/waterdetector.js.map +1 -1
  47. package/dist/irdevice/airconditioner.js +31 -31
  48. package/dist/irdevice/airconditioner.js.map +1 -1
  49. package/dist/irdevice/airpurifier.js +10 -10
  50. package/dist/irdevice/airpurifier.js.map +1 -1
  51. package/dist/irdevice/camera.js +9 -9
  52. package/dist/irdevice/camera.js.map +1 -1
  53. package/dist/irdevice/fan.js +11 -11
  54. package/dist/irdevice/fan.js.map +1 -1
  55. package/dist/irdevice/irdevice.js +11 -11
  56. package/dist/irdevice/irdevice.js.map +1 -1
  57. package/dist/irdevice/light.js +9 -9
  58. package/dist/irdevice/light.js.map +1 -1
  59. package/dist/irdevice/other.js +55 -55
  60. package/dist/irdevice/other.js.map +1 -1
  61. package/dist/irdevice/tv.js +33 -33
  62. package/dist/irdevice/tv.js.map +1 -1
  63. package/dist/irdevice/vacuumcleaner.js +9 -9
  64. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  65. package/dist/irdevice/waterheater.js +9 -9
  66. package/dist/irdevice/waterheater.js.map +1 -1
  67. package/dist/platform.js +228 -228
  68. package/dist/platform.js.map +1 -1
  69. package/package.json +9 -9
  70. package/src/device/blindtilt.ts +103 -103
  71. package/src/device/bot.ts +84 -84
  72. package/src/device/ceilinglight.ts +97 -97
  73. package/src/device/colorbulb.ts +139 -139
  74. package/src/device/contact.ts +47 -47
  75. package/src/device/curtain.ts +91 -89
  76. package/src/device/device.ts +42 -42
  77. package/src/device/fan.ts +95 -95
  78. package/src/device/hub.ts +46 -46
  79. package/src/device/humidifier.ts +84 -84
  80. package/src/device/iosensor.ts +44 -44
  81. package/src/device/lightstrip.ts +118 -118
  82. package/src/device/lock.ts +74 -74
  83. package/src/device/meter.ts +44 -44
  84. package/src/device/meterplus.ts +42 -42
  85. package/src/device/meterpro.ts +42 -42
  86. package/src/device/motion.ts +44 -44
  87. package/src/device/plug.ts +61 -61
  88. package/src/device/robotvacuumcleaner.ts +73 -73
  89. package/src/device/waterdetector.ts +44 -44
  90. package/src/irdevice/airconditioner.ts +31 -31
  91. package/src/irdevice/airpurifier.ts +10 -10
  92. package/src/irdevice/camera.ts +9 -9
  93. package/src/irdevice/fan.ts +11 -11
  94. package/src/irdevice/irdevice.ts +11 -11
  95. package/src/irdevice/light.ts +9 -9
  96. package/src/irdevice/other.ts +55 -55
  97. package/src/irdevice/tv.ts +33 -33
  98. package/src/irdevice/vacuumcleaner.ts +9 -9
  99. package/src/irdevice/waterheater.ts +9 -9
  100. package/src/platform.ts +228 -228
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/)
4
4
 
5
+ ## [4.1.1](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v4.1.0) (2024-10-21)
6
+
7
+ ### What's Changed
8
+ - Remove unneeded light level check [#1096](https://github.com/OpenWonderLabs/homebridge-switchbot/pull/1096), Thanks [@dnicolson](https://github.com/dnicolson)
9
+ - Remove unneeded async [#1089](https://github.com/OpenWonderLabs/homebridge-switchbot/pull/1089) & [#1094](https://github.com/OpenWonderLabs/homebridge-switchbot/pull/1094), Thanks [@dnicolson](https://github.com/dnicolson)
10
+ - Fix characteristic warning [#1093](https://github.com/OpenWonderLabs/homebridge-switchbot/pull/1093), Thanks [@dnicolson](https://github.com/dnicolson)
11
+ - Fix light level [#1092](https://github.com/OpenWonderLabs/homebridge-switchbot/pull/1092), Thanks [@dnicolson](https://github.com/dnicolson)
12
+ - Fix device types [#1091](https://github.com/OpenWonderLabs/homebridge-switchbot/pull/1091), Thanks [@dnicolson](https://github.com/dnicolson)
13
+ - Fix curtain light sensor [#1090](https://github.com/OpenWonderLabs/homebridge-switchbot/pull/1090), Thanks [@dnicolson](https://github.com/dnicolson)
14
+ - Fix max retry [#1088](https://github.com/OpenWonderLabs/homebridge-switchbot/pull/1088), Thanks [@dnicolson](https://github.com/dnicolson)
15
+ - Housekeeping and updated dependencies.
16
+
17
+ **Full Changelog**: https://github.com/OpenWonderLabs/homebridge-switchbot/compare/v4.0.0...v4.1.0
18
+
5
19
  ## [4.1.0](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v4.1.0) (2024-10-21)
6
20
 
7
21
  ### What's Changed
@@ -224,7 +224,7 @@ export class BlindTilt 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.blindTiltUpdateInProgress = false;
230
230
  });
@@ -233,62 +233,62 @@ export class BlindTilt extends deviceBase {
233
233
  * Parse the device status from the SwitchBotBLE API
234
234
  */
235
235
  async BLEparseStatus() {
236
- await this.debugLog('BLEparseStatus');
237
- await this.debugLog(`(direction, slidePosition, battery, version) = BLE:(${this.serviceData.tilt}, ${this.serviceData.tilt}, ${this.serviceData.battery}, ${this.accessory.context.version}), current:(${this.WindowCovering.CurrentHorizontalTiltAngle}, ${this.WindowCovering.CurrentPosition}, ${this.Battery.BatteryLevel}, ${this.accessory.context.version})`);
236
+ this.debugLog('BLEparseStatus');
237
+ this.debugLog(`(direction, slidePosition, battery, version) = BLE:(${this.serviceData.tilt}, ${this.serviceData.tilt}, ${this.serviceData.battery}, ${this.accessory.context.version}), current:(${this.WindowCovering.CurrentHorizontalTiltAngle}, ${this.WindowCovering.CurrentPosition}, ${this.Battery.BatteryLevel}, ${this.accessory.context.version})`);
238
238
  // CurrentPosition
239
239
  this.WindowCovering.CurrentPosition = 100 - Number(this.serviceData.tilt);
240
240
  await this.setMinMax();
241
- await this.debugLog(`CurrentPosition ${this.WindowCovering.CurrentPosition}`);
241
+ this.debugLog(`CurrentPosition ${this.WindowCovering.CurrentPosition}`);
242
242
  if (this.setNewTarget) {
243
- await this.infoLog('Checking Status ...');
243
+ this.infoLog('Checking Status ...');
244
244
  }
245
245
  if (this.setNewTarget && this.serviceData.inMotion) {
246
246
  this.blindTiltMoving = true;
247
247
  await this.setMinMax();
248
248
  if (Number(this.WindowCovering.TargetPosition) > this.WindowCovering.CurrentPosition) {
249
- await this.debugLog(`Closing, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
249
+ this.debugLog(`Closing, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
250
250
  this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.INCREASING;
251
251
  this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.PositionState).updateValue(this.WindowCovering.PositionState);
252
- await this.debugLog(`Increasing, PositionState: ${this.WindowCovering.PositionState}`);
252
+ this.debugLog(`Increasing, PositionState: ${this.WindowCovering.PositionState}`);
253
253
  }
254
254
  else if (Number(this.WindowCovering.TargetPosition) < this.WindowCovering.CurrentPosition) {
255
- await this.debugLog(`Opening, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
255
+ this.debugLog(`Opening, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
256
256
  this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.DECREASING;
257
257
  this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.PositionState).updateValue(this.WindowCovering.PositionState);
258
- await this.debugLog(`Decreasing, PositionState: ${this.WindowCovering.PositionState}`);
258
+ this.debugLog(`Decreasing, PositionState: ${this.WindowCovering.PositionState}`);
259
259
  }
260
260
  else {
261
- await this.debugLog(`Standby, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
261
+ this.debugLog(`Standby, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
262
262
  this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.STOPPED;
263
263
  this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.PositionState).updateValue(this.WindowCovering.PositionState);
264
- await this.debugLog('Stopped, PositionState', this.WindowCovering.PositionState);
264
+ this.debugLog('Stopped, PositionState', this.WindowCovering.PositionState);
265
265
  }
266
266
  }
267
267
  else {
268
268
  this.blindTiltMoving = false;
269
- await this.debugLog(`Standby, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
269
+ this.debugLog(`Standby, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
270
270
  this.WindowCovering.TargetPosition = this.WindowCovering.CurrentPosition;
271
271
  this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.STOPPED;
272
- await this.debugLog(`Stopped, PositionState: ${this.WindowCovering.PositionState}`);
272
+ this.debugLog(`Stopped, PositionState: ${this.WindowCovering.PositionState}`);
273
273
  }
274
- await this.debugLog(`CurrentPosition: ${this.WindowCovering.CurrentPosition}, TargetPosition: ${this.WindowCovering.TargetPosition}, PositionState: ${this.WindowCovering.PositionState}`);
274
+ this.debugLog(`CurrentPosition: ${this.WindowCovering.CurrentPosition}, TargetPosition: ${this.WindowCovering.TargetPosition}, PositionState: ${this.WindowCovering.PositionState}`);
275
275
  // CurrentAmbientLightLevel
276
276
  if (!this.device.hide_lightsensor && this.LightSensor?.Service) {
277
277
  const set_minLux = this.device.set_minLux ?? 1;
278
278
  const set_maxLux = this.device.set_maxLux ?? 6001;
279
279
  const spaceBetweenLevels = 9;
280
- await this.getLightLevel(this.serviceData.lightLevel, set_minLux, set_maxLux, spaceBetweenLevels);
281
- await this.debugLog(`LightLevel: ${this.serviceData.lightLevel}, CurrentAmbientLightLevel: ${this.LightSensor.CurrentAmbientLightLevel}`);
280
+ this.getLightLevel(this.serviceData.lightLevel, set_minLux, set_maxLux, spaceBetweenLevels);
281
+ this.debugLog(`LightLevel: ${this.serviceData.lightLevel}, CurrentAmbientLightLevel: ${this.LightSensor.CurrentAmbientLightLevel}`);
282
282
  }
283
283
  // BatteryLevel
284
284
  if (this.serviceData?.battery) {
285
285
  this.Battery.BatteryLevel = this.serviceData.battery;
286
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
286
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
287
287
  // StatusLowBattery
288
288
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
289
289
  ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
290
290
  : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
291
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
291
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
292
292
  }
293
293
  }
294
294
  ;
@@ -296,28 +296,28 @@ export class BlindTilt extends deviceBase {
296
296
  * Parse the device status from the SwitchBot OpenAPI
297
297
  */
298
298
  async openAPIparseStatus() {
299
- await this.debugLog('openAPIparseStatus');
300
- await this.debugLog(`(direction, slidePosition, battery, version) = OpenAPI:(${this.deviceStatus.direction}, ${this.deviceStatus.slidePosition}, ${this.deviceStatus.battery}, ${this.deviceStatus.version}), current:(${this.WindowCovering.CurrentHorizontalTiltAngle}, ${this.WindowCovering.CurrentPosition}, ${this.Battery.BatteryLevel}, ${this.accessory.context.version})`);
299
+ this.debugLog('openAPIparseStatus');
300
+ this.debugLog(`(direction, slidePosition, battery, version) = OpenAPI:(${this.deviceStatus.direction}, ${this.deviceStatus.slidePosition}, ${this.deviceStatus.battery}, ${this.deviceStatus.version}), current:(${this.WindowCovering.CurrentHorizontalTiltAngle}, ${this.WindowCovering.CurrentPosition}, ${this.Battery.BatteryLevel}, ${this.accessory.context.version})`);
301
301
  // CurrentPosition
302
302
  await this.getCurrentPosttionDirection(this.deviceStatus.direction, this.deviceStatus.slidePosition);
303
303
  if (!this.device.hide_lightsensor && this.LightSensor?.Service) {
304
304
  const set_minLux = this.device.set_minLux ?? 1;
305
305
  const set_maxLux = this.device.set_maxLux ?? 6001;
306
306
  const lightLevel = this.deviceStatus.lightLevel === 'bright' ? set_maxLux : set_minLux;
307
- this.LightSensor.CurrentAmbientLightLevel = await this.getLightLevel(lightLevel, set_minLux, set_maxLux, 2);
308
- await this.debugLog(`LightLevel: ${this.deviceStatus.lightLevel}, CurrentAmbientLightLevel: ${this.LightSensor.CurrentAmbientLightLevel}`);
307
+ this.LightSensor.CurrentAmbientLightLevel = this.getLightLevel(lightLevel, set_minLux, set_maxLux, 2);
308
+ this.debugLog(`LightLevel: ${this.deviceStatus.lightLevel}, CurrentAmbientLightLevel: ${this.LightSensor.CurrentAmbientLightLevel}`);
309
309
  }
310
310
  // BatteryLevel
311
311
  this.Battery.BatteryLevel = this.deviceStatus.battery;
312
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
312
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
313
313
  // StatusLowBattery
314
314
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
315
315
  ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
316
316
  : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
317
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
317
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
318
318
  // Firmware Version
319
319
  const version = this.deviceStatus.version.toString();
320
- await this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`);
320
+ this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`);
321
321
  let deviceVersion;
322
322
  if (version?.includes('.') === false) {
323
323
  const replace = version?.replace(/^V|-.*$/g, '');
@@ -335,21 +335,21 @@ export class BlindTilt extends deviceBase {
335
335
  .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
336
336
  .updateValue(deviceVersion);
337
337
  this.accessory.context.version = deviceVersion;
338
- await this.debugLog(`version: ${this.accessory.context.version}`);
338
+ this.debugLog(`version: ${this.accessory.context.version}`);
339
339
  }
340
340
  async parseStatusWebhook() {
341
- await this.debugLog('parseStatusWebhook');
342
- await this.debugLog(`(slidePosition, battery, version) = Webhook:(${this.webhookContext.direction}, ${this.webhookContext.slidePosition}, ${this.webhookContext.battery}, ${this.webhookContext.version}, current:(${this.WindowCovering.CurrentHorizontalTiltAngle}, ${this.WindowCovering.CurrentPosition}, ${this.Battery.BatteryLevel}, ${this.accessory.context.version})`);
341
+ this.debugLog('parseStatusWebhook');
342
+ this.debugLog(`(slidePosition, battery, version) = Webhook:(${this.webhookContext.direction}, ${this.webhookContext.slidePosition}, ${this.webhookContext.battery}, ${this.webhookContext.version}, current:(${this.WindowCovering.CurrentHorizontalTiltAngle}, ${this.WindowCovering.CurrentPosition}, ${this.Battery.BatteryLevel}, ${this.accessory.context.version})`);
343
343
  // CurrentPosition and CurrentHorizontalTiltAngle
344
344
  await this.getCurrentPosttionDirection(this.webhookContext.direction, this.webhookContext.slidePosition);
345
345
  // BatteryLevel
346
346
  this.Battery.BatteryLevel = this.webhookContext.battery;
347
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
347
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
348
348
  // StatusLowBattery
349
349
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
350
350
  ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
351
351
  : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
352
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
352
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
353
353
  // Firmware Version
354
354
  const deviceVersion = this.webhookContext.version.replace(/^V|-.*$/g, '') ?? '0.0.0';
355
355
  this.accessory
@@ -359,14 +359,14 @@ export class BlindTilt extends deviceBase {
359
359
  .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
360
360
  .updateValue(deviceVersion);
361
361
  this.accessory.context.version = deviceVersion;
362
- await this.debugSuccessLog(`version: ${this.accessory.context.version}`);
362
+ this.debugSuccessLog(`version: ${this.accessory.context.version}`);
363
363
  }
364
364
  /**
365
365
  * Asks the SwitchBot API for the latest device information
366
366
  */
367
367
  async refreshStatus() {
368
368
  if (!this.device.enableCloudService && this.OpenAPI) {
369
- await this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`);
369
+ this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`);
370
370
  }
371
371
  else if (this.BLE) {
372
372
  await this.BLERefreshStatus();
@@ -376,11 +376,11 @@ export class BlindTilt extends deviceBase {
376
376
  }
377
377
  else {
378
378
  await this.offlineOff();
379
- await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`);
379
+ this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`);
380
380
  }
381
381
  }
382
382
  async BLERefreshStatus() {
383
- await this.debugLog('BLERefreshStatus');
383
+ this.debugLog('BLERefreshStatus');
384
384
  const switchBotBLE = await this.switchbotBLE();
385
385
  if (switchBotBLE === undefined) {
386
386
  await this.BLERefreshConnection(switchBotBLE);
@@ -397,84 +397,84 @@ export class BlindTilt extends deviceBase {
397
397
  await this.updateHomeKitCharacteristics();
398
398
  }
399
399
  else {
400
- await this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`);
400
+ this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`);
401
401
  await this.BLERefreshConnection(switchBotBLE);
402
402
  }
403
403
  })();
404
404
  }
405
405
  }
406
406
  async registerPlatformBLE() {
407
- await this.debugLog('registerPlatformBLE');
407
+ this.debugLog('registerPlatformBLE');
408
408
  if (this.config.options?.BLE) {
409
- await this.debugLog('is listening to Platform BLE.');
409
+ this.debugLog('is listening to Platform BLE.');
410
410
  try {
411
411
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId);
412
412
  this.device.bleMac = formattedDeviceId;
413
- await this.debugLog(`bleMac: ${this.device.bleMac}`);
413
+ this.debugLog(`bleMac: ${this.device.bleMac}`);
414
414
  this.platform.bleEventHandler[this.device.bleMac] = async (context) => {
415
415
  try {
416
- await this.debugLog(`received BLE: ${JSON.stringify(context)}`);
416
+ this.debugLog(`received BLE: ${JSON.stringify(context)}`);
417
417
  this.serviceData = context;
418
418
  await this.BLEparseStatus();
419
419
  await this.updateHomeKitCharacteristics();
420
420
  }
421
421
  catch (e) {
422
- await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`);
422
+ this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`);
423
423
  }
424
424
  };
425
425
  }
426
426
  catch (error) {
427
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`);
427
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`);
428
428
  }
429
429
  }
430
430
  else {
431
- await this.debugLog('is not listening to Platform BLE');
431
+ this.debugLog('is not listening to Platform BLE');
432
432
  }
433
433
  }
434
434
  async openAPIRefreshStatus() {
435
- await this.debugLog('openAPIRefreshStatus');
435
+ this.debugLog('openAPIRefreshStatus');
436
436
  try {
437
- const { body } = await this.deviceRefreshStatus();
438
- const deviceStatus = await body;
439
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
437
+ const response = await this.deviceRefreshStatus();
438
+ const deviceStatus = response.body;
439
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
440
440
  if (await this.successfulStatusCodes(deviceStatus)) {
441
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
441
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
442
442
  this.deviceStatus = deviceStatus.body;
443
443
  await this.openAPIparseStatus();
444
444
  await this.updateHomeKitCharacteristics();
445
445
  }
446
446
  else {
447
- await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
448
- await this.debugWarnLog(deviceStatus);
447
+ this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
448
+ this.debugWarnLog(deviceStatus);
449
449
  }
450
450
  }
451
451
  catch (e) {
452
452
  await this.apiError(e);
453
- await this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
453
+ this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
454
454
  }
455
455
  }
456
456
  async registerWebhook() {
457
457
  if (this.device.webhook) {
458
- await this.debugLog('is listening webhook.');
458
+ this.debugLog('is listening webhook.');
459
459
  this.platform.webhookEventHandler[this.device.deviceId] = async (context) => {
460
460
  try {
461
- await this.debugLog(`received Webhook: ${JSON.stringify(context)}`);
461
+ this.debugLog(`received Webhook: ${JSON.stringify(context)}`);
462
462
  this.webhookContext = context;
463
463
  await this.parseStatusWebhook();
464
464
  await this.updateHomeKitCharacteristics();
465
465
  }
466
466
  catch (e) {
467
- await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`);
467
+ this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`);
468
468
  }
469
469
  };
470
470
  }
471
471
  else {
472
- await this.debugLog('is not listening webhook.');
472
+ this.debugLog('is not listening webhook.');
473
473
  }
474
474
  }
475
475
  async pushChanges() {
476
476
  if (!this.device.enableCloudService && this.OpenAPI) {
477
- await this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`);
477
+ this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`);
478
478
  }
479
479
  else if (this.BLE) {
480
480
  await this.BLEpushChanges();
@@ -484,7 +484,7 @@ export class BlindTilt extends deviceBase {
484
484
  }
485
485
  else {
486
486
  await this.offlineOff();
487
- await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, pushChanges will not happen.`);
487
+ this.debugWarnLog(`Connection Type: ${this.device.connectionType}, pushChanges will not happen.`);
488
488
  }
489
489
  // Refresh the status from the API
490
490
  interval(15000)
@@ -495,16 +495,16 @@ export class BlindTilt extends deviceBase {
495
495
  });
496
496
  }
497
497
  async BLEpushChanges() {
498
- await this.debugLog('BLEpushChanges');
498
+ this.debugLog('BLEpushChanges');
499
499
  if (this.WindowCovering.TargetPosition !== this.WindowCovering.CurrentPosition) {
500
- await this.debugLog(`BLEpushChanges On: ${this.WindowCovering.TargetPosition} OnCached: ${this.WindowCovering.CurrentPosition}`);
500
+ this.debugLog(`BLEpushChanges On: ${this.WindowCovering.TargetPosition} OnCached: ${this.WindowCovering.CurrentPosition}`);
501
501
  const switchBotBLE = await this.platform.connectBLE(this.accessory, this.device);
502
502
  try {
503
503
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId);
504
504
  this.device.bleMac = formattedDeviceId;
505
- await this.debugLog(`bleMac: ${this.device.bleMac}`);
505
+ this.debugLog(`bleMac: ${this.device.bleMac}`);
506
506
  const { setPositionMode, Mode } = await this.setPerformance();
507
- await this.debugLog(`Mode: ${Mode}, setPositionMode: ${setPositionMode}`);
507
+ this.debugLog(`Mode: ${Mode}, setPositionMode: ${setPositionMode}`);
508
508
  if (switchBotBLE !== false) {
509
509
  switchBotBLE
510
510
  .discover({ model: this.device.bleModel, quick: true, id: this.device.bleMac })
@@ -518,38 +518,38 @@ export class BlindTilt extends deviceBase {
518
518
  });
519
519
  })
520
520
  .then(async () => {
521
- await this.successLog(`TargetPostion: ${this.WindowCovering.TargetPosition} sent over SwitchBot BLE, sent successfully`);
521
+ this.successLog(`TargetPostion: ${this.WindowCovering.TargetPosition} sent over SwitchBot BLE, sent successfully`);
522
522
  await this.updateHomeKitCharacteristics();
523
523
  })
524
524
  .catch(async (e) => {
525
525
  await this.apiError(e);
526
- await this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
526
+ this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
527
527
  await this.BLEPushConnection();
528
528
  });
529
529
  }
530
530
  else {
531
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`);
531
+ this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`);
532
532
  await this.BLEPushConnection();
533
533
  }
534
534
  }
535
535
  catch (error) {
536
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`);
536
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`);
537
537
  }
538
538
  }
539
539
  else {
540
- await this.debugLog(`No changes (BLEpushChanges), TargetPosition: ${this.WindowCovering.TargetPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
540
+ this.debugLog(`No changes (BLEpushChanges), TargetPosition: ${this.WindowCovering.TargetPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
541
541
  }
542
542
  }
543
543
  async openAPIpushChanges() {
544
- await this.debugLog('openAPIpushChanges');
544
+ this.debugLog('openAPIpushChanges');
545
545
  const hasDifferentAndRelevantHorizontalTiltAngle = this.mappingMode === BlindTiltMappingMode.UseTiltForDirection
546
546
  && this.WindowCovering.TargetHorizontalTiltAngle !== this.WindowCovering.CurrentHorizontalTiltAngle;
547
547
  if (this.WindowCovering.TargetPosition !== this.WindowCovering.CurrentPosition
548
548
  || hasDifferentAndRelevantHorizontalTiltAngle || this.device.disableCaching) {
549
549
  const [direction, position] = this.mapHomekitValuesToDeviceValues(Number(this.WindowCovering.TargetPosition), Number(this.WindowCovering.TargetHorizontalTiltAngle));
550
550
  const { Mode, setPositionMode } = await this.setPerformance();
551
- await this.debugLog(`Pushing ${this.WindowCovering.TargetPosition} (device = ${direction};${position})`);
552
- await this.debugLog(`Mode: ${Mode}, setPositionMode: ${setPositionMode}`);
551
+ this.debugLog(`Pushing ${this.WindowCovering.TargetPosition} (device = ${direction};${position})`);
552
+ this.debugLog(`Mode: ${Mode}, setPositionMode: ${setPositionMode}`);
553
553
  let bodyChange;
554
554
  if (position === 100) {
555
555
  bodyChange = {
@@ -572,13 +572,13 @@ export class BlindTilt extends deviceBase {
572
572
  commandType: 'command',
573
573
  };
574
574
  }
575
- await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
575
+ this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
576
576
  try {
577
- const { body } = await this.pushChangeRequest(bodyChange);
578
- const deviceStatus = await body;
579
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
577
+ const response = await this.pushChangeRequest(bodyChange);
578
+ const deviceStatus = response.body;
579
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
580
580
  if (await this.successfulStatusCodes(deviceStatus)) {
581
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
581
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
582
582
  await this.updateHomeKitCharacteristics();
583
583
  }
584
584
  else {
@@ -587,12 +587,12 @@ export class BlindTilt extends deviceBase {
587
587
  }
588
588
  catch (e) {
589
589
  await this.apiError(e);
590
- await this.errorLog(`failed openAPIpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
590
+ this.errorLog(`failed openAPIpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
591
591
  }
592
592
  }
593
593
  else {
594
- await this.debugLog(`No changes (openAPIpushChanges), TargetPosition: ${this.WindowCovering.TargetPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
595
- await this.debugLog(`No changes (openAPIpushChanges), TargetHorizontalTiltAngle: ${this.WindowCovering.TargetHorizontalTiltAngle}, CurrentHorizontalTiltAngle: ${this.WindowCovering.CurrentHorizontalTiltAngle}`);
594
+ this.debugLog(`No changes (openAPIpushChanges), TargetPosition: ${this.WindowCovering.TargetPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
595
+ this.debugLog(`No changes (openAPIpushChanges), TargetHorizontalTiltAngle: ${this.WindowCovering.TargetHorizontalTiltAngle}, CurrentHorizontalTiltAngle: ${this.WindowCovering.CurrentHorizontalTiltAngle}`);
596
596
  }
597
597
  }
598
598
  /**
@@ -600,10 +600,10 @@ export class BlindTilt extends deviceBase {
600
600
  */
601
601
  async TargetHorizontalTiltAngleSet(value) {
602
602
  if (this.WindowCovering.TargetHorizontalTiltAngle !== this.accessory.context.TargetHorizontalTiltAngle) {
603
- await this.debugLog(`Set TargetHorizontalTiltAngle: ${value}`);
603
+ this.debugLog(`Set TargetHorizontalTiltAngle: ${value}`);
604
604
  }
605
605
  else {
606
- await this.debugLog(`No changes, TargetHorizontalTiltAngle: ${value}`);
606
+ this.debugLog(`No changes, TargetHorizontalTiltAngle: ${value}`);
607
607
  }
608
608
  // value = value < 0 ? -90 : 90;
609
609
  this.WindowCovering.TargetHorizontalTiltAngle = value;
@@ -615,10 +615,10 @@ export class BlindTilt extends deviceBase {
615
615
  */
616
616
  async TargetPositionSet(value) {
617
617
  if (this.WindowCovering.TargetPosition !== this.accessory.context.TargetPosition) {
618
- await this.debugLog(`Set TargetPosition: ${value}`);
618
+ this.debugLog(`Set TargetPosition: ${value}`);
619
619
  }
620
620
  else {
621
- await this.debugLog(`No changes, TargetPosition: ${value}`);
621
+ this.debugLog(`No changes, TargetPosition: ${value}`);
622
622
  }
623
623
  this.WindowCovering.TargetPosition = value;
624
624
  await this.mqtt('TargetPosition', this.WindowCovering.TargetPosition);
@@ -626,22 +626,22 @@ export class BlindTilt extends deviceBase {
626
626
  }
627
627
  async startUpdatingBlindTiltIfNeeded() {
628
628
  await this.setMinMax();
629
- await this.debugLog('setMinMax');
629
+ this.debugLog('setMinMax');
630
630
  if (this.WindowCovering.TargetPosition > this.WindowCovering.CurrentPosition
631
631
  || this.WindowCovering.TargetHorizontalTiltAngle !== this.WindowCovering.CurrentHorizontalTiltAngle) {
632
632
  this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.INCREASING;
633
633
  this.setNewTarget = true;
634
- await this.debugLog(`value: ${this.WindowCovering.CurrentPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
634
+ this.debugLog(`value: ${this.WindowCovering.CurrentPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
635
635
  }
636
636
  else if (this.WindowCovering.TargetPosition < this.WindowCovering.CurrentPosition) {
637
637
  this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.DECREASING;
638
638
  this.setNewTarget = true;
639
- await this.debugLog(`value: ${this.WindowCovering.CurrentPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
639
+ this.debugLog(`value: ${this.WindowCovering.CurrentPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
640
640
  }
641
641
  else {
642
642
  this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.STOPPED;
643
643
  this.setNewTarget = false;
644
- await this.debugLog(`value: ${this.WindowCovering.CurrentPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
644
+ this.debugLog(`value: ${this.WindowCovering.CurrentPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
645
645
  }
646
646
  this.WindowCovering.Service.setCharacteristic(this.hap.Characteristic.PositionState, this.WindowCovering.PositionState);
647
647
  this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.PositionState).updateValue(this.WindowCovering.PositionState);
@@ -650,10 +650,10 @@ export class BlindTilt extends deviceBase {
650
650
  * The minimum time depends on the network control latency.
651
651
  */
652
652
  clearTimeout(this.setNewTargetTimer);
653
- await this.debugLog(`deviceUpdateRate: ${this.deviceUpdateRate}`);
653
+ this.debugLog(`deviceUpdateRate: ${this.deviceUpdateRate}`);
654
654
  if (this.setNewTarget) {
655
655
  this.setNewTargetTimer = setTimeout(async () => {
656
- await this.debugLog(`setNewTarget ${this.setNewTarget} timeout`);
656
+ this.debugLog(`setNewTarget ${this.setNewTarget} timeout`);
657
657
  this.setNewTarget = false;
658
658
  }, this.deviceUpdateRate * 1000);
659
659
  }
@@ -707,14 +707,14 @@ export class BlindTilt 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
  }
@@ -796,50 +796,50 @@ export class BlindTilt extends deviceBase {
796
796
  }
797
797
  async getCurrentPosttionDirection(direction, slidePosition) {
798
798
  const [homekitPosition, homekitTiltAngle] = this.mapDeviceValuesToHomekitValues(Number(slidePosition), String(direction));
799
- await this.debugLog(`Slide Position: ${slidePosition}`);
800
- await this.debugLog(`Homekit Position: ${homekitPosition}`);
799
+ this.debugLog(`Slide Position: ${slidePosition}`);
800
+ this.debugLog(`Homekit Position: ${homekitPosition}`);
801
801
  this.WindowCovering.CurrentPosition = homekitPosition;
802
802
  await this.setMinMax();
803
- await this.debugLog(`CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
803
+ this.debugLog(`CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
804
804
  if (homekitTiltAngle) {
805
805
  this.WindowCovering.CurrentHorizontalTiltAngle = homekitTiltAngle;
806
- await this.debugLog(`CurrentHorizontalTiltAngle: ${this.WindowCovering.CurrentHorizontalTiltAngle}`);
806
+ this.debugLog(`CurrentHorizontalTiltAngle: ${this.WindowCovering.CurrentHorizontalTiltAngle}`);
807
807
  }
808
808
  if (this.setNewTarget) {
809
809
  this.blindTiltMoving = true;
810
- await this.infoLog('Checking Status ...');
810
+ this.infoLog('Checking Status ...');
811
811
  await this.setMinMax();
812
812
  if (this.WindowCovering.TargetPosition > this.WindowCovering.CurrentPosition
813
813
  || (homekitTiltAngle && this.WindowCovering.TargetHorizontalTiltAngle !== this.WindowCovering.CurrentHorizontalTiltAngle)) {
814
- await this.debugLog(`Closing, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
814
+ this.debugLog(`Closing, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
815
815
  this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.INCREASING;
816
816
  this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.PositionState).updateValue(this.WindowCovering.PositionState);
817
- await this.debugLog(`Increasing, PositionState: ${this.WindowCovering.PositionState}`);
817
+ this.debugLog(`Increasing, PositionState: ${this.WindowCovering.PositionState}`);
818
818
  }
819
819
  else if (this.WindowCovering.TargetPosition < this.WindowCovering.CurrentPosition) {
820
- await this.debugLog(`Opening, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
820
+ this.debugLog(`Opening, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
821
821
  this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.DECREASING;
822
822
  this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.PositionState).updateValue(this.WindowCovering.PositionState);
823
- await this.debugLog(`Decreasing, PositionState: ${this.WindowCovering.PositionState}`);
823
+ this.debugLog(`Decreasing, PositionState: ${this.WindowCovering.PositionState}`);
824
824
  }
825
825
  else {
826
- await this.debugLog(`Standby because reached position, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
826
+ this.debugLog(`Standby because reached position, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
827
827
  this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.STOPPED;
828
828
  this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.PositionState).updateValue(this.WindowCovering.PositionState);
829
- await this.debugLog(`Stopped, PositionState: ${this.WindowCovering.PositionState}`);
829
+ this.debugLog(`Stopped, PositionState: ${this.WindowCovering.PositionState}`);
830
830
  }
831
831
  }
832
832
  else {
833
833
  this.blindTiltMoving = false;
834
- await this.debugLog(`Standby because device not moving, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
834
+ this.debugLog(`Standby because device not moving, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
835
835
  this.WindowCovering.TargetPosition = this.WindowCovering.CurrentPosition;
836
836
  if (homekitTiltAngle) {
837
837
  this.WindowCovering.TargetHorizontalTiltAngle = this.WindowCovering.CurrentHorizontalTiltAngle;
838
838
  }
839
839
  this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.STOPPED;
840
- await this.debugLog(`Stopped, PositionState: ${this.WindowCovering.PositionState}`);
840
+ this.debugLog(`Stopped, PositionState: ${this.WindowCovering.PositionState}`);
841
841
  }
842
- await this.debugLog(`CurrentPosition: ${this.WindowCovering.CurrentPosition}, TargetPosition: ${this.WindowCovering.TargetPosition}, PositionState: ${this.WindowCovering.PositionState}`);
842
+ this.debugLog(`CurrentPosition: ${this.WindowCovering.CurrentPosition}, TargetPosition: ${this.WindowCovering.TargetPosition}, PositionState: ${this.WindowCovering.PositionState}`);
843
843
  }
844
844
  /**
845
845
  * Maps device values to homekit values