@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
@@ -177,24 +177,24 @@ export class Humidifier extends deviceBase {
177
177
  await this.pushChanges()
178
178
  } catch (e: any) {
179
179
  await this.apiError(e)
180
- await this.errorLog(`failed pushChanges with ${device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
180
+ this.errorLog(`failed pushChanges with ${device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
181
181
  }
182
182
  this.humidifierUpdateInProgress = false
183
183
  })
184
184
  }
185
185
 
186
186
  async BLEparseStatus(): Promise<void> {
187
- await this.debugLog('BLEparseStatus')
188
- await this.debugLog(`(onState, percentage, autoMode) = BLE:(${this.serviceData.onState}, ${this.serviceData.percentage}, ${this.serviceData.autoMode}), current:(${this.HumidifierDehumidifier.Active}, ${this.HumidifierDehumidifier.CurrentRelativeHumidity}, ${this.HumidifierDehumidifier.TargetHumidifierDehumidifierState}, ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold})`,
187
+ this.debugLog('BLEparseStatus')
188
+ this.debugLog(`(onState, percentage, autoMode) = BLE:(${this.serviceData.onState}, ${this.serviceData.percentage}, ${this.serviceData.autoMode}), current:(${this.HumidifierDehumidifier.Active}, ${this.HumidifierDehumidifier.CurrentRelativeHumidity}, ${this.HumidifierDehumidifier.TargetHumidifierDehumidifierState}, ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold})`,
189
189
  )
190
190
 
191
191
  // Active
192
192
  this.HumidifierDehumidifier.Active = this.serviceData.onState ? this.hap.Characteristic.Active.ACTIVE : this.hap.Characteristic.Active.INACTIVE
193
- await this.debugLog(`Active: ${this.HumidifierDehumidifier.Active}`)
193
+ this.debugLog(`Active: ${this.HumidifierDehumidifier.Active}`)
194
194
 
195
195
  // Current Relative Humidity
196
196
  this.HumidifierDehumidifier.CurrentRelativeHumidity = validHumidity(this.serviceData.humidity)
197
- await this.debugLog(`CurrentRelativeHumidity: ${this.HumidifierDehumidifier.CurrentRelativeHumidity}`)
197
+ this.debugLog(`CurrentRelativeHumidity: ${this.HumidifierDehumidifier.CurrentRelativeHumidity}`)
198
198
 
199
199
  // Target Humidifier Dehumidifier State
200
200
  switch (this.serviceData.autoMode) {
@@ -215,27 +215,27 @@ export class Humidifier extends deviceBase {
215
215
  this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState = this.hap.Characteristic.CurrentHumidifierDehumidifierState.HUMIDIFYING
216
216
  }
217
217
  }
218
- await this.debugLog(`TargetHumidifierDehumidifierState: ${this.HumidifierDehumidifier.TargetHumidifierDehumidifierState}, RelativeHumidityHumidifierThreshold: ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold}, CurrentHumidifierDehumidifierState: ${this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState}`)
218
+ this.debugLog(`TargetHumidifierDehumidifierState: ${this.HumidifierDehumidifier.TargetHumidifierDehumidifierState}, RelativeHumidityHumidifierThreshold: ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold}, CurrentHumidifierDehumidifierState: ${this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState}`)
219
219
  }
220
220
 
221
221
  async openAPIparseStatus(): Promise<void> {
222
- await this.debugLog('openAPIparseStatus')
223
- await this.debugLog(`(power, auto, temperature, lackWater, nebulizationEfficiency, version) = OpenAPI:(${this.deviceStatus.power}, ${this.deviceStatus.auto}, ${this.deviceStatus.temperature}, ${this.deviceStatus.lackWater}, ${this.deviceStatus.nebulizationEfficiency}, ${this.deviceStatus.version}), current:(${this.HumidifierDehumidifier.Active}, ${this.HumidifierDehumidifier.CurrentRelativeHumidity}, ${this.HumidifierDehumidifier.TargetHumidifierDehumidifierState}, ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold})`)
222
+ this.debugLog('openAPIparseStatus')
223
+ this.debugLog(`(power, auto, temperature, lackWater, nebulizationEfficiency, version) = OpenAPI:(${this.deviceStatus.power}, ${this.deviceStatus.auto}, ${this.deviceStatus.temperature}, ${this.deviceStatus.lackWater}, ${this.deviceStatus.nebulizationEfficiency}, ${this.deviceStatus.version}), current:(${this.HumidifierDehumidifier.Active}, ${this.HumidifierDehumidifier.CurrentRelativeHumidity}, ${this.HumidifierDehumidifier.TargetHumidifierDehumidifierState}, ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold})`)
224
224
 
225
225
  // Active
226
226
  this.HumidifierDehumidifier.Active = this.deviceStatus.power === 'on'
227
227
  ? this.hap.Characteristic.Active.ACTIVE
228
228
  : this.hap.Characteristic.Active.INACTIVE
229
- await this.debugLog(`Active: ${this.HumidifierDehumidifier.Active}`)
229
+ this.debugLog(`Active: ${this.HumidifierDehumidifier.Active}`)
230
230
 
231
231
  // Current Relative Humidity
232
232
  this.HumidifierDehumidifier.CurrentRelativeHumidity = validHumidity(this.deviceStatus.humidity)
233
- await this.debugLog(`CurrentRelativeHumidity: ${this.HumidifierDehumidifier.CurrentRelativeHumidity}`)
233
+ this.debugLog(`CurrentRelativeHumidity: ${this.HumidifierDehumidifier.CurrentRelativeHumidity}`)
234
234
 
235
235
  // Current Temperature
236
236
  if (!(this.device as humidifierConfig).hide_temperature && this.TemperatureSensor?.Service) {
237
237
  this.TemperatureSensor.CurrentTemperature = this.deviceStatus.temperature
238
- await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`)
238
+ this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`)
239
239
  }
240
240
  // Target Humidifier Dehumidifier State
241
241
  switch (this.deviceStatus.auto) {
@@ -258,7 +258,7 @@ export class Humidifier extends deviceBase {
258
258
  this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState = this.hap.Characteristic.CurrentHumidifierDehumidifierState.HUMIDIFYING
259
259
  }
260
260
  }
261
- await this.debugLog(`TargetHumidifierDehumidifierState: ${this.HumidifierDehumidifier.TargetHumidifierDehumidifierState}, RelativeHumidityHumidifierThreshold: ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold}, CurrentHumidifierDehumidifierState: ${this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState}`)
261
+ this.debugLog(`TargetHumidifierDehumidifierState: ${this.HumidifierDehumidifier.TargetHumidifierDehumidifierState}, RelativeHumidityHumidifierThreshold: ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold}, CurrentHumidifierDehumidifierState: ${this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState}`)
262
262
 
263
263
  // Water Level
264
264
  if (this.deviceStatus.lackWater) {
@@ -266,12 +266,12 @@ export class Humidifier extends deviceBase {
266
266
  } else {
267
267
  this.HumidifierDehumidifier.WaterLevel = 100
268
268
  }
269
- await this.debugLog(`WaterLevel: ${this.HumidifierDehumidifier.WaterLevel}`)
269
+ this.debugLog(`WaterLevel: ${this.HumidifierDehumidifier.WaterLevel}`)
270
270
 
271
271
  // Firmware Version
272
272
  if (this.deviceStatus.version) {
273
273
  const version = this.deviceStatus.version.toString()
274
- await this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`)
274
+ this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`)
275
275
  const deviceVersion = version.replace(/^V|-.*$/g, '') ?? '0.0.0'
276
276
  this.accessory
277
277
  .getService(this.hap.Service.AccessoryInformation)!
@@ -280,22 +280,22 @@ export class Humidifier extends deviceBase {
280
280
  .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
281
281
  .updateValue(deviceVersion)
282
282
  this.accessory.context.version = deviceVersion
283
- await this.debugSuccessLog(`version: ${this.accessory.context.version}`)
283
+ this.debugSuccessLog(`version: ${this.accessory.context.version}`)
284
284
  }
285
285
  }
286
286
 
287
287
  async parseStatusWebhook(): Promise<void> {
288
- await this.debugLog('parseStatusWebhook')
289
- await this.debugLog(`(temperature, humidity) = Webhook:(${convertUnits(this.webhookContext.temperature, this.webhookContext.scale, (this.device as humidifierConfig).convertUnitTo)}, ${this.webhookContext.humidity}), current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumidifierDehumidifier.CurrentRelativeHumidity})`)
288
+ this.debugLog('parseStatusWebhook')
289
+ this.debugLog(`(temperature, humidity) = Webhook:(${convertUnits(this.webhookContext.temperature, this.webhookContext.scale, (this.device as humidifierConfig).convertUnitTo)}, ${this.webhookContext.humidity}), current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumidifierDehumidifier.CurrentRelativeHumidity})`)
290
290
 
291
291
  // CurrentRelativeHumidity
292
292
  this.HumidifierDehumidifier.CurrentRelativeHumidity = validHumidity(this.webhookContext.humidity)
293
- await this.debugLog(`CurrentRelativeHumidity: ${this.HumidifierDehumidifier.CurrentRelativeHumidity}`)
293
+ this.debugLog(`CurrentRelativeHumidity: ${this.HumidifierDehumidifier.CurrentRelativeHumidity}`)
294
294
 
295
295
  // CurrentTemperature
296
296
  if (!(this.device as humidifierConfig).hide_temperature && this.TemperatureSensor?.Service) {
297
297
  this.TemperatureSensor.CurrentTemperature = convertUnits(this.webhookContext.temperature, this.webhookContext.scale, (this.device as humidifierConfig).convertUnitTo)
298
- await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`)
298
+ this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`)
299
299
  }
300
300
  }
301
301
 
@@ -304,19 +304,19 @@ export class Humidifier extends deviceBase {
304
304
  */
305
305
  async refreshStatus(): Promise<void> {
306
306
  if (!this.device.enableCloudService && this.OpenAPI) {
307
- await this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
307
+ this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
308
308
  } else if (this.BLE) {
309
309
  await this.BLERefreshStatus()
310
310
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
311
311
  await this.openAPIRefreshStatus()
312
312
  } else {
313
313
  await this.offlineOff()
314
- await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`)
314
+ this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`)
315
315
  }
316
316
  }
317
317
 
318
318
  async BLERefreshStatus(): Promise<void> {
319
- await this.debugLog('BLERefreshStatus')
319
+ this.debugLog('BLERefreshStatus')
320
320
  const switchBotBLE = await this.switchbotBLE()
321
321
  if (switchBotBLE === undefined) {
322
322
  await this.BLERefreshConnection(switchBotBLE)
@@ -331,7 +331,7 @@ export class Humidifier extends deviceBase {
331
331
  await this.BLEparseStatus()
332
332
  await this.updateHomeKitCharacteristics()
333
333
  } else {
334
- await this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
334
+ this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
335
335
  await this.BLERefreshConnection(switchBotBLE)
336
336
  }
337
337
  })()
@@ -339,63 +339,63 @@ export class Humidifier extends deviceBase {
339
339
  }
340
340
 
341
341
  async registerPlatformBLE(): Promise<void> {
342
- await this.debugLog('registerPlatformBLE')
342
+ this.debugLog('registerPlatformBLE')
343
343
  if (this.config.options?.BLE) {
344
- await this.debugLog('is listening to Platform BLE.')
344
+ this.debugLog('is listening to Platform BLE.')
345
345
  try {
346
346
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId)
347
347
  this.device.bleMac = formattedDeviceId
348
- await this.debugLog(`bleMac: ${this.device.bleMac}`)
348
+ this.debugLog(`bleMac: ${this.device.bleMac}`)
349
349
  this.platform.bleEventHandler[this.device.bleMac] = async (context: humidifierServiceData) => {
350
350
  try {
351
- await this.debugLog(`received BLE: ${JSON.stringify(context)}`)
351
+ this.debugLog(`received BLE: ${JSON.stringify(context)}`)
352
352
  this.serviceData = context
353
353
  await this.BLEparseStatus()
354
354
  await this.updateHomeKitCharacteristics()
355
355
  } catch (e: any) {
356
- await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
356
+ this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
357
357
  }
358
358
  }
359
359
  } catch (error) {
360
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
360
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
361
361
  }
362
362
  } else {
363
- await this.debugLog('is not listening to Platform BLE')
363
+ this.debugLog('is not listening to Platform BLE')
364
364
  }
365
365
  }
366
366
 
367
367
  async openAPIRefreshStatus(): Promise<void> {
368
- await this.debugLog('openAPIRefreshStatus')
368
+ this.debugLog('openAPIRefreshStatus')
369
369
  try {
370
- const { body } = await this.deviceRefreshStatus()
371
- const deviceStatus: any = await body
372
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
370
+ const response = await this.deviceRefreshStatus()
371
+ const deviceStatus: any = response.body
372
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
373
373
  if (await this.successfulStatusCodes(deviceStatus)) {
374
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
374
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
375
375
  this.deviceStatus = deviceStatus.body
376
376
  await this.openAPIparseStatus()
377
377
  await this.updateHomeKitCharacteristics()
378
378
  } else {
379
- await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
380
- await this.debugWarnLog(deviceStatus)
379
+ this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
380
+ this.debugWarnLog(deviceStatus)
381
381
  }
382
382
  } catch (e: any) {
383
383
  await this.apiError(e)
384
- await this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
384
+ this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
385
385
  }
386
386
  }
387
387
 
388
388
  async registerWebhook() {
389
389
  if (this.device.webhook) {
390
- await this.debugLog('is listening webhook.')
390
+ this.debugLog('is listening webhook.')
391
391
  this.platform.webhookEventHandler[this.device.deviceId] = async (context: humidifierWebhookContext) => {
392
392
  try {
393
- await this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
393
+ this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
394
394
  this.webhookContext = context
395
395
  await this.parseStatusWebhook()
396
396
  await this.updateHomeKitCharacteristics()
397
397
  } catch (e: any) {
398
- await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
398
+ this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
399
399
  }
400
400
  }
401
401
  }
@@ -406,14 +406,14 @@ export class Humidifier extends deviceBase {
406
406
  */
407
407
  async pushChanges(): Promise<void> {
408
408
  if (!this.device.enableCloudService && this.OpenAPI) {
409
- await this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`)
409
+ this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`)
410
410
  } else if (this.BLE) {
411
411
  await this.BLEpushChanges()
412
412
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
413
413
  await this.openAPIpushChanges()
414
414
  } else {
415
415
  await this.offlineOff()
416
- await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, pushChanges will not happen.`)
416
+ this.debugWarnLog(`Connection Type: ${this.device.connectionType}, pushChanges will not happen.`)
417
417
  }
418
418
  // Refresh the status from the API
419
419
  interval(15000)
@@ -425,7 +425,7 @@ export class Humidifier extends deviceBase {
425
425
  }
426
426
 
427
427
  async BLEpushChanges(): Promise<void> {
428
- await this.debugLog('BLEpushChanges')
428
+ this.debugLog('BLEpushChanges')
429
429
  if ((this.HumidifierDehumidifier.TargetHumidifierDehumidifierState === this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER)
430
430
  && (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.ACTIVE)
431
431
  && (this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold !== this.HumidifierDehumidifier.CurrentRelativeHumidity)) {
@@ -433,7 +433,7 @@ export class Humidifier extends deviceBase {
433
433
  try {
434
434
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId)
435
435
  this.device.bleMac = formattedDeviceId
436
- await this.debugLog(`bleMac: ${this.device.bleMac}`)
436
+ this.debugLog(`bleMac: ${this.device.bleMac}`)
437
437
  if (switchBotBLE !== false) {
438
438
  switchBotBLE
439
439
  .discover({ model: this.device.bleModel, quick: true, id: this.device.bleMac })
@@ -442,51 +442,51 @@ export class Humidifier extends deviceBase {
442
442
  return await deviceList[0].percentage(this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold)
443
443
  })
444
444
  .then(async () => {
445
- await this.successLog(`RelativeHumidityHumidifierThreshold: ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold} sent over BLE, sent successfully`)
445
+ this.successLog(`RelativeHumidityHumidifierThreshold: ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold} sent over BLE, sent successfully`)
446
446
  await this.updateHomeKitCharacteristics()
447
447
  })
448
448
  .catch(async (e: any) => {
449
449
  await this.apiError(e)
450
- await this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
450
+ this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
451
451
  await this.BLEPushConnection()
452
452
  })
453
453
  } else {
454
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`)
454
+ this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`)
455
455
  await this.BLEPushConnection()
456
456
  }
457
457
  } catch (error) {
458
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
458
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
459
459
  }
460
460
  } else {
461
- await this.debugLog(`No changes (BLEpushChanges), Active: ${this.HumidifierDehumidifier.Active}, RelativeHumidityHumidifierThreshold: ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold}, CurrentRelativeHumidity: ${this.HumidifierDehumidifier.CurrentRelativeHumidity}`)
461
+ this.debugLog(`No changes (BLEpushChanges), Active: ${this.HumidifierDehumidifier.Active}, RelativeHumidityHumidifierThreshold: ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold}, CurrentRelativeHumidity: ${this.HumidifierDehumidifier.CurrentRelativeHumidity}`)
462
462
  }
463
463
  }
464
464
 
465
465
  async openAPIpushChanges(): Promise<void> {
466
- await this.debugLog('openAPIpushChanges')
466
+ this.debugLog('openAPIpushChanges')
467
467
  if ((this.HumidifierDehumidifier.TargetHumidifierDehumidifierState === this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER)
468
468
  && (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.ACTIVE)
469
469
  && (this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold !== this.HumidifierDehumidifier.CurrentRelativeHumidity)) {
470
- await this.debugLog(`Auto Off, RelativeHumidityHumidifierThreshold: ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold}!`)
470
+ this.debugLog(`Auto Off, RelativeHumidityHumidifierThreshold: ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold}!`)
471
471
  const bodyChange: bodyChange = {
472
472
  command: 'setMode',
473
473
  parameter: `${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold}`,
474
474
  commandType: 'command',
475
475
  }
476
- await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
476
+ this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
477
477
  try {
478
- const { body } = await this.pushChangeRequest(bodyChange)
479
- const deviceStatus: any = await body
480
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
478
+ const response = await this.pushChangeRequest(bodyChange)
479
+ const deviceStatus: any = response.body
480
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
481
481
  if (await this.successfulStatusCodes(deviceStatus)) {
482
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
482
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
483
483
  await this.updateHomeKitCharacteristics()
484
484
  } else {
485
485
  await this.statusCode(deviceStatus.statusCode)
486
486
  }
487
487
  } catch (e: any) {
488
488
  await this.apiError(e)
489
- await this.errorLog(`failed openAPIpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
489
+ this.errorLog(`failed openAPIpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
490
490
  }
491
491
  } else if ((this.HumidifierDehumidifier.TargetHumidifierDehumidifierState === this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER) && (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.ACTIVE)) {
492
492
  await this.pushAutoChanges()
@@ -503,29 +503,29 @@ export class Humidifier extends deviceBase {
503
503
  if ((this.HumidifierDehumidifier.TargetHumidifierDehumidifierState
504
504
  === this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER)
505
505
  && (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.ACTIVE)) {
506
- await this.debugLog('Pushing Auto')
506
+ this.debugLog('Pushing Auto')
507
507
  const bodyChange: bodyChange = {
508
508
  command: 'setMode',
509
509
  parameter: 'auto',
510
510
  commandType: 'command',
511
511
  }
512
- await this.debugLog(`pushAutoChanges, SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
512
+ this.debugLog(`pushAutoChanges, SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
513
513
  try {
514
- const { body } = await this.pushChangeRequest(bodyChange)
515
- const deviceStatus: any = await body
516
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
514
+ const response = await this.pushChangeRequest(bodyChange)
515
+ const deviceStatus: any = response.body
516
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
517
517
  if (await this.successfulStatusCodes(deviceStatus)) {
518
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
518
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
519
519
  await this.updateHomeKitCharacteristics()
520
520
  } else {
521
521
  await this.statusCode(deviceStatus.statusCode)
522
522
  }
523
523
  } catch (e: any) {
524
524
  await this.apiError(e)
525
- await this.errorLog(`failed pushAutoChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
525
+ this.errorLog(`failed pushAutoChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
526
526
  }
527
527
  } else {
528
- await this.debugLog(`No changes (pushAutoChanges), TargetHumidifierDehumidifierState: ${this.HumidifierDehumidifier.TargetHumidifierDehumidifierState}, Active: ${this.HumidifierDehumidifier.Active}`)
528
+ this.debugLog(`No changes (pushAutoChanges), TargetHumidifierDehumidifierState: ${this.HumidifierDehumidifier.TargetHumidifierDehumidifierState}, Active: ${this.HumidifierDehumidifier.Active}`)
529
529
  }
530
530
  }
531
531
 
@@ -533,31 +533,31 @@ export class Humidifier extends deviceBase {
533
533
  * Pushes the requested changes to the SwitchBot API
534
534
  */
535
535
  async pushActiveChanges(): Promise<void> {
536
- await this.debugLog('pushActiveChanges')
536
+ this.debugLog('pushActiveChanges')
537
537
  if (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.INACTIVE) {
538
- await this.debugLog('Pushing Off')
538
+ this.debugLog('Pushing Off')
539
539
  const bodyChange: bodyChange = {
540
540
  command: 'turnOff',
541
541
  parameter: 'default',
542
542
  commandType: 'command',
543
543
  }
544
- await this.debugLog(`pushActiveChanges, SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
544
+ this.debugLog(`pushActiveChanges, SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
545
545
  try {
546
- const { body } = await this.pushChangeRequest(bodyChange)
547
- const deviceStatus: any = await body
548
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
546
+ const response = await this.pushChangeRequest(bodyChange)
547
+ const deviceStatus: any = response.body
548
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
549
549
  if (await this.successfulStatusCodes(deviceStatus)) {
550
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
550
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
551
551
  await this.updateHomeKitCharacteristics()
552
552
  } else {
553
553
  await this.statusCode(deviceStatus.statusCode)
554
554
  }
555
555
  } catch (e: any) {
556
556
  await this.apiError(e)
557
- await this.errorLog(`failed pushActiveChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
557
+ this.errorLog(`failed pushActiveChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
558
558
  }
559
559
  } else {
560
- await this.debugLog(`No changes (pushActiveChanges), Active: ${this.HumidifierDehumidifier.Active}`)
560
+ this.debugLog(`No changes (pushActiveChanges), Active: ${this.HumidifierDehumidifier.Active}`)
561
561
  }
562
562
  }
563
563
 
@@ -566,9 +566,9 @@ export class Humidifier extends deviceBase {
566
566
  */
567
567
  async ActiveSet(value: CharacteristicValue): Promise<void> {
568
568
  if (this.HumidifierDehumidifier.Active !== this.accessory.context.Active) {
569
- await this.infoLog(`Set Active: ${value}`)
569
+ this.infoLog(`Set Active: ${value}`)
570
570
  } else {
571
- await this.debugLog(`No Changes, Active: ${value}`)
571
+ this.debugLog(`No Changes, Active: ${value}`)
572
572
  }
573
573
 
574
574
  this.HumidifierDehumidifier.Active = value
@@ -580,9 +580,9 @@ export class Humidifier extends deviceBase {
580
580
  */
581
581
  async TargetHumidifierDehumidifierStateSet(value: CharacteristicValue): Promise<void> {
582
582
  if (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.ACTIVE) {
583
- await this.infoLog(`Set TargetHumidifierDehumidifierState: ${value}`)
583
+ this.infoLog(`Set TargetHumidifierDehumidifierState: ${value}`)
584
584
  } else {
585
- await this.debugLog(`No Changes, TargetHumidifierDehumidifierState: ${value}`)
585
+ this.debugLog(`No Changes, TargetHumidifierDehumidifierState: ${value}`)
586
586
  }
587
587
 
588
588
  this.HumidifierDehumidifier.TargetHumidifierDehumidifierState = value
@@ -594,9 +594,9 @@ export class Humidifier extends deviceBase {
594
594
  */
595
595
  async RelativeHumidityHumidifierThresholdSet(value: CharacteristicValue): Promise<void> {
596
596
  if (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.ACTIVE) {
597
- await this.infoLog(`Set RelativeHumidityHumidifierThreshold: ${value}`)
597
+ this.infoLog(`Set RelativeHumidityHumidifierThreshold: ${value}`)
598
598
  } else {
599
- await this.debugLog(`No Changes, RelativeHumidityHumidifierThreshold: ${value}`)
599
+ this.debugLog(`No Changes, RelativeHumidityHumidifierThreshold: ${value}`)
600
600
  }
601
601
  // If the Humidifier is off, turn it on
602
602
  if (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.INACTIVE) {
@@ -632,15 +632,15 @@ export class Humidifier extends deviceBase {
632
632
 
633
633
  async BLEPushConnection() {
634
634
  if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
635
- await this.warnLog('Using OpenAPI Connection to Push Changes')
635
+ this.warnLog('Using OpenAPI Connection to Push Changes')
636
636
  await this.openAPIpushChanges()
637
637
  }
638
638
  }
639
639
 
640
640
  async BLERefreshConnection(switchbot: any): Promise<void> {
641
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`)
641
+ this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`)
642
642
  if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
643
- await this.warnLog('Using OpenAPI Connection to Refresh Status')
643
+ this.warnLog('Using OpenAPI Connection to Refresh Status')
644
644
  await this.openAPIRefreshStatus()
645
645
  }
646
646
  }