@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
@@ -188,7 +188,7 @@ export class CeilingLight extends deviceBase {
188
188
  await this.pushChanges()
189
189
  } catch (e: any) {
190
190
  await this.apiError(e)
191
- await this.errorLog(`failed pushChanges with ${device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
191
+ this.errorLog(`failed pushChanges with ${device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
192
192
  }
193
193
  this.ceilingLightUpdateInProgress = false
194
194
  })
@@ -198,43 +198,43 @@ export class CeilingLight extends deviceBase {
198
198
  * Parse the device status from the SwitchBotBLE API
199
199
  */
200
200
  async BLEparseStatus(): Promise<void> {
201
- await this.debugLog('BLEparseStatus')
202
- await this.debugLog(`(power, brightness, colorTemperature) = BLE:(${this.serviceData.state}, ${this.serviceData.brightness}, ${this.serviceData.color_temperature}), current:(${this.LightBulb.On}, ${this.LightBulb.Brightness}, ${this.LightBulb.ColorTemperature})`)
201
+ this.debugLog('BLEparseStatus')
202
+ this.debugLog(`(power, brightness, colorTemperature) = BLE:(${this.serviceData.state}, ${this.serviceData.brightness}, ${this.serviceData.color_temperature}), current:(${this.LightBulb.On}, ${this.LightBulb.Brightness}, ${this.LightBulb.ColorTemperature})`)
203
203
 
204
204
  // On
205
205
  this.LightBulb.On = this.serviceData.state
206
- await this.debugLog(`On: ${this.LightBulb.On}`)
206
+ this.debugLog(`On: ${this.LightBulb.On}`)
207
207
 
208
208
  // ColorTemperature
209
209
  const miredColorTemperature = Math.round(1000000 / this.serviceData.color_temperature)
210
210
  this.LightBulb.ColorTemperature = Math.max(Math.min(miredColorTemperature, 500), 140)
211
- await this.debugLog(`ColorTemperature: ${this.LightBulb.ColorTemperature}`)
211
+ this.debugLog(`ColorTemperature: ${this.LightBulb.ColorTemperature}`)
212
212
  }
213
213
 
214
214
  /**
215
215
  * Parse the device status from the SwitchBot OpenAPI
216
216
  */
217
217
  async openAPIparseStatus(): Promise<void> {
218
- await this.debugLog('openAPIparseStatus')
219
- await this.debugLog(`(power, brightness, colorTemperature) = OpenAPI:(${this.deviceStatus.power}, ${this.deviceStatus.brightness}, ${this.deviceStatus.colorTemperature}), current:(${this.LightBulb.On}, ${this.LightBulb.Brightness}, ${this.LightBulb.ColorTemperature})`)
218
+ this.debugLog('openAPIparseStatus')
219
+ this.debugLog(`(power, brightness, colorTemperature) = OpenAPI:(${this.deviceStatus.power}, ${this.deviceStatus.brightness}, ${this.deviceStatus.colorTemperature}), current:(${this.LightBulb.On}, ${this.LightBulb.Brightness}, ${this.LightBulb.ColorTemperature})`)
220
220
 
221
221
  // On
222
222
  this.LightBulb.On = this.deviceStatus.power
223
- await this.debugLog(`On: ${this.LightBulb.On}`)
223
+ this.debugLog(`On: ${this.LightBulb.On}`)
224
224
 
225
225
  // Brightness
226
226
  this.LightBulb.Brightness = this.deviceStatus.brightness
227
- await this.debugLog(`Brightness: ${this.LightBulb.Brightness}`)
227
+ this.debugLog(`Brightness: ${this.LightBulb.Brightness}`)
228
228
 
229
229
  // ColorTemperature
230
230
  const miredColorTemperature = Math.round(1000000 / this.deviceStatus.colorTemperature)
231
231
  this.LightBulb.ColorTemperature = Math.max(Math.min(miredColorTemperature, 500), 140)
232
- await this.debugLog(`ColorTemperature: ${this.LightBulb.ColorTemperature}`)
232
+ this.debugLog(`ColorTemperature: ${this.LightBulb.ColorTemperature}`)
233
233
 
234
234
  // Firmware Version
235
235
  if (this.deviceStatus.version) {
236
236
  const version = this.deviceStatus.version.toString()
237
- await this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`)
237
+ this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`)
238
238
  const deviceVersion = version.replace(/^V|-.*$/g, '') ?? '0.0.0'
239
239
  this.accessory
240
240
  .getService(this.hap.Service.AccessoryInformation)!
@@ -243,26 +243,26 @@ export class CeilingLight extends deviceBase {
243
243
  .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
244
244
  .updateValue(deviceVersion)
245
245
  this.accessory.context.version = deviceVersion
246
- await this.debugSuccessLog(`version: ${this.accessory.context.version}`)
246
+ this.debugSuccessLog(`version: ${this.accessory.context.version}`)
247
247
  }
248
248
  }
249
249
 
250
250
  async parseStatusWebhook(): Promise<void> {
251
- await this.debugLog('parseStatusWebhook')
252
- await this.debugLog(`(powerState, brightness, colorTemperature) = Webhook:(${this.webhookContext.powerState}, ${this.webhookContext.brightness}, ${this.webhookContext.colorTemperature}), current:(${this.LightBulb.On}, ${this.LightBulb.Brightness}, ${this.LightBulb.ColorTemperature})`)
251
+ this.debugLog('parseStatusWebhook')
252
+ this.debugLog(`(powerState, brightness, colorTemperature) = Webhook:(${this.webhookContext.powerState}, ${this.webhookContext.brightness}, ${this.webhookContext.colorTemperature}), current:(${this.LightBulb.On}, ${this.LightBulb.Brightness}, ${this.LightBulb.ColorTemperature})`)
253
253
 
254
254
  // On
255
255
  this.LightBulb.On = this.webhookContext.powerState === 'ON'
256
- await this.debugLog(`On: ${this.LightBulb.On}`)
256
+ this.debugLog(`On: ${this.LightBulb.On}`)
257
257
 
258
258
  // Brightness
259
259
  this.LightBulb.Brightness = this.webhookContext.brightness
260
- await this.debugLog(`Brightness: ${this.LightBulb.Brightness}`)
260
+ this.debugLog(`Brightness: ${this.LightBulb.Brightness}`)
261
261
 
262
262
  // ColorTemperature
263
263
  const miredColorTemperature = Math.round(1000000 / this.webhookContext.colorTemperature)
264
264
  this.LightBulb.ColorTemperature = Math.max(Math.min(miredColorTemperature, 500), 140)
265
- await this.debugLog(`ColorTemperature: ${this.LightBulb.ColorTemperature}`)
265
+ this.debugLog(`ColorTemperature: ${this.LightBulb.ColorTemperature}`)
266
266
  }
267
267
 
268
268
  /**
@@ -270,19 +270,19 @@ export class CeilingLight extends deviceBase {
270
270
  */
271
271
  async refreshStatus(): Promise<void> {
272
272
  if (!this.device.enableCloudService && this.OpenAPI) {
273
- await this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
273
+ this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
274
274
  } else if (this.BLE) {
275
275
  await this.BLERefreshStatus()
276
276
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
277
277
  await this.openAPIRefreshStatus()
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
 
284
284
  async BLERefreshStatus(): Promise<void> {
285
- await this.debugLog('BLERefreshStatus')
285
+ this.debugLog('BLERefreshStatus')
286
286
  const switchBotBLE = await this.switchbotBLE()
287
287
  if (switchBotBLE === undefined) {
288
288
  await this.BLERefreshConnection(switchBotBLE)
@@ -296,7 +296,7 @@ export class CeilingLight extends deviceBase {
296
296
  await this.BLEparseStatus()
297
297
  await this.updateHomeKitCharacteristics()
298
298
  } else {
299
- await this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
299
+ this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
300
300
  await this.BLERefreshConnection(switchBotBLE)
301
301
  }
302
302
  })()
@@ -304,67 +304,67 @@ export class CeilingLight extends deviceBase {
304
304
  }
305
305
 
306
306
  async registerPlatformBLE(): Promise<void> {
307
- await this.debugLog('registerPlatformBLE')
307
+ this.debugLog('registerPlatformBLE')
308
308
  if (this.config.options?.BLE) {
309
- await this.debugLog('is listening to Platform BLE.')
309
+ this.debugLog('is listening to Platform BLE.')
310
310
  try {
311
311
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId)
312
312
  this.device.bleMac = formattedDeviceId
313
- await this.debugLog(`bleMac: ${this.device.bleMac}`)
313
+ this.debugLog(`bleMac: ${this.device.bleMac}`)
314
314
  this.platform.bleEventHandler[this.device.bleMac] = async (context: ceilingLightServiceData | ceilingLightProServiceData) => {
315
315
  try {
316
- await this.debugLog(`received BLE: ${JSON.stringify(context)}`)
316
+ this.debugLog(`received BLE: ${JSON.stringify(context)}`)
317
317
  this.serviceData = context
318
318
  await this.BLEparseStatus()
319
319
  await this.updateHomeKitCharacteristics()
320
320
  } catch (e: any) {
321
- await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
321
+ this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
322
322
  }
323
323
  }
324
324
  } catch (error) {
325
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
325
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
326
326
  }
327
327
  } else {
328
- await this.debugLog('is not listening to Platform BLE')
328
+ this.debugLog('is not listening to Platform BLE')
329
329
  }
330
330
  }
331
331
 
332
332
  async openAPIRefreshStatus(): Promise<void> {
333
- await this.debugLog('openAPIRefreshStatus')
333
+ this.debugLog('openAPIRefreshStatus')
334
334
  try {
335
- const { body } = await this.deviceRefreshStatus()
336
- const deviceStatus: any = await body
337
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
335
+ const response = await this.deviceRefreshStatus()
336
+ const deviceStatus: any = response.body
337
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
338
338
  if (await this.successfulStatusCodes(deviceStatus)) {
339
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
339
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
340
340
  this.deviceStatus = deviceStatus.body
341
341
  await this.openAPIparseStatus()
342
342
  await this.updateHomeKitCharacteristics()
343
343
  } else {
344
- await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
345
- await this.debugWarnLog(deviceStatus)
344
+ this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
345
+ this.debugWarnLog(deviceStatus)
346
346
  }
347
347
  } catch (e: any) {
348
348
  await this.apiError(e)
349
- await this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
349
+ this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
350
350
  }
351
351
  }
352
352
 
353
353
  async registerWebhook() {
354
354
  if (this.device.webhook) {
355
- await this.debugLog('is listening webhook.')
355
+ this.debugLog('is listening webhook.')
356
356
  this.platform.webhookEventHandler[this.device.deviceId] = async (context: ceilingLightWebhookContext | ceilingLightProWebhookContext) => {
357
357
  try {
358
- await this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
358
+ this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
359
359
  this.webhookContext = context
360
360
  await this.parseStatusWebhook()
361
361
  await this.updateHomeKitCharacteristics()
362
362
  } catch (e: any) {
363
- await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
363
+ this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
364
364
  }
365
365
  }
366
366
  } else {
367
- await this.debugLog('is not listening webhook.')
367
+ this.debugLog('is not listening webhook.')
368
368
  }
369
369
  }
370
370
 
@@ -381,28 +381,28 @@ export class CeilingLight extends deviceBase {
381
381
  */
382
382
  async pushChanges(): Promise<void> {
383
383
  if (!this.device.enableCloudService && this.OpenAPI) {
384
- await this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`)
384
+ this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`)
385
385
  } else if (this.BLE) {
386
386
  await this.BLEpushChanges()
387
387
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
388
388
  await this.openAPIpushChanges()
389
389
  if (this.LightBulb.On) {
390
- await this.debugLog(`On: ${this.LightBulb.On}`)
390
+ this.debugLog(`On: ${this.LightBulb.On}`)
391
391
  // Push Brightness Update
392
- await this.debugLog(`Brightness: ${this.LightBulb.Brightness}`)
392
+ this.debugLog(`Brightness: ${this.LightBulb.Brightness}`)
393
393
  await this.pushBrightnessChanges()
394
394
  // Push ColorTemperature Update
395
- await this.debugLog(`ColorTemperature: ${this.LightBulb.ColorTemperature}`)
395
+ this.debugLog(`ColorTemperature: ${this.LightBulb.ColorTemperature}`)
396
396
  await this.pushColorTemperatureChanges()
397
397
  // Push Hue & Saturation Update
398
- await this.debugLog(`Hue: ${this.LightBulb.Hue}, Saturation: ${this.LightBulb.Saturation}`)
398
+ this.debugLog(`Hue: ${this.LightBulb.Hue}, Saturation: ${this.LightBulb.Saturation}`)
399
399
  await this.pushHueSaturationChanges()
400
400
  } else {
401
- await this.debugLog('BLE (Brightness), (ColorTemperature), (Hue), & (Saturation) changes will not happen, as the device is OFF.')
401
+ this.debugLog('BLE (Brightness), (ColorTemperature), (Hue), & (Saturation) changes will not happen, as the device is OFF.')
402
402
  }
403
403
  } else {
404
404
  await this.offlineOff()
405
- await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, pushChanges will not happen.`)
405
+ this.debugWarnLog(`Connection Type: ${this.device.connectionType}, pushChanges will not happen.`)
406
406
  }
407
407
  // Refresh the status from the API
408
408
  interval(15000)
@@ -414,14 +414,14 @@ export class CeilingLight extends deviceBase {
414
414
  }
415
415
 
416
416
  async BLEpushChanges(): Promise<void> {
417
- await this.debugLog('BLEpushChanges')
417
+ this.debugLog('BLEpushChanges')
418
418
  if (this.LightBulb.On !== this.accessory.context.On) {
419
- await this.debugLog(`BLEpushChanges On: ${this.LightBulb.On} OnCached: ${this.accessory.context.On}`)
419
+ this.debugLog(`BLEpushChanges On: ${this.LightBulb.On} OnCached: ${this.accessory.context.On}`)
420
420
  const switchBotBLE = await this.platform.connectBLE(this.accessory, this.device)
421
421
  try {
422
422
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId)
423
423
  this.device.bleMac = formattedDeviceId
424
- await this.debugLog(`bleMac: ${this.device.bleMac}`)
424
+ this.debugLog(`bleMac: ${this.device.bleMac}`)
425
425
  if (switchBotBLE !== false) {
426
426
  switchBotBLE
427
427
  .discover({ model: this.device.bleModel, id: this.device.bleMac })
@@ -440,28 +440,28 @@ export class CeilingLight extends deviceBase {
440
440
  })
441
441
  })
442
442
  .then(async () => {
443
- await this.successLog(`On: ${this.LightBulb.On} sent over SwitchBot BLE, sent successfully`)
443
+ this.successLog(`On: ${this.LightBulb.On} sent over SwitchBot BLE, sent successfully`)
444
444
  this.LightBulb.On = false
445
445
  })
446
446
  .catch(async (e: any) => {
447
447
  await this.apiError(e)
448
- await this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
448
+ this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
449
449
  await this.BLEPushConnection()
450
450
  })
451
451
  } else {
452
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`)
452
+ this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`)
453
453
  await this.BLEPushConnection()
454
454
  }
455
455
  } catch (error) {
456
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
456
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
457
457
  }
458
458
  } else {
459
- await this.debugLog(`No changes (BLEpushChanges): On: ${this.LightBulb.On}, OnCached: ${this.accessory.context.On}`)
459
+ this.debugLog(`No changes (BLEpushChanges): On: ${this.LightBulb.On}, OnCached: ${this.accessory.context.On}`)
460
460
  }
461
461
  }
462
462
 
463
463
  async openAPIpushChanges(): Promise<void> {
464
- await this.debugLog('openAPIpushChanges')
464
+ this.debugLog('openAPIpushChanges')
465
465
  if (this.LightBulb.On !== this.accessory.context.On) {
466
466
  const command = this.LightBulb.On ? 'turnOn' : 'turnOff'
467
467
  const bodyChange: bodyChange = {
@@ -469,60 +469,60 @@ export class CeilingLight extends deviceBase {
469
469
  parameter: 'default',
470
470
  commandType: 'command',
471
471
  }
472
- await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
472
+ this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
473
473
  try {
474
- const { body } = await this.pushChangeRequest(bodyChange)
475
- const deviceStatus: any = await body
476
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
474
+ const response = await this.pushChangeRequest(bodyChange)
475
+ const deviceStatus: any = response.body
476
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
477
477
  if (await this.successfulStatusCodes(deviceStatus)) {
478
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
478
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
479
479
  await this.updateHomeKitCharacteristics()
480
480
  } else {
481
481
  await this.statusCode(deviceStatus.statusCode)
482
482
  }
483
483
  } catch (e: any) {
484
484
  await this.apiError(e)
485
- await this.errorLog(`failed openAPIpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
485
+ this.errorLog(`failed openAPIpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
486
486
  }
487
487
  } else {
488
- await this.debugLog(`No changes (openAPIpushChanges), On: ${this.LightBulb.On}, OnCached: ${this.accessory.context.On}`)
488
+ this.debugLog(`No changes (openAPIpushChanges), On: ${this.LightBulb.On}, OnCached: ${this.accessory.context.On}`)
489
489
  }
490
490
  }
491
491
 
492
492
  async pushHueSaturationChanges(): Promise<void> {
493
- await this.debugLog('pushHueSaturationChanges')
493
+ this.debugLog('pushHueSaturationChanges')
494
494
  if ((this.LightBulb.Hue !== this.accessory.context.Hue) || (this.LightBulb.Saturation !== this.accessory.context.Saturation)) {
495
- await this.debugLog(`Hue: ${JSON.stringify(this.LightBulb.Hue)}`)
496
- await this.debugLog(`Saturation: ${JSON.stringify(this.LightBulb.Saturation)}`)
495
+ this.debugLog(`Hue: ${JSON.stringify(this.LightBulb.Hue)}`)
496
+ this.debugLog(`Saturation: ${JSON.stringify(this.LightBulb.Saturation)}`)
497
497
  const [red, green, blue] = hs2rgb(Number(this.LightBulb.Hue), Number(this.LightBulb.Saturation))
498
- await this.debugLog(`rgb: ${JSON.stringify([red, green, blue])}`)
498
+ this.debugLog(`rgb: ${JSON.stringify([red, green, blue])}`)
499
499
  const bodyChange: bodyChange = {
500
500
  command: 'setColor',
501
501
  parameter: `${red}:${green}:${blue}`,
502
502
  commandType: 'command',
503
503
  }
504
- await this.debugLog(`(pushHueSaturationChanges) SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
504
+ this.debugLog(`(pushHueSaturationChanges) SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
505
505
  try {
506
- const { body } = await this.pushChangeRequest(bodyChange)
507
- const deviceStatus: any = await body
508
- await this.debugLog(`(pushHueSaturationChanges) statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
506
+ const response = await this.pushChangeRequest(bodyChange)
507
+ const deviceStatus: any = response.body
508
+ this.debugLog(`(pushHueSaturationChanges) statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
509
509
  if (await this.successfulStatusCodes(deviceStatus)) {
510
- await this.debugSuccessLog(`(pushHueSaturationChanges) statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
510
+ this.debugSuccessLog(`(pushHueSaturationChanges) statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
511
511
  await this.updateHomeKitCharacteristics()
512
512
  } else {
513
513
  await this.statusCode(deviceStatus.statusCode)
514
514
  }
515
515
  } catch (e: any) {
516
516
  await this.apiError(e)
517
- await this.errorLog(`failed pushHueSaturationChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
517
+ this.errorLog(`failed pushHueSaturationChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
518
518
  }
519
519
  } else {
520
- await this.debugLog(`No changes (pushHueSaturationChanges), Hue: ${this.LightBulb.Hue}, HueCached: ${this.accessory.context.Hue}, Saturation: ${this.LightBulb.Saturation}, SaturationCached: ${this.accessory.context.Saturation}`)
520
+ this.debugLog(`No changes (pushHueSaturationChanges), Hue: ${this.LightBulb.Hue}, HueCached: ${this.accessory.context.Hue}, Saturation: ${this.LightBulb.Saturation}, SaturationCached: ${this.accessory.context.Saturation}`)
521
521
  }
522
522
  }
523
523
 
524
524
  async pushColorTemperatureChanges(): Promise<void> {
525
- await this.debugLog('pushColorTemperatureChanges')
525
+ this.debugLog('pushColorTemperatureChanges')
526
526
  if (this.LightBulb.ColorTemperature !== this.accessory.context.ColorTemperature) {
527
527
  const kelvin = Math.round(1000000 * Number(this.LightBulb.ColorTemperature))
528
528
  this.accessory.context.kelvin = kelvin
@@ -531,51 +531,51 @@ export class CeilingLight extends deviceBase {
531
531
  parameter: `${kelvin}`,
532
532
  commandType: 'command',
533
533
  }
534
- await this.debugLog(`(pushColorTemperatureChanges) SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
534
+ this.debugLog(`(pushColorTemperatureChanges) SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
535
535
  try {
536
- const { body } = await this.pushChangeRequest(bodyChange)
537
- const deviceStatus: any = await body
538
- await this.debugLog(`(pushColorTemperatureChanges) statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
536
+ const response = await this.pushChangeRequest(bodyChange)
537
+ const deviceStatus: any = response.body
538
+ this.debugLog(`(pushColorTemperatureChanges) statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
539
539
  if (await this.successfulStatusCodes(deviceStatus)) {
540
- await this.debugSuccessLog(`(pushColorTemperatureChanges) statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
540
+ this.debugSuccessLog(`(pushColorTemperatureChanges) statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
541
541
  await this.updateHomeKitCharacteristics()
542
542
  } else {
543
543
  await this.statusCode(deviceStatus.statusCode)
544
544
  }
545
545
  } catch (e: any) {
546
546
  await this.apiError(e)
547
- await this.errorLog(`failed pushColorTemperatureChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
547
+ this.errorLog(`failed pushColorTemperatureChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
548
548
  }
549
549
  } else {
550
- await this.debugLog(`No changes (pushColorTemperatureChanges), ColorTemperature: ${this.LightBulb.ColorTemperature}, ColorTemperatureCached: ${this.accessory.context.ColorTemperature}`)
550
+ this.debugLog(`No changes (pushColorTemperatureChanges), ColorTemperature: ${this.LightBulb.ColorTemperature}, ColorTemperatureCached: ${this.accessory.context.ColorTemperature}`)
551
551
  }
552
552
  }
553
553
 
554
554
  async pushBrightnessChanges(): Promise<void> {
555
- await this.debugLog('pushBrightnessChanges')
555
+ this.debugLog('pushBrightnessChanges')
556
556
  if (this.LightBulb.Brightness !== this.accessory.context.Brightness) {
557
557
  const bodyChange: bodyChange = {
558
558
  command: 'setBrightness',
559
559
  parameter: `${this.LightBulb.Brightness}`,
560
560
  commandType: 'command',
561
561
  }
562
- await this.debugLog(`(pushBrightnessChanges) SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
562
+ this.debugLog(`(pushBrightnessChanges) 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(`(pushBrightnessChanges) statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
564
+ const response = await this.pushChangeRequest(bodyChange)
565
+ const deviceStatus: any = response.body
566
+ this.debugLog(`(pushBrightnessChanges) statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
567
567
  if (await this.successfulStatusCodes(deviceStatus)) {
568
- await this.debugSuccessLog(`(pushBrightnessChanges) statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
568
+ this.debugSuccessLog(`(pushBrightnessChanges) 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 pushBrightnessChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
575
+ this.errorLog(`failed pushBrightnessChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
576
576
  }
577
577
  } else {
578
- await this.debugLog(`No changes (pushBrightnessChanges), Brightness: ${this.LightBulb.Brightness}, BrightnessCached: ${this.accessory.context.Brightness}`)
578
+ this.debugLog(`No changes (pushBrightnessChanges), Brightness: ${this.LightBulb.Brightness}, BrightnessCached: ${this.accessory.context.Brightness}`)
579
579
  }
580
580
  }
581
581
 
@@ -584,9 +584,9 @@ export class CeilingLight extends deviceBase {
584
584
  */
585
585
  async OnSet(value: CharacteristicValue): Promise<void> {
586
586
  if (this.LightBulb.On !== this.accessory.context.On) {
587
- await this.infoLog(`Set On: ${value}`)
587
+ this.infoLog(`Set On: ${value}`)
588
588
  } else {
589
- await this.debugLog(`No Changes, Set On: ${value}`)
589
+ this.debugLog(`No Changes, Set On: ${value}`)
590
590
  }
591
591
 
592
592
  this.LightBulb.On = value
@@ -598,7 +598,7 @@ export class CeilingLight extends deviceBase {
598
598
  */
599
599
  async BrightnessSet(value: CharacteristicValue): Promise<void> {
600
600
  if (this.LightBulb.On && (this.LightBulb.Brightness !== this.accessory.context.Brightness)) {
601
- await this.infoLog(`Set Brightness: ${value}`)
601
+ this.infoLog(`Set Brightness: ${value}`)
602
602
  } else {
603
603
  if (this.LightBulb.On) {
604
604
  this.debugLog(`No Changes, Brightness: ${value}`)
@@ -701,7 +701,7 @@ export class CeilingLight extends deviceBase {
701
701
  async getAdaptiveLightingSettings(accessory: PlatformAccessory, device: device & devicesConfig): Promise<void> {
702
702
  // Adaptive Lighting
703
703
  this.adaptiveLighting = accessory.context.adaptiveLighting ?? true
704
- await this.debugLog(`adaptiveLighting: ${this.adaptiveLighting}`)
704
+ this.debugLog(`adaptiveLighting: ${this.adaptiveLighting}`)
705
705
  // Adaptive Lighting Shift
706
706
  this.adaptiveLightingShift = (device as ceilingLightConfig).adaptiveLightingShift ?? 0
707
707
  this.debugLog(`adaptiveLightingShift: ${this.adaptiveLightingShift}`)
@@ -709,15 +709,15 @@ export class CeilingLight extends deviceBase {
709
709
 
710
710
  async BLEPushConnection() {
711
711
  if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
712
- await this.warnLog('Using OpenAPI Connection to Push Changes')
712
+ this.warnLog('Using OpenAPI Connection to Push Changes')
713
713
  await this.openAPIpushChanges()
714
714
  }
715
715
  }
716
716
 
717
717
  async BLERefreshConnection(switchbot: any): Promise<void> {
718
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`)
718
+ this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`)
719
719
  if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
720
- await this.warnLog('Using OpenAPI Connection to Refresh Status')
720
+ this.warnLog('Using OpenAPI Connection to Refresh Status')
721
721
  await this.openAPIRefreshStatus()
722
722
  }
723
723
  }