@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
@@ -186,7 +186,7 @@ export class Bot extends deviceBase {
186
186
  }
187
187
  catch (e) {
188
188
  await this.apiError(e);
189
- await this.errorLog(`failed pushChanges with ${device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
189
+ this.errorLog(`failed pushChanges with ${device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
190
190
  }
191
191
  this.botUpdateInProgress = false;
192
192
  });
@@ -195,40 +195,40 @@ export class Bot extends deviceBase {
195
195
  * Parse the device status from the SwitchBotBLE API
196
196
  */
197
197
  async BLEparseStatus() {
198
- await this.debugLog('BLEparseStatus');
199
- await this.debugLog(`(power, battery, deviceMode) = BLE:(${this.serviceData.state}, ${this.serviceData.battery}, ${this.serviceData.mode}), current:(${this.accessory.context.On}, ${this.Battery.BatteryLevel}, ${this.botMode})`);
198
+ this.debugLog('BLEparseStatus');
199
+ this.debugLog(`(power, battery, deviceMode) = BLE:(${this.serviceData.state}, ${this.serviceData.battery}, ${this.serviceData.mode}), current:(${this.accessory.context.On}, ${this.Battery.BatteryLevel}, ${this.botMode})`);
200
200
  // BLEmode (true if Switch Mode) | (false if Press Mode)
201
201
  this.On = this.serviceData.mode ? this.serviceData.state : false;
202
202
  const mode = this.serviceData.mode ? 'Switch' : 'Press';
203
- await this.debugLog(`${mode} Mode, On: ${this.On}`);
203
+ this.debugLog(`${mode} Mode, On: ${this.On}`);
204
204
  this.accessory.context.On = this.On;
205
205
  // BatteryLevel
206
206
  this.Battery.BatteryLevel = this.serviceData.battery;
207
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
207
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
208
208
  // StatusLowBattery
209
209
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
210
210
  ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
211
211
  : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
212
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
212
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
213
213
  }
214
214
  /**
215
215
  * Parse the device status from the SwitchBot OpenAPI
216
216
  */
217
217
  async openAPIparseStatus() {
218
- await this.debugLog('openAPIparseStatus');
219
- await this.debugLog(`(power, battery, deviceMode) = API:(${this.deviceStatus.power}, ${this.deviceStatus.battery}, ${this.botMode}), current:(${this.accessory.context.On}, ${this.Battery.BatteryLevel}, ${this.botMode})`);
218
+ this.debugLog('openAPIparseStatus');
219
+ this.debugLog(`(power, battery, deviceMode) = API:(${this.deviceStatus.power}, ${this.deviceStatus.battery}, ${this.botMode}), current:(${this.accessory.context.On}, ${this.Battery.BatteryLevel}, ${this.botMode})`);
220
220
  // On
221
221
  this.On = this.botMode === 'press' ? false : this.deviceStatus.power === 'on';
222
- await this.debugLog(`On: ${this.On}`);
222
+ this.debugLog(`On: ${this.On}`);
223
223
  this.accessory.context.On = this.On;
224
224
  // Battery Level
225
225
  this.Battery.BatteryLevel = this.deviceStatus.battery;
226
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
226
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
227
227
  // StatusLowBattery
228
228
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
229
229
  ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
230
230
  : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
231
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
231
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
232
232
  // Firmware Version
233
233
  if (this.deviceStatus.version) {
234
234
  const version = this.deviceStatus.version.toString();
@@ -241,33 +241,33 @@ export class Bot extends deviceBase {
241
241
  .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
242
242
  .updateValue(deviceVersion);
243
243
  this.accessory.context.version = deviceVersion;
244
- await this.debugLog(`version: ${deviceVersion}`);
244
+ this.debugLog(`version: ${deviceVersion}`);
245
245
  }
246
246
  }
247
247
  async parseStatusWebhook() {
248
- await this.debugLog('parseStatusWebhook');
249
- await this.debugLog(`(power, battery, deviceMode) = Webhook:(${this.webhookContext.power}, ${this.webhookContext.battery}, ${this.webhookContext.deviceMode}), current:(${this.On}, ${this.Battery.BatteryLevel}, ${this.botMode})`);
248
+ this.debugLog('parseStatusWebhook');
249
+ this.debugLog(`(power, battery, deviceMode) = Webhook:(${this.webhookContext.power}, ${this.webhookContext.battery}, ${this.webhookContext.deviceMode}), current:(${this.On}, ${this.Battery.BatteryLevel}, ${this.botMode})`);
250
250
  // On
251
251
  this.On = this.webhookContext.power === 'on';
252
- await this.debugLog(`On: ${this.On}`);
252
+ this.debugLog(`On: ${this.On}`);
253
253
  // BatteryLevel
254
254
  this.Battery.BatteryLevel = this.webhookContext.battery;
255
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
255
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
256
256
  // StatusLowBattery
257
257
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
258
258
  ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
259
259
  : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
260
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
260
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
261
261
  // Mode
262
262
  this.botMode = this.webhookContext.deviceMode;
263
- await this.debugLog(`Mode: ${this.botMode}`);
263
+ this.debugLog(`Mode: ${this.botMode}`);
264
264
  }
265
265
  /**
266
266
  * Asks the SwitchBot API for the latest device information
267
267
  */
268
268
  async refreshStatus() {
269
269
  if (!this.device.enableCloudService && this.OpenAPI) {
270
- await this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`);
270
+ this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`);
271
271
  }
272
272
  else if (this.BLE) {
273
273
  await this.BLERefreshStatus();
@@ -277,11 +277,11 @@ export class Bot extends deviceBase {
277
277
  }
278
278
  else {
279
279
  await this.offlineOff();
280
- await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`);
280
+ this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`);
281
281
  }
282
282
  }
283
283
  async BLERefreshStatus() {
284
- await this.debugLog('BLERefreshStatus');
284
+ this.debugLog('BLERefreshStatus');
285
285
  const switchBotBLE = await this.switchbotBLE();
286
286
  if (switchBotBLE === undefined) {
287
287
  await this.BLERefreshConnection(switchBotBLE);
@@ -298,79 +298,79 @@ export class Bot extends deviceBase {
298
298
  await this.updateHomeKitCharacteristics();
299
299
  }
300
300
  else {
301
- await this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`);
301
+ this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`);
302
302
  await this.BLERefreshConnection(switchBotBLE);
303
303
  }
304
304
  })();
305
305
  }
306
306
  }
307
307
  async registerPlatformBLE() {
308
- await this.debugLog('registerPlatformBLE');
308
+ this.debugLog('registerPlatformBLE');
309
309
  if (this.config.options?.BLE) {
310
- await this.debugLog('is listening to Platform BLE.');
310
+ this.debugLog('is listening to Platform BLE.');
311
311
  try {
312
312
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId);
313
313
  this.device.bleMac = formattedDeviceId;
314
- await this.debugLog(`bleMac: ${this.device.bleMac}`);
314
+ this.debugLog(`bleMac: ${this.device.bleMac}`);
315
315
  this.platform.bleEventHandler[this.device.bleMac] = async (context) => {
316
316
  try {
317
- await this.debugLog(`received BLE: ${JSON.stringify(context)}`);
317
+ this.debugLog(`received BLE: ${JSON.stringify(context)}`);
318
318
  this.serviceData = context;
319
319
  await this.BLEparseStatus();
320
320
  await this.updateHomeKitCharacteristics();
321
321
  }
322
322
  catch (e) {
323
- await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`);
323
+ this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`);
324
324
  }
325
325
  };
326
326
  }
327
327
  catch (error) {
328
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`);
328
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`);
329
329
  }
330
330
  }
331
331
  else {
332
- await this.debugLog('is not listening to Platform BLE');
332
+ this.debugLog('is not listening to Platform BLE');
333
333
  }
334
334
  }
335
335
  async openAPIRefreshStatus() {
336
- await this.debugLog('openAPIRefreshStatus');
336
+ this.debugLog('openAPIRefreshStatus');
337
337
  try {
338
- const { body } = await this.deviceRefreshStatus();
339
- const deviceStatus = await body;
340
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
338
+ const response = await this.deviceRefreshStatus();
339
+ const deviceStatus = response.body;
340
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
341
341
  if (await this.successfulStatusCodes(deviceStatus)) {
342
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
342
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
343
343
  this.deviceStatus = deviceStatus.body;
344
344
  await this.openAPIparseStatus();
345
345
  await this.updateHomeKitCharacteristics();
346
346
  }
347
347
  else {
348
- await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
349
- await this.debugWarnLog(deviceStatus);
348
+ this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
349
+ this.debugWarnLog(deviceStatus);
350
350
  }
351
351
  }
352
352
  catch (e) {
353
353
  await this.apiError(e);
354
- await this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
354
+ this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
355
355
  }
356
356
  }
357
357
  async registerWebhook() {
358
358
  if (this.device.webhook) {
359
- await this.debugLog('is listening webhook.');
359
+ this.debugLog('is listening webhook.');
360
360
  this.platform.webhookEventHandler[this.device.deviceId] = async (context) => {
361
361
  try {
362
- await this.debugLog(`received Webhook: ${JSON.stringify(context)}`);
362
+ this.debugLog(`received Webhook: ${JSON.stringify(context)}`);
363
363
  this.webhookContext = context;
364
364
  await this.parseStatusWebhook();
365
365
  await this.updateHomeKitCharacteristics();
366
366
  }
367
367
  catch (e) {
368
- await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`);
368
+ this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`);
369
369
  }
370
370
  };
371
371
  }
372
372
  else {
373
- await this.debugLog('is not listening webhook.');
373
+ this.debugLog('is not listening webhook.');
374
374
  }
375
375
  }
376
376
  /**
@@ -382,7 +382,7 @@ export class Bot extends deviceBase {
382
382
  */
383
383
  async pushChanges() {
384
384
  if (!this.device.enableCloudService && this.OpenAPI) {
385
- await this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`);
385
+ this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`);
386
386
  }
387
387
  else if (this.BLE) {
388
388
  await this.BLEpushChanges();
@@ -392,7 +392,7 @@ export class Bot extends deviceBase {
392
392
  }
393
393
  else {
394
394
  await this.offlineOff();
395
- await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, pushChanges will not happen.`);
395
+ this.debugWarnLog(`Connection Type: ${this.device.connectionType}, pushChanges will not happen.`);
396
396
  }
397
397
  // Refresh the status from the API
398
398
  interval(15000)
@@ -403,26 +403,26 @@ export class Bot extends deviceBase {
403
403
  });
404
404
  }
405
405
  async BLEpushChanges() {
406
- await this.debugLog('BLEpushChanges');
406
+ this.debugLog('BLEpushChanges');
407
407
  if ((this.On !== this.accessory.context.On) || this.allowPush) {
408
- await this.debugLog(`BLEpushChanges On: ${this.On} OnCached: ${this.accessory.context.On}`);
408
+ this.debugLog(`BLEpushChanges On: ${this.On} OnCached: ${this.accessory.context.On}`);
409
409
  const switchBotBLE = this.platform.switchBotBLE;
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
  // if (switchBotBLE !== false) {
415
- await this.debugLog(`Bot Mode: ${this.botMode}`);
415
+ this.debugLog(`Bot Mode: ${this.botMode}`);
416
416
  if (this.botMode === 'press') {
417
417
  switchBotBLE
418
418
  .discover({ model: this.device.bleModel, quick: true, id: this.device.bleMac })
419
419
  .then(async (device_list) => {
420
420
  const deviceList = device_list;
421
- await this.infoLog(`On: ${this.On}`);
421
+ this.infoLog(`On: ${this.On}`);
422
422
  return await deviceList[0].press();
423
423
  })
424
424
  .then(async () => {
425
- await this.successLog(`On: ${this.On} sent over SwitchBot BLE, sent successfully`);
425
+ this.successLog(`On: ${this.On} sent over SwitchBot BLE, sent successfully`);
426
426
  await this.updateHomeKitCharacteristics();
427
427
  setTimeout(async () => {
428
428
  this.On = false;
@@ -432,7 +432,7 @@ export class Bot extends deviceBase {
432
432
  })
433
433
  .catch(async (e) => {
434
434
  await this.apiError(e);
435
- await this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
435
+ this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
436
436
  await this.BLEPushConnection();
437
437
  });
438
438
  }
@@ -444,7 +444,7 @@ export class Bot extends deviceBase {
444
444
  this.infoLog(`On: ${this.On}`);
445
445
  this.warnLog(`device_list: ${JSON.stringify(device_list)}`);
446
446
  return await this.retryBLE({
447
- max: await this.maxRetryBLE(),
447
+ max: this.maxRetryBLE(),
448
448
  fn: async () => {
449
449
  if (deviceList.length > 0) {
450
450
  if (this.On) {
@@ -461,41 +461,41 @@ export class Bot extends deviceBase {
461
461
  });
462
462
  })
463
463
  .then(async () => {
464
- await this.successLog(`On: ${this.On} sent over SwitchBot BLE, sent successfully`);
464
+ this.successLog(`On: ${this.On} sent over SwitchBot BLE, sent successfully`);
465
465
  await this.updateHomeKitCharacteristics();
466
466
  })
467
467
  .catch(async (e) => {
468
468
  await this.apiError(e);
469
- await this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
469
+ this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
470
470
  await this.BLEPushConnection();
471
471
  });
472
472
  }
473
473
  else {
474
- await this.errorLog(`Device Parameters not set for this Bot, please check the device configuration. Bot Mode: ${this.botMode}`);
474
+ this.errorLog(`Device Parameters not set for this Bot, please check the device configuration. Bot Mode: ${this.botMode}`);
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(`No Changes (BLEpushChanges), On: ${this.On} OnCached: ${this.accessory.context.On}`);
482
+ this.debugLog(`No Changes (BLEpushChanges), On: ${this.On} OnCached: ${this.accessory.context.On}`);
483
483
  }
484
484
  }
485
485
  async openAPIpushChanges() {
486
- await this.debugLog('openAPIpushChanges');
486
+ this.debugLog('openAPIpushChanges');
487
487
  if (this.multiPressCount > 0) {
488
- await this.debugLog(`${this.multiPressCount} request(s) queued.`);
488
+ this.debugLog(`${this.multiPressCount} request(s) queued.`);
489
489
  }
490
490
  if ((this.On !== this.accessory.context.On) || this.allowPush || this.multiPressCount > 0) {
491
491
  let command = '';
492
492
  if (this.botMode === 'switch') {
493
493
  command = this.On ? 'turnOn' : 'turnOff';
494
- await this.debugLog(`Switch Mode, Command: ${command}`);
494
+ this.debugLog(`Switch Mode, Command: ${command}`);
495
495
  }
496
496
  else if (this.botMode === 'press' || this.botMode === 'multipress') {
497
497
  command = 'press';
498
- await this.debugLog('Press Mode');
498
+ this.debugLog('Press Mode');
499
499
  this.On = false;
500
500
  }
501
501
  else {
@@ -506,13 +506,13 @@ export class Bot extends deviceBase {
506
506
  parameter: 'default',
507
507
  commandType: 'command',
508
508
  };
509
- await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
509
+ this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
510
510
  try {
511
- const { body } = await this.pushChangeRequest(bodyChange);
512
- const deviceStatus = await body;
513
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
511
+ const response = await this.pushChangeRequest(bodyChange);
512
+ const deviceStatus = response.body;
513
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
514
514
  if (await this.successfulStatusCodes(deviceStatus)) {
515
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
515
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
516
516
  await this.updateHomeKitCharacteristics();
517
517
  }
518
518
  else {
@@ -521,7 +521,7 @@ export class Bot extends deviceBase {
521
521
  if (this.device.mode === 'multipress') {
522
522
  this.multiPressCount--;
523
523
  if (this.multiPressCount > 0) {
524
- await this.debugLog(`multiPressCount: ${this.multiPressCount}`);
524
+ this.debugLog(`multiPressCount: ${this.multiPressCount}`);
525
525
  this.On = true;
526
526
  await this.openAPIpushChanges();
527
527
  }
@@ -529,11 +529,11 @@ export class Bot extends deviceBase {
529
529
  }
530
530
  catch (e) {
531
531
  await this.apiError(e);
532
- await this.errorLog(`failed openAPIpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
532
+ this.errorLog(`failed openAPIpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
533
533
  }
534
534
  }
535
535
  else {
536
- await this.debugLog(`No Changes (openAPIpushChanges), On: ${this.On} OnCached: ${this.accessory.context.On}`);
536
+ this.debugLog(`No Changes (openAPIpushChanges), On: ${this.On} OnCached: ${this.accessory.context.On}`);
537
537
  }
538
538
  }
539
539
  /**
@@ -567,29 +567,29 @@ export class Bot extends deviceBase {
567
567
  * Updates the status for each of the HomeKit Characteristics
568
568
  */
569
569
  async updateHomeKitCharacteristics() {
570
- await this.debugLog('updateHomeKitCharacteristics');
570
+ this.debugLog('updateHomeKitCharacteristics');
571
571
  // BatteryLevel
572
572
  if (this.Battery.BatteryLevel === undefined) {
573
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
573
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
574
574
  }
575
575
  else {
576
576
  this.accessory.context.BatteryLevel = this.Battery.BatteryLevel;
577
577
  this.Battery.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, this.Battery.BatteryLevel);
578
- await this.debugLog(`updateCharacteristic BatteryLevel: ${this.Battery.BatteryLevel}`);
578
+ this.debugLog(`updateCharacteristic BatteryLevel: ${this.Battery.BatteryLevel}`);
579
579
  }
580
580
  // StatusLowBattery
581
581
  if (this.Battery.StatusLowBattery === undefined) {
582
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
582
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
583
583
  }
584
584
  else {
585
585
  this.accessory.context.StatusLowBattery = this.Battery.StatusLowBattery;
586
586
  this.Battery.Service.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, this.Battery.StatusLowBattery);
587
- await this.debugLog(`updateCharacteristic StatusLowBattery: ${this.Battery.StatusLowBattery}`);
587
+ this.debugLog(`updateCharacteristic StatusLowBattery: ${this.Battery.StatusLowBattery}`);
588
588
  }
589
589
  // State
590
590
  const updateCharacteristic = async (service, characteristic, value, logMessage) => {
591
591
  service.updateCharacteristic(characteristic, value);
592
- await this.debugLog(logMessage);
592
+ this.debugLog(logMessage);
593
593
  };
594
594
  const stateActions = {
595
595
  switch: async () => this.Switch && await updateCharacteristic(this.Switch.Service, this.hap.Characteristic.On, this.On, `updateCharacteristic On: ${this.On}`),
@@ -642,7 +642,7 @@ export class Bot extends deviceBase {
642
642
  }
643
643
  },
644
644
  outlet: async () => this.Outlet && await updateCharacteristic(this.Outlet.Service, this.hap.Characteristic.On, this.On, `updateCharacteristic On: ${this.On}`),
645
- default: async () => await this.errorLog(`botDeviceType: ${this.botDeviceType}, On: ${this.On}`),
645
+ default: async () => this.errorLog(`botDeviceType: ${this.botDeviceType}, On: ${this.On}`),
646
646
  };
647
647
  const action = stateActions[this.botDeviceType] || stateActions.default;
648
648
  await action();
@@ -655,7 +655,7 @@ export class Bot extends deviceBase {
655
655
  Service: accessory.getService(this.hap.Service[serviceType]),
656
656
  };
657
657
  accessory.context[contextKey] = this[contextKey];
658
- await this.debugWarnLog(`Removing any leftover ${contextKey} Service`);
658
+ this.debugWarnLog(`Removing any leftover ${contextKey} Service`);
659
659
  accessory.removeService(this[contextKey].Service);
660
660
  }
661
661
  async removeOutletService(accessory) {
@@ -692,7 +692,7 @@ export class Bot extends deviceBase {
692
692
  // Bot Device Type
693
693
  this.botDeviceType = device.type ?? 'Outlet';
694
694
  const botDeviceType = device.type ? 'Device Config' : 'Default';
695
- await this.debugWarnLog(`Use ${botDeviceType} Device Type: ${this.botDeviceType}`);
695
+ this.debugWarnLog(`Use ${botDeviceType} Device Type: ${this.botDeviceType}`);
696
696
  // Bot Mode
697
697
  this.botMode = device.mode ?? 'switch';
698
698
  if (!device.mode) {
@@ -709,40 +709,40 @@ export class Bot extends deviceBase {
709
709
  const botModeLog = device.mode
710
710
  ? `Using Bot Mode: ${this.botMode}`
711
711
  : `No Bot Mode Set, Using default Bot Mode: ${this.botMode}`;
712
- await this.debugWarnLog(botModeLog);
712
+ this.debugWarnLog(botModeLog);
713
713
  this.accessory.context.botMode = this.botMode;
714
714
  // Bot Double Press
715
715
  this.doublePress = device.doublePress ?? 1;
716
716
  const doublePress = device.doublePress
717
717
  ? `Using Double Press: ${this.doublePress}`
718
718
  : `No Double Press Set, Using default Double Press: ${this.doublePress}`;
719
- await this.debugWarnLog(doublePress);
719
+ this.debugWarnLog(doublePress);
720
720
  // Bot Press PushRate
721
721
  this.pushRatePress = device.pushRatePress ?? 15;
722
722
  const pushRatePress = device.pushRatePress
723
723
  ? `Using Bot Push Rate Press: ${this.pushRatePress}`
724
724
  : `No Push Rate Press Set, Using default Push Rate Press: ${this.pushRatePress}`;
725
- await this.debugWarnLog(pushRatePress);
725
+ this.debugWarnLog(pushRatePress);
726
726
  // Bot Allow Push
727
727
  this.allowPush = device.allowPush ?? false;
728
728
  const allowPush = device.allowPush
729
729
  ? `Using Allow Push: ${this.allowPush}`
730
730
  : `No Allow Push Set, Using default Allow Push: ${this.allowPush}`;
731
- await this.debugWarnLog(allowPush);
731
+ this.debugWarnLog(allowPush);
732
732
  // Bot Multi Press Count
733
733
  this.multiPressCount = 0;
734
- await this.debugWarnLog(`Multi Press Count: ${this.multiPressCount}`);
734
+ this.debugWarnLog(`Multi Press Count: ${this.multiPressCount}`);
735
735
  }
736
736
  async BLEPushConnection() {
737
737
  if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
738
- await this.warnLog('Using OpenAPI Connection to Push Changes');
738
+ this.warnLog('Using OpenAPI Connection to Push Changes');
739
739
  await this.openAPIpushChanges();
740
740
  }
741
741
  }
742
742
  async BLERefreshConnection(switchbot) {
743
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
743
+ this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
744
744
  if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
745
- await this.warnLog('Using OpenAPI Connection to Refresh Status');
745
+ this.warnLog('Using OpenAPI Connection to Refresh Status');
746
746
  await this.openAPIRefreshStatus();
747
747
  }
748
748
  }