@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/src/device/fan.ts CHANGED
@@ -186,28 +186,28 @@ export class Fan extends deviceBase {
186
186
  await this.pushChanges()
187
187
  } catch (e: any) {
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.fanUpdateInProgress = false
192
192
  })
193
193
  }
194
194
 
195
195
  async BLEparseStatus(): Promise<void> {
196
- await this.debugLog('BLEparseStatus')
197
- await this.debugLog(`(powerState, fanSpeed) = BLE:(${this.serviceData.state}, ${this.serviceData.fanSpeed}), current:(${this.Fan.Active}, ${this.Fan.RotationSpeed})`)
196
+ this.debugLog('BLEparseStatus')
197
+ this.debugLog(`(powerState, fanSpeed) = BLE:(${this.serviceData.state}, ${this.serviceData.fanSpeed}), current:(${this.Fan.Active}, ${this.Fan.RotationSpeed})`)
198
198
 
199
199
  // Active
200
200
  this.Fan.Active = this.serviceData.state === 'on' ? this.hap.Characteristic.Active.ACTIVE : this.hap.Characteristic.Active.INACTIVE
201
- await this.debugLog(`Active: ${this.Fan.Active}`)
201
+ this.debugLog(`Active: ${this.Fan.Active}`)
202
202
 
203
203
  // RotationSpeed
204
204
  this.Fan.RotationSpeed = this.serviceData.fanSpeed // ?? 0
205
- await this.debugLog(`RotationSpeed: ${this.Fan.RotationSpeed}`)
205
+ this.debugLog(`RotationSpeed: ${this.Fan.RotationSpeed}`)
206
206
  }
207
207
 
208
208
  async openAPIparseStatus() {
209
- await this.debugLog('openAPIparseStatus')
210
- await this.debugLog(`(version, battery, powerState, oscillation, chargingStatus, fanSpeed) = OpenAPI:(${this.deviceStatus.version}, ${this.deviceStatus.battery}, ${this.deviceStatus.power}, ${this.deviceStatus.oscillation}, ${this.deviceStatus.chargingStatus}, ${this.deviceStatus.fanSpeed}), current:(${this.accessory.context.version}, ${this.Battery.BatteryLevel}, ${this.Fan.Active}, ${this.Fan.SwingMode}, ${this.Battery.ChargingState}, ${this.Fan.RotationSpeed})`)
209
+ this.debugLog('openAPIparseStatus')
210
+ this.debugLog(`(version, battery, powerState, oscillation, chargingStatus, fanSpeed) = OpenAPI:(${this.deviceStatus.version}, ${this.deviceStatus.battery}, ${this.deviceStatus.power}, ${this.deviceStatus.oscillation}, ${this.deviceStatus.chargingStatus}, ${this.deviceStatus.fanSpeed}), current:(${this.accessory.context.version}, ${this.Battery.BatteryLevel}, ${this.Fan.Active}, ${this.Fan.SwingMode}, ${this.Battery.ChargingState}, ${this.Fan.RotationSpeed})`)
211
211
 
212
212
  // Active
213
213
  this.Fan.Active = this.deviceStatus.power === 'on' ? this.hap.Characteristic.Active.ACTIVE : this.hap.Characteristic.Active.INACTIVE
@@ -217,11 +217,11 @@ export class Fan extends deviceBase {
217
217
  this.Fan.SwingMode = this.deviceStatus.oscillation === 'on'
218
218
  ? this.hap.Characteristic.SwingMode.SWING_ENABLED
219
219
  : this.hap.Characteristic.SwingMode.SWING_DISABLED
220
- await this.debugLog(`SwingMode: ${this.Fan.SwingMode}`)
220
+ this.debugLog(`SwingMode: ${this.Fan.SwingMode}`)
221
221
 
222
222
  // RotationSpeed
223
223
  this.Fan.RotationSpeed = this.deviceStatus.fanSpeed ?? 0
224
- await this.debugLog(`RotationSpeed: ${this.Fan.RotationSpeed}`)
224
+ this.debugLog(`RotationSpeed: ${this.Fan.RotationSpeed}`)
225
225
 
226
226
  // ChargingState
227
227
  this.Battery.ChargingState = this.deviceStatus.chargingStatus === 'charging'
@@ -230,18 +230,18 @@ export class Fan extends deviceBase {
230
230
 
231
231
  // BatteryLevel
232
232
  this.Battery.BatteryLevel = this.deviceStatus.battery
233
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
233
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
234
234
 
235
235
  // StatusLowBattery
236
236
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
237
237
  ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
238
238
  : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
239
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
239
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
240
240
 
241
241
  // Firmware Version
242
242
  if (this.deviceStatus.version) {
243
243
  const version = this.deviceStatus.version.toString()
244
- await this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`)
244
+ this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`)
245
245
  const deviceVersion = version.replace(/^V|-.*$/g, '') ?? '0.0.0'
246
246
  this.accessory
247
247
  .getService(this.hap.Service.AccessoryInformation)!
@@ -250,43 +250,43 @@ export class Fan extends deviceBase {
250
250
  .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
251
251
  .updateValue(deviceVersion)
252
252
  this.accessory.context.version = deviceVersion
253
- await this.debugSuccessLog(`version: ${this.accessory.context.version}`)
253
+ this.debugSuccessLog(`version: ${this.accessory.context.version}`)
254
254
  }
255
255
  }
256
256
 
257
257
  async parseStatusWebhook(): Promise<void> {
258
- await this.debugLog('parseStatusWebhook')
259
- await this.debugLog(`(version, battery, powerState, oscillation, chargingStatus, fanSpeed) = Webhook:(${this.webhookContext.version}, ${this.webhookContext.battery}, ${this.webhookContext.powerState}, ${this.webhookContext.oscillation}, ${this.webhookContext.chargingStatus}, ${this.webhookContext.fanSpeed}), current:(${this.accessory.context.version}, ${this.Battery.BatteryLevel}, ${this.Fan.Active}, ${this.Fan.SwingMode}, ${this.Battery.ChargingState}, ${this.Fan.RotationSpeed})`)
258
+ this.debugLog('parseStatusWebhook')
259
+ this.debugLog(`(version, battery, powerState, oscillation, chargingStatus, fanSpeed) = Webhook:(${this.webhookContext.version}, ${this.webhookContext.battery}, ${this.webhookContext.powerState}, ${this.webhookContext.oscillation}, ${this.webhookContext.chargingStatus}, ${this.webhookContext.fanSpeed}), current:(${this.accessory.context.version}, ${this.Battery.BatteryLevel}, ${this.Fan.Active}, ${this.Fan.SwingMode}, ${this.Battery.ChargingState}, ${this.Fan.RotationSpeed})`)
260
260
 
261
261
  // Active
262
262
  this.Fan.Active = this.webhookContext.powerState === 'ON' ? this.hap.Characteristic.Active.ACTIVE : this.hap.Characteristic.Active.INACTIVE
263
- await this.debugLog(`Active: ${this.Fan.Active}`)
263
+ this.debugLog(`Active: ${this.Fan.Active}`)
264
264
 
265
265
  // SwingMode
266
266
  this.Fan.SwingMode = this.webhookContext.oscillation === 'on'
267
267
  ? this.hap.Characteristic.SwingMode.SWING_ENABLED
268
268
  : this.hap.Characteristic.SwingMode.SWING_DISABLED
269
- await this.debugLog(`SwingMode: ${this.Fan.SwingMode}`)
269
+ this.debugLog(`SwingMode: ${this.Fan.SwingMode}`)
270
270
 
271
271
  // RotationSpeed
272
272
  this.Fan.RotationSpeed = this.webhookContext.fanSpeed // ?? 0
273
- await this.debugLog(`RotationSpeed: ${this.Fan.RotationSpeed}`)
273
+ this.debugLog(`RotationSpeed: ${this.Fan.RotationSpeed}`)
274
274
 
275
275
  // BatteryLevel
276
276
  this.Battery.BatteryLevel = this.webhookContext.battery
277
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
277
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
278
278
 
279
279
  // StatusLowBattery
280
280
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
281
281
  ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
282
282
  : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
283
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
283
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
284
284
 
285
285
  // ChargingState
286
286
  this.Battery.ChargingState = this.webhookContext.chargingStatus === 'charging'
287
287
  ? this.hap.Characteristic.ChargingState.CHARGING
288
288
  : this.hap.Characteristic.ChargingState.NOT_CHARGING
289
- await this.debugLog(`ChargingState: ${this.Battery.ChargingState}`)
289
+ this.debugLog(`ChargingState: ${this.Battery.ChargingState}`)
290
290
 
291
291
  // FirmwareVersion
292
292
  if (this.webhookContext.version) {
@@ -298,7 +298,7 @@ export class Fan extends deviceBase {
298
298
  .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
299
299
  .updateValue(deviceVersion)
300
300
  this.accessory.context.version = deviceVersion
301
- await this.debugSuccessLog(`version: ${this.accessory.context.version}`)
301
+ this.debugSuccessLog(`version: ${this.accessory.context.version}`)
302
302
  }
303
303
  }
304
304
 
@@ -307,19 +307,19 @@ export class Fan extends deviceBase {
307
307
  */
308
308
  async refreshStatus(): Promise<void> {
309
309
  if (!this.device.enableCloudService && this.OpenAPI) {
310
- await this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
310
+ this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
311
311
  } else if (this.BLE) {
312
312
  await this.BLERefreshStatus()
313
313
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
314
314
  await this.openAPIRefreshStatus()
315
315
  } else {
316
316
  await this.offlineOff()
317
- await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`)
317
+ this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`)
318
318
  }
319
319
  }
320
320
 
321
321
  async BLERefreshStatus(): Promise<void> {
322
- await this.debugLog('BLERefreshStatus')
322
+ this.debugLog('BLERefreshStatus')
323
323
  const switchBotBLE = await this.switchbotBLE()
324
324
  if (switchBotBLE === undefined) {
325
325
  await this.BLERefreshConnection(switchBotBLE)
@@ -334,7 +334,7 @@ export class Fan extends deviceBase {
334
334
  await this.BLEparseStatus()
335
335
  await this.updateHomeKitCharacteristics()
336
336
  } else {
337
- await this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
337
+ this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
338
338
  await this.BLERefreshConnection(switchBotBLE)
339
339
  }
340
340
  })()
@@ -342,67 +342,67 @@ export class Fan extends deviceBase {
342
342
  }
343
343
 
344
344
  async registerPlatformBLE(): Promise<void> {
345
- await this.debugLog('registerPlatformBLE')
345
+ this.debugLog('registerPlatformBLE')
346
346
  if (this.config.options?.BLE) {
347
- await this.debugLog('is listening to Platform BLE.')
347
+ this.debugLog('is listening to Platform BLE.')
348
348
  try {
349
349
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId)
350
350
  this.device.bleMac = formattedDeviceId
351
- await this.debugLog(`bleMac: ${this.device.bleMac}`)
351
+ this.debugLog(`bleMac: ${this.device.bleMac}`)
352
352
  this.platform.bleEventHandler[this.device.bleMac] = async (context: batteryCirculatorFanServiceData) => {
353
353
  try {
354
- await this.debugLog(`received BLE: ${JSON.stringify(context)}`)
354
+ this.debugLog(`received BLE: ${JSON.stringify(context)}`)
355
355
  this.serviceData = context
356
356
  await this.BLEparseStatus()
357
357
  await this.updateHomeKitCharacteristics()
358
358
  } catch (e: any) {
359
- await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
359
+ this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
360
360
  }
361
361
  }
362
362
  } catch (error) {
363
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
363
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
364
364
  }
365
365
  } else {
366
- await this.debugLog('is not listening to Platform BLE')
366
+ this.debugLog('is not listening to Platform BLE')
367
367
  }
368
368
  }
369
369
 
370
370
  async openAPIRefreshStatus(): Promise<void> {
371
- await this.debugLog('openAPIRefreshStatus')
371
+ this.debugLog('openAPIRefreshStatus')
372
372
  try {
373
- const { body } = await this.deviceRefreshStatus()
374
- const deviceStatus: any = await body
375
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
373
+ const response = await this.deviceRefreshStatus()
374
+ const deviceStatus: any = response.body
375
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
376
376
  if (await this.successfulStatusCodes(deviceStatus)) {
377
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
377
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
378
378
  this.deviceStatus = deviceStatus.body
379
379
  await this.openAPIparseStatus()
380
380
  await this.updateHomeKitCharacteristics()
381
381
  } else {
382
- await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
383
- await this.debugWarnLog(deviceStatus)
382
+ this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
383
+ this.debugWarnLog(deviceStatus)
384
384
  }
385
385
  } catch (e: any) {
386
386
  await this.apiError(e)
387
- await this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
387
+ this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
388
388
  }
389
389
  }
390
390
 
391
391
  async registerWebhook() {
392
392
  if (this.device.webhook) {
393
- await this.debugLog('is listening webhook.')
393
+ this.debugLog('is listening webhook.')
394
394
  this.platform.webhookEventHandler[this.device.deviceId] = async (context: batteryCirculatorFanWebhookContext) => {
395
395
  try {
396
- await this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
396
+ this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
397
397
  this.webhookContext = context
398
398
  await this.parseStatusWebhook()
399
399
  await this.updateHomeKitCharacteristics()
400
400
  } catch (e: any) {
401
- await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
401
+ this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
402
402
  }
403
403
  }
404
404
  } else {
405
- await this.debugLog('is not listening webhook.')
405
+ this.debugLog('is not listening webhook.')
406
406
  }
407
407
  }
408
408
 
@@ -418,25 +418,25 @@ export class Fan extends deviceBase {
418
418
 
419
419
  async pushChanges(): Promise<void> {
420
420
  if (!this.device.enableCloudService && this.OpenAPI) {
421
- await this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`)
421
+ this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`)
422
422
  } else if (this.BLE) {
423
423
  await this.BLEpushChanges()
424
424
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
425
425
  await this.openAPIpushChanges()
426
426
  if (this.Fan.Active) {
427
- await this.debugLog(`Active: ${this.Fan.Active}`)
427
+ this.debugLog(`Active: ${this.Fan.Active}`)
428
428
  // Push RotationSpeed Update
429
- await this.debugLog(`RotationSpeed: ${this.Fan.RotationSpeed}`)
429
+ this.debugLog(`RotationSpeed: ${this.Fan.RotationSpeed}`)
430
430
  await this.pushRotationSpeedChanges()
431
431
  // Push SwingMode Update
432
- await this.debugLog(`SwingMode: ${this.Fan.SwingMode}`)
432
+ this.debugLog(`SwingMode: ${this.Fan.SwingMode}`)
433
433
  await this.pushSwingModeChanges()
434
434
  } else {
435
- await this.debugLog('BLE (RotationSpeed) & (SwingMode) changes will not happen, as the device is Off.')
435
+ this.debugLog('BLE (RotationSpeed) & (SwingMode) changes will not happen, as the device is Off.')
436
436
  }
437
437
  } else {
438
438
  await this.offlineOff()
439
- await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, pushChanges will not happen.`)
439
+ this.debugWarnLog(`Connection Type: ${this.device.connectionType}, pushChanges will not happen.`)
440
440
  }
441
441
  // Refresh the status from the API
442
442
  interval(15000)
@@ -448,14 +448,14 @@ export class Fan extends deviceBase {
448
448
  }
449
449
 
450
450
  async BLEpushChanges(): Promise<void> {
451
- await this.debugLog('BLEpushChanges')
451
+ this.debugLog('BLEpushChanges')
452
452
  if (this.Fan.Active !== this.accessory.context.Active) {
453
- await this.debugLog(`BLEpushChanges On: ${this.Fan.Active} OnCached: ${this.accessory.context.Active}`)
453
+ this.debugLog(`BLEpushChanges On: ${this.Fan.Active} OnCached: ${this.accessory.context.Active}`)
454
454
  const switchBotBLE = await this.platform.connectBLE(this.accessory, this.device)
455
455
  try {
456
456
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId)
457
457
  this.device.bleMac = formattedDeviceId
458
- await this.debugLog(`bleMac: ${this.device.bleMac}`)
458
+ this.debugLog(`bleMac: ${this.device.bleMac}`)
459
459
  if (switchBotBLE !== false) {
460
460
  switchBotBLE
461
461
  .discover({ model: this.device.bleModel, id: this.device.bleMac })
@@ -473,28 +473,28 @@ export class Fan extends deviceBase {
473
473
  })
474
474
  })
475
475
  .then(async () => {
476
- await this.successLog(`Active: ${this.Fan.Active} sent over SwitchBot BLE, sent successfully`)
476
+ this.successLog(`Active: ${this.Fan.Active} sent over SwitchBot BLE, sent successfully`)
477
477
  await this.updateHomeKitCharacteristics()
478
478
  })
479
479
  .catch(async (e: any) => {
480
480
  await this.apiError(e)
481
- await this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
481
+ this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
482
482
  await this.BLEPushConnection()
483
483
  })
484
484
  } else {
485
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`)
485
+ this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`)
486
486
  await this.BLEPushConnection()
487
487
  }
488
488
  } catch (error) {
489
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
489
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
490
490
  }
491
491
  } else {
492
- await this.debugLog(`No change (BLEpushChanges), Active: ${this.Fan.Active}, ActiveCached: ${this.accessory.context.Active}`)
492
+ this.debugLog(`No change (BLEpushChanges), Active: ${this.Fan.Active}, ActiveCached: ${this.accessory.context.Active}`)
493
493
  }
494
494
  }
495
495
 
496
496
  async openAPIpushChanges() {
497
- await this.debugLog('openAPIpushChanges')
497
+ this.debugLog('openAPIpushChanges')
498
498
  if (this.Fan.Active !== this.accessory.context.Active) {
499
499
  const command = this.Fan.Active ? 'turnOn' : 'turnOff'
500
500
  const bodyChange: bodyChange = {
@@ -502,56 +502,56 @@ export class Fan extends deviceBase {
502
502
  parameter: 'default',
503
503
  commandType: 'command',
504
504
  }
505
- await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
505
+ this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
506
506
  try {
507
- const { body } = await this.pushChangeRequest(bodyChange)
508
- const deviceStatus: any = await body
509
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
507
+ const response = await this.pushChangeRequest(bodyChange)
508
+ const deviceStatus: any = response.body
509
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
510
510
  if (await this.successfulStatusCodes(deviceStatus)) {
511
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
511
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
512
512
  await this.updateHomeKitCharacteristics()
513
513
  } else {
514
514
  await this.statusCode(deviceStatus.statusCode)
515
515
  }
516
516
  } catch (e: any) {
517
517
  await this.apiError(e)
518
- await this.errorLog(`failed openAPIpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
518
+ this.errorLog(`failed openAPIpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
519
519
  }
520
520
  } else {
521
- await this.debugLog(`No changes (openAPIpushChanges), Active: ${this.Fan.Active}, ActiveCached: ${this.accessory.context.Active}`)
521
+ this.debugLog(`No changes (openAPIpushChanges), Active: ${this.Fan.Active}, ActiveCached: ${this.accessory.context.Active}`)
522
522
  }
523
523
  }
524
524
 
525
525
  async pushRotationSpeedChanges(): Promise<void> {
526
- await this.debugLog('pushRotationSpeedChanges')
526
+ this.debugLog('pushRotationSpeedChanges')
527
527
  if (this.Fan.SwingMode !== this.accessory.context.SwingMode) {
528
528
  const bodyChange: bodyChange = {
529
529
  command: 'setWindSpeed',
530
530
  parameter: `${this.Fan.RotationSpeed}`,
531
531
  commandType: 'command',
532
532
  }
533
- await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
533
+ this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
534
534
  try {
535
- const { body } = await this.pushChangeRequest(bodyChange)
536
- const deviceStatus: any = await body
537
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
535
+ const response = await this.pushChangeRequest(bodyChange)
536
+ const deviceStatus: any = response.body
537
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
538
538
  if (await this.successfulStatusCodes(deviceStatus)) {
539
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
539
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
540
540
  await this.updateHomeKitCharacteristics()
541
541
  } else {
542
542
  await this.statusCode(deviceStatus.statusCode)
543
543
  }
544
544
  } catch (e: any) {
545
545
  await this.apiError(e)
546
- await this.errorLog(`failed pushRotationSpeedChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
546
+ this.errorLog(`failed pushRotationSpeedChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
547
547
  }
548
548
  } else {
549
- await this.debugLog(`No changes (pushRotationSpeedChanges), RotationSpeed: ${this.Fan.RotationSpeed}, RotationSpeedCached: ${this.accessory.context.RotationSpeed}`)
549
+ this.debugLog(`No changes (pushRotationSpeedChanges), RotationSpeed: ${this.Fan.RotationSpeed}, RotationSpeedCached: ${this.accessory.context.RotationSpeed}`)
550
550
  }
551
551
  }
552
552
 
553
553
  async pushSwingModeChanges(): Promise<void> {
554
- await this.debugLog('pushSwingModeChanges')
554
+ this.debugLog('pushSwingModeChanges')
555
555
  if (this.Fan.SwingMode !== this.accessory.context.SwingMode) {
556
556
  const parameter = this.Fan.SwingMode === this.hap.Characteristic.SwingMode.SWING_ENABLED ? 'on' : 'off'
557
557
  const bodyChange: bodyChange = {
@@ -559,23 +559,23 @@ export class Fan extends deviceBase {
559
559
  parameter: `${parameter}`,
560
560
  commandType: 'command',
561
561
  }
562
- await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
562
+ this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
563
563
  try {
564
- const { body } = await this.pushChangeRequest(bodyChange)
565
- const deviceStatus: any = await body
566
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
564
+ const response = await this.pushChangeRequest(bodyChange)
565
+ const deviceStatus: any = response.body
566
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
567
567
  if (await this.successfulStatusCodes(deviceStatus)) {
568
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
568
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
569
569
  await this.updateHomeKitCharacteristics()
570
570
  } else {
571
571
  await this.statusCode(deviceStatus.statusCode)
572
572
  }
573
573
  } catch (e: any) {
574
574
  await this.apiError(e)
575
- await this.errorLog(`failed pushSwingModeChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
575
+ this.errorLog(`failed pushSwingModeChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
576
576
  }
577
577
  } else {
578
- await this.debugLog(`No changes (pushSwingModeChanges), SwingMode: ${this.Fan.SwingMode}, SwingModeCached: ${this.accessory.context.SwingMode}`)
578
+ this.debugLog(`No changes (pushSwingModeChanges), SwingMode: ${this.Fan.SwingMode}, SwingModeCached: ${this.accessory.context.SwingMode}`)
579
579
  }
580
580
  }
581
581
 
@@ -584,9 +584,9 @@ export class Fan extends deviceBase {
584
584
  */
585
585
  async ActiveSet(value: CharacteristicValue): Promise<void> {
586
586
  if (this.Fan.Active !== this.accessory.context.Active) {
587
- await this.infoLog(`Set Active: ${value}`)
587
+ this.infoLog(`Set Active: ${value}`)
588
588
  } else {
589
- await this.debugLog(`No Changes, Active: ${value}`)
589
+ this.debugLog(`No Changes, Active: ${value}`)
590
590
  }
591
591
 
592
592
  this.Fan.Active = value
@@ -598,9 +598,9 @@ export class Fan extends deviceBase {
598
598
  */
599
599
  async RotationSpeedSet(value: CharacteristicValue): Promise<void> {
600
600
  if (this.Fan.RotationSpeed !== this.accessory.context.RotationSpeed) {
601
- await this.infoLog(`Set RotationSpeed ${value}`)
601
+ this.infoLog(`Set RotationSpeed ${value}`)
602
602
  } else {
603
- await this.debugLog(`No Changes, RotationSpeed: ${value}`)
603
+ this.debugLog(`No Changes, RotationSpeed: ${value}`)
604
604
  }
605
605
 
606
606
  this.Fan.RotationSpeed = value
@@ -612,9 +612,9 @@ export class Fan extends deviceBase {
612
612
  */
613
613
  async SwingModeSet(value: CharacteristicValue): Promise<void> {
614
614
  if (this.Fan.SwingMode !== this.accessory.context.SwingMode) {
615
- await this.infoLog(`Set SwingMode ${value}`)
615
+ this.infoLog(`Set SwingMode ${value}`)
616
616
  } else {
617
- await this.debugLog(`No Changes, SwingMode: ${value}`)
617
+ this.debugLog(`No Changes, SwingMode: ${value}`)
618
618
  }
619
619
 
620
620
  this.Fan.SwingMode = value
@@ -626,9 +626,9 @@ export class Fan extends deviceBase {
626
626
  */
627
627
  async OnSet(value: CharacteristicValue): Promise<void> {
628
628
  if (this.LightBulb.On !== this.accessory.context.On) {
629
- await this.infoLog(`Set On: ${value}`)
629
+ this.infoLog(`Set On: ${value}`)
630
630
  } else {
631
- await this.debugLog(`No Changes, On: ${value}`)
631
+ this.debugLog(`No Changes, On: ${value}`)
632
632
  }
633
633
 
634
634
  this.LightBulb.On = value
@@ -640,7 +640,7 @@ export class Fan extends deviceBase {
640
640
  */
641
641
  async BrightnessSet(value: CharacteristicValue): Promise<void> {
642
642
  if (this.LightBulb.On && (this.LightBulb.Brightness !== this.accessory.context.Brightness)) {
643
- await this.infoLog(`Set Brightness: ${value}`)
643
+ this.infoLog(`Set Brightness: ${value}`)
644
644
  } else {
645
645
  if (this.LightBulb.On) {
646
646
  this.debugLog(`No Changes, Brightness: ${value}`)
@@ -674,15 +674,15 @@ export class Fan extends deviceBase {
674
674
 
675
675
  async BLEPushConnection() {
676
676
  if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
677
- await this.warnLog('Using OpenAPI Connection to Push Changes')
677
+ this.warnLog('Using OpenAPI Connection to Push Changes')
678
678
  await this.openAPIpushChanges()
679
679
  }
680
680
  }
681
681
 
682
682
  async BLERefreshConnection(switchbot: any): Promise<void> {
683
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`)
683
+ this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`)
684
684
  if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
685
- await this.warnLog('Using OpenAPI Connection to Refresh Status')
685
+ this.warnLog('Using OpenAPI Connection to Refresh Status')
686
686
  await this.openAPIRefreshStatus()
687
687
  }
688
688
  }