@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
@@ -188,28 +188,28 @@ export class StripLight 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.stripLightUpdateInProgress = false
194
194
  })
195
195
  }
196
196
 
197
197
  async BLEparseStatus(): Promise<void> {
198
- await this.debugLog('BLEparseStatus')
199
- await this.debugLog(`(power, brightness, color) = BLE:(${this.serviceData.power}, ${this.serviceData.brightness}, ${this.serviceData.red}:${this.serviceData.green}:${this.serviceData.blue}), current:(${this.LightBulb.On}, ${this.LightBulb.Brightness}, ${this.LightBulb.Hue}, ${this.LightBulb.Saturation})`)
198
+ this.debugLog('BLEparseStatus')
199
+ this.debugLog(`(power, brightness, color) = BLE:(${this.serviceData.power}, ${this.serviceData.brightness}, ${this.serviceData.red}:${this.serviceData.green}:${this.serviceData.blue}), current:(${this.LightBulb.On}, ${this.LightBulb.Brightness}, ${this.LightBulb.Hue}, ${this.LightBulb.Saturation})`)
200
200
 
201
201
  // On
202
202
  this.LightBulb.On = this.serviceData.power
203
- await this.debugLog(`On: ${this.LightBulb.On}`)
203
+ this.debugLog(`On: ${this.LightBulb.On}`)
204
204
 
205
205
  // Brightness
206
206
  this.LightBulb.Brightness = this.serviceData.brightness
207
- await this.debugLog(`Brightness: ${this.LightBulb.Brightness}`)
207
+ this.debugLog(`Brightness: ${this.LightBulb.Brightness}`)
208
208
 
209
209
  // Color, Hue & Brightness
210
- await this.debugLog(`red: ${this.serviceData.red}, green: ${this.serviceData.green}, blue: ${this.serviceData.blue}`)
210
+ this.debugLog(`red: ${this.serviceData.red}, green: ${this.serviceData.green}, blue: ${this.serviceData.blue}`)
211
211
  const [hue, saturation] = rgb2hs(this.serviceData.red, this.serviceData.green, this.serviceData.blue)
212
- await this.debugLog(`hs: ${JSON.stringify(rgb2hs(this.serviceData.red, this.serviceData.green, this.serviceData.blue))}`)
212
+ this.debugLog(`hs: ${JSON.stringify(rgb2hs(this.serviceData.red, this.serviceData.green, this.serviceData.blue))}`)
213
213
 
214
214
  // Hue
215
215
  this.LightBulb.Hue = hue
@@ -221,36 +221,36 @@ export class StripLight extends deviceBase {
221
221
  }
222
222
 
223
223
  async openAPIparseStatus(): Promise<void> {
224
- await this.debugLog('openAPIparseStatus')
225
- await this.debugLog(`(power, brightness, color) = API:(${this.deviceStatus.power}, ${this.deviceStatus.brightness}, ${this.deviceStatus.color}), current:(${this.LightBulb.On}, ${this.LightBulb.Brightness}, ${this.LightBulb.Hue}, ${this.LightBulb.Saturation})`)
224
+ this.debugLog('openAPIparseStatus')
225
+ this.debugLog(`(power, brightness, color) = API:(${this.deviceStatus.power}, ${this.deviceStatus.brightness}, ${this.deviceStatus.color}), current:(${this.LightBulb.On}, ${this.LightBulb.Brightness}, ${this.LightBulb.Hue}, ${this.LightBulb.Saturation})`)
226
226
 
227
227
  // On
228
228
  this.LightBulb.On = this.deviceStatus.power === 'on'
229
- await this.debugLog(`On: ${this.LightBulb.On}`)
229
+ this.debugLog(`On: ${this.LightBulb.On}`)
230
230
 
231
231
  // Brightness
232
232
  this.LightBulb.Brightness = this.deviceStatus.brightness
233
- await this.debugLog(`Brightness: ${this.LightBulb.Brightness}`)
233
+ this.debugLog(`Brightness: ${this.LightBulb.Brightness}`)
234
234
 
235
235
  // Color, Hue & Brightness
236
- await this.debugLog(`color: ${JSON.stringify(this.deviceStatus.color)}`)
236
+ this.debugLog(`color: ${JSON.stringify(this.deviceStatus.color)}`)
237
237
  const [red, green, blue] = this.deviceStatus.color.split(':')
238
- await this.debugLog(`red: ${JSON.stringify(red)}, green: ${JSON.stringify(green)}, blue: ${JSON.stringify(blue)}`)
238
+ this.debugLog(`red: ${JSON.stringify(red)}, green: ${JSON.stringify(green)}, blue: ${JSON.stringify(blue)}`)
239
239
  const [hue, saturation] = rgb2hs(red, green, blue)
240
- await this.debugLog(`hs: ${JSON.stringify(rgb2hs(red, green, blue))}`)
240
+ this.debugLog(`hs: ${JSON.stringify(rgb2hs(red, green, blue))}`)
241
241
 
242
242
  // Hue
243
243
  this.LightBulb.Hue = hue
244
- await this.debugLog(`Hue: ${this.LightBulb.Hue}`)
244
+ this.debugLog(`Hue: ${this.LightBulb.Hue}`)
245
245
 
246
246
  // Saturation
247
247
  this.LightBulb.Saturation = saturation
248
- await this.debugLog(`Saturation: ${this.LightBulb.Saturation}`)
248
+ this.debugLog(`Saturation: ${this.LightBulb.Saturation}`)
249
249
 
250
250
  // Firmware Version
251
251
  if (this.deviceStatus.version) {
252
252
  const version = this.deviceStatus.version.toString()
253
- await this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`)
253
+ this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`)
254
254
  const deviceVersion = version.replace(/^V|-.*$/g, '') ?? '0.0.0'
255
255
  this.accessory
256
256
  .getService(this.hap.Service.AccessoryInformation)!
@@ -259,36 +259,36 @@ export class StripLight extends deviceBase {
259
259
  .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
260
260
  .updateValue(deviceVersion)
261
261
  this.accessory.context.version = deviceVersion
262
- await this.debugSuccessLog(`version: ${this.accessory.context.version}`)
262
+ this.debugSuccessLog(`version: ${this.accessory.context.version}`)
263
263
  }
264
264
  }
265
265
 
266
266
  async parseStatusWebhook(): Promise<void> {
267
- await this.debugLog('parseStatusWebhook')
268
- await this.debugLog(`(powerState, brightness, color) = Webhook:(${this.webhookContext.powerState}, ${this.webhookContext.brightness}, ${this.webhookContext.color}), current:(${this.LightBulb.On}, ${this.LightBulb.Brightness}, ${this.LightBulb.Hue}, ${this.LightBulb.Saturation})`)
267
+ this.debugLog('parseStatusWebhook')
268
+ this.debugLog(`(powerState, brightness, color) = Webhook:(${this.webhookContext.powerState}, ${this.webhookContext.brightness}, ${this.webhookContext.color}), current:(${this.LightBulb.On}, ${this.LightBulb.Brightness}, ${this.LightBulb.Hue}, ${this.LightBulb.Saturation})`)
269
269
 
270
270
  // On
271
271
  this.LightBulb.On = this.webhookContext.powerState === 'ON'
272
- await this.debugLog(`On: ${this.LightBulb.On}`)
272
+ this.debugLog(`On: ${this.LightBulb.On}`)
273
273
 
274
274
  // Brightness
275
275
  this.LightBulb.Brightness = this.webhookContext.brightness
276
- await this.debugLog(`Brightness: ${this.LightBulb.Brightness}`)
276
+ this.debugLog(`Brightness: ${this.LightBulb.Brightness}`)
277
277
 
278
278
  // Color, Hue & Brightness
279
- await this.debugLog(`color: ${JSON.stringify(this.webhookContext.color)}`)
279
+ this.debugLog(`color: ${JSON.stringify(this.webhookContext.color)}`)
280
280
  const [red, green, blue] = this.webhookContext.color.split(':')
281
- await this.debugLog(`red: ${JSON.stringify(red)}, green: ${JSON.stringify(green)}, blue: ${JSON.stringify(blue)}`)
281
+ this.debugLog(`red: ${JSON.stringify(red)}, green: ${JSON.stringify(green)}, blue: ${JSON.stringify(blue)}`)
282
282
  const [hue, saturation] = rgb2hs(red, green, blue)
283
- await this.debugLog(`hs: ${JSON.stringify(rgb2hs(red, green, blue))}`)
283
+ this.debugLog(`hs: ${JSON.stringify(rgb2hs(red, green, blue))}`)
284
284
 
285
285
  // Hue
286
286
  this.LightBulb.Hue = hue
287
- await this.debugLog(`Hue: ${this.LightBulb.Hue}`)
287
+ this.debugLog(`Hue: ${this.LightBulb.Hue}`)
288
288
 
289
289
  // Saturation
290
290
  this.LightBulb.Saturation = saturation
291
- await this.debugLog(`Saturation: ${this.LightBulb.Saturation}`)
291
+ this.debugLog(`Saturation: ${this.LightBulb.Saturation}`)
292
292
  }
293
293
 
294
294
  /**
@@ -296,19 +296,19 @@ export class StripLight extends deviceBase {
296
296
  */
297
297
  async refreshStatus(): Promise<void> {
298
298
  if (!this.device.enableCloudService && this.OpenAPI) {
299
- await this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
299
+ this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
300
300
  } else if (this.BLE) {
301
301
  await this.BLERefreshStatus()
302
302
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
303
303
  await this.openAPIRefreshStatus()
304
304
  } else {
305
305
  await this.offlineOff()
306
- await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`)
306
+ this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`)
307
307
  }
308
308
  }
309
309
 
310
310
  async BLERefreshStatus(): Promise<void> {
311
- await this.debugLog('BLERefreshStatus')
311
+ this.debugLog('BLERefreshStatus')
312
312
  const switchBotBLE = await this.switchbotBLE()
313
313
  if (switchBotBLE === undefined) {
314
314
  await this.BLERefreshConnection(switchBotBLE)
@@ -323,7 +323,7 @@ export class StripLight extends deviceBase {
323
323
  await this.BLEparseStatus()
324
324
  await this.updateHomeKitCharacteristics()
325
325
  } else {
326
- await this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
326
+ this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
327
327
  await this.BLERefreshConnection(switchBotBLE)
328
328
  }
329
329
  })()
@@ -331,67 +331,67 @@ export class StripLight extends deviceBase {
331
331
  }
332
332
 
333
333
  async registerPlatformBLE(): Promise<void> {
334
- await this.debugLog('registerPlatformBLE')
334
+ this.debugLog('registerPlatformBLE')
335
335
  if (this.config.options?.BLE) {
336
- await this.debugLog('is listening to Platform BLE.')
336
+ this.debugLog('is listening to Platform BLE.')
337
337
  try {
338
338
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId)
339
339
  this.device.bleMac = formattedDeviceId
340
- await this.debugLog(`bleMac: ${this.device.bleMac}`)
340
+ this.debugLog(`bleMac: ${this.device.bleMac}`)
341
341
  this.platform.bleEventHandler[this.device.bleMac] = async (context: stripLightServiceData) => {
342
342
  try {
343
- await this.debugLog(`received BLE: ${JSON.stringify(context)}`)
343
+ this.debugLog(`received BLE: ${JSON.stringify(context)}`)
344
344
  this.serviceData = context
345
345
  await this.BLEparseStatus()
346
346
  await this.updateHomeKitCharacteristics()
347
347
  } catch (e: any) {
348
- await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
348
+ this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
349
349
  }
350
350
  }
351
351
  } catch (error) {
352
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
352
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
353
353
  }
354
354
  } else {
355
- await this.debugLog('is not listening to Platform BLE')
355
+ this.debugLog('is not listening to Platform BLE')
356
356
  }
357
357
  }
358
358
 
359
359
  async openAPIRefreshStatus(): Promise<void> {
360
- await this.debugLog('openAPIRefreshStatus')
360
+ this.debugLog('openAPIRefreshStatus')
361
361
  try {
362
- const { body } = await this.deviceRefreshStatus()
363
- const deviceStatus: any = await body
364
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
362
+ const response = await this.deviceRefreshStatus()
363
+ const deviceStatus: any = response.body
364
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
365
365
  if (await this.successfulStatusCodes(deviceStatus)) {
366
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
366
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
367
367
  this.deviceStatus = deviceStatus.body
368
368
  await this.openAPIparseStatus()
369
369
  await this.updateHomeKitCharacteristics()
370
370
  } else {
371
- await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
372
- await this.debugWarnLog(deviceStatus)
371
+ this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
372
+ this.debugWarnLog(deviceStatus)
373
373
  }
374
374
  } catch (e: any) {
375
375
  await this.apiError(e)
376
- await this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
376
+ this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
377
377
  }
378
378
  }
379
379
 
380
380
  async registerWebhook() {
381
381
  if (this.device.webhook) {
382
- await this.debugLog('is listening webhook.')
382
+ this.debugLog('is listening webhook.')
383
383
  this.platform.webhookEventHandler[this.device.deviceId] = async (context: stripLightWebhookContext) => {
384
384
  try {
385
- await this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
385
+ this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
386
386
  this.webhookContext = context
387
387
  await this.parseStatusWebhook()
388
388
  await this.updateHomeKitCharacteristics()
389
389
  } catch (e: any) {
390
- await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
390
+ this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
391
391
  }
392
392
  }
393
393
  } else {
394
- await this.debugLog('is not listening webhook.')
394
+ this.debugLog('is not listening webhook.')
395
395
  }
396
396
  }
397
397
 
@@ -412,36 +412,36 @@ export class StripLight extends deviceBase {
412
412
  await this.BLEpushChanges()
413
413
  if (this.LightBulb.On) {
414
414
  // Push Brightness Update
415
- await this.debugLog(`Brightness: ${this.LightBulb.Brightness}`)
415
+ this.debugLog(`Brightness: ${this.LightBulb.Brightness}`)
416
416
  await this.BLEpushBrightnessChanges()
417
417
  // Push Hue & Saturation Update
418
- await this.debugLog(`Hue: ${this.LightBulb.Hue}, Saturation: ${this.LightBulb.Saturation}`)
418
+ this.debugLog(`Hue: ${this.LightBulb.Hue}, Saturation: ${this.LightBulb.Saturation}`)
419
419
  await this.BLEpushRGBChanges()
420
420
  // Set ColorTemperature
421
421
  if (this.LightBulb.ColorTemperature !== this.accessory.context.ColorTemperature) {
422
422
  const kelvin = Math.round(1000000 / Number(this.LightBulb.ColorTemperature))
423
423
  this.accessory.context.kelvin = kelvin
424
424
  } else {
425
- await this.debugLog(`No pushColorTemperatureChanges, ColorTemperature: ${this.LightBulb.ColorTemperature}, ColorTemperatureCached: ${this.accessory.context.ColorTemperature}`)
425
+ this.debugLog(`No pushColorTemperatureChanges, ColorTemperature: ${this.LightBulb.ColorTemperature}, ColorTemperatureCached: ${this.accessory.context.ColorTemperature}`)
426
426
  }
427
427
  } else {
428
- await this.debugLog('BLE (Brightness), (Hue), & (Saturation) changes will not happen, as the device is OFF.')
428
+ this.debugLog('BLE (Brightness), (Hue), & (Saturation) changes will not happen, as the device is OFF.')
429
429
  }
430
430
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
431
431
  await this.openAPIpushChanges()
432
432
  if (this.LightBulb.On) {
433
433
  // Push Brightness Update
434
- await this.debugLog(`Brightness: ${this.LightBulb.Brightness}`)
434
+ this.debugLog(`Brightness: ${this.LightBulb.Brightness}`)
435
435
  await this.pushBrightnessChanges()
436
436
  // Push Hue & Saturation Update
437
- await this.debugLog(`Hue: ${this.LightBulb.Hue}, Saturation: ${this.LightBulb.Saturation}`)
437
+ this.debugLog(`Hue: ${this.LightBulb.Hue}, Saturation: ${this.LightBulb.Saturation}`)
438
438
  await this.pushHueSaturationChanges()
439
439
  } else {
440
- await this.debugLog('openAPI (Brightness), (ColorTemperature), (Hue), & (Saturation) changes will not happen, as the device is OFF.')
440
+ this.debugLog('openAPI (Brightness), (ColorTemperature), (Hue), & (Saturation) changes will not happen, as the device is OFF.')
441
441
  }
442
442
  } else {
443
443
  await this.offlineOff()
444
- await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, pushChanges will not happen.`)
444
+ this.debugWarnLog(`Connection Type: ${this.device.connectionType}, pushChanges will not happen.`)
445
445
  }
446
446
  // Refresh the status from the API
447
447
  interval(15000)
@@ -453,22 +453,22 @@ export class StripLight extends deviceBase {
453
453
  }
454
454
 
455
455
  async BLEpushChanges(): Promise<void> {
456
- await this.debugLog('BLEpushChanges')
456
+ this.debugLog('BLEpushChanges')
457
457
  if (this.LightBulb.On !== this.accessory.context.On) {
458
- await this.debugLog(`BLEpushChanges On: ${this.LightBulb.On}, OnCached: ${this.accessory.context.On}`)
458
+ this.debugLog(`BLEpushChanges On: ${this.LightBulb.On}, OnCached: ${this.accessory.context.On}`)
459
459
  const switchBotBLE = await this.platform.connectBLE(this.accessory, this.device)
460
460
  try {
461
461
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId)
462
462
  this.device.bleMac = formattedDeviceId
463
- await this.debugLog(`bleMac: ${this.device.bleMac}`)
463
+ this.debugLog(`bleMac: ${this.device.bleMac}`)
464
464
  if (switchBotBLE !== false) {
465
465
  switchBotBLE
466
466
  .discover({ model: this.device.bleModel, id: this.device.bleMac })
467
467
  .then(async (device_list: SwitchbotDevice[]) => {
468
468
  const deviceList = device_list as unknown as WoStrip[]
469
- await this.infoLog(`On: ${this.LightBulb.On}`)
469
+ this.infoLog(`On: ${this.LightBulb.On}`)
470
470
  return await this.retryBLE({
471
- max: await this.maxRetryBLE(),
471
+ max: this.maxRetryBLE(),
472
472
  fn: async () => {
473
473
  if (this.LightBulb.On) {
474
474
  return await deviceList[0].turnOn()
@@ -479,103 +479,103 @@ export class StripLight extends deviceBase {
479
479
  })
480
480
  })
481
481
  .then(async () => {
482
- await this.successLog(`On: ${this.LightBulb.On} sent over SwitchBot BLE, sent successfully`)
482
+ this.successLog(`On: ${this.LightBulb.On} sent over SwitchBot BLE, sent successfully`)
483
483
  await this.updateHomeKitCharacteristics()
484
484
  })
485
485
  .catch(async (e: any) => {
486
486
  await this.apiError(e)
487
- await this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
487
+ this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
488
488
  await this.BLEPushConnection()
489
489
  })
490
490
  } else {
491
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`)
491
+ this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`)
492
492
  await this.BLEPushConnection()
493
493
  }
494
494
  } catch (error) {
495
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
495
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
496
496
  }
497
497
  } else {
498
- await this.debugLog(`No changes (BLEpushChanges), On: ${this.LightBulb.On}, OnCached: ${this.accessory.context.On}`)
498
+ this.debugLog(`No changes (BLEpushChanges), On: ${this.LightBulb.On}, OnCached: ${this.accessory.context.On}`)
499
499
  }
500
500
  }
501
501
 
502
502
  async BLEpushBrightnessChanges(): Promise<void> {
503
- await this.debugLog('BLEpushBrightnessChanges')
503
+ this.debugLog('BLEpushBrightnessChanges')
504
504
  if (this.LightBulb.Brightness !== this.accessory.context.Brightness) {
505
505
  const switchBotBLE = await this.platform.connectBLE(this.accessory, this.device)
506
506
  try {
507
507
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId)
508
508
  this.device.bleMac = formattedDeviceId
509
- await this.debugLog(`bleMac: ${this.device.bleMac}`)
509
+ this.debugLog(`bleMac: ${this.device.bleMac}`)
510
510
  if (switchBotBLE !== false) {
511
511
  switchBotBLE
512
512
  .discover({ model: this.device.bleModel, id: this.device.bleMac })
513
513
  .then(async (device_list: SwitchbotDevice[]) => {
514
- await this.infoLog(`Brightness: ${this.LightBulb.Brightness}`)
514
+ this.infoLog(`Brightness: ${this.LightBulb.Brightness}`)
515
515
  return await device_list[0].setBrightness(this.LightBulb.Brightness)
516
516
  })
517
517
  .then(async () => {
518
- await this.successLog(`Brightness: ${this.LightBulb.Brightness} sent over SwitchBot BLE, sent successfully`)
518
+ this.successLog(`Brightness: ${this.LightBulb.Brightness} sent over SwitchBot BLE, sent successfully`)
519
519
  await this.updateHomeKitCharacteristics()
520
520
  })
521
521
  .catch(async (e: any) => {
522
522
  await this.apiError(e)
523
- await this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
523
+ this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
524
524
  await this.BLEPushConnection()
525
525
  })
526
526
  } else {
527
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`)
527
+ this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`)
528
528
  await this.BLEPushConnection()
529
529
  }
530
530
  } catch (error) {
531
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
531
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
532
532
  }
533
533
  } else {
534
- await this.debugLog(`No changes (BLEpushBrightnessChanges), Brightness: ${this.LightBulb.Brightness}, BrightnessCached: ${this.accessory.context.Brightness}`)
534
+ this.debugLog(`No changes (BLEpushBrightnessChanges), Brightness: ${this.LightBulb.Brightness}, BrightnessCached: ${this.accessory.context.Brightness}`)
535
535
  }
536
536
  }
537
537
 
538
538
  async BLEpushRGBChanges(): Promise<void> {
539
- await this.debugLog('BLEpushRGBChanges')
539
+ this.debugLog('BLEpushRGBChanges')
540
540
  if ((this.LightBulb.Hue !== this.accessory.context.Hue) || (this.LightBulb.Saturation !== this.accessory.context.Saturation)) {
541
- await this.debugLog(`Hue: ${JSON.stringify(this.LightBulb.Hue)}, Saturation: ${JSON.stringify(this.LightBulb.Saturation)}`)
541
+ this.debugLog(`Hue: ${JSON.stringify(this.LightBulb.Hue)}, Saturation: ${JSON.stringify(this.LightBulb.Saturation)}`)
542
542
  const [red, green, blue] = hs2rgb(this.LightBulb.Hue, this.LightBulb.Saturation)
543
- await this.debugLog(`rgb: ${JSON.stringify([red, green, blue])}`)
543
+ this.debugLog(`rgb: ${JSON.stringify([red, green, blue])}`)
544
544
  const switchBotBLE = await this.platform.connectBLE(this.accessory, this.device)
545
545
  try {
546
546
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId)
547
547
  this.device.bleMac = formattedDeviceId
548
- await this.debugLog(`bleMac: ${this.device.bleMac}`)
548
+ this.debugLog(`bleMac: ${this.device.bleMac}`)
549
549
  if (switchBotBLE !== false) {
550
550
  switchBotBLE
551
551
  .discover({ model: this.device.bleModel, id: this.device.bleMac })
552
552
  .then(async (device_list: SwitchbotDevice[]) => {
553
- await this.infoLog(`RGB: ${(this.LightBulb.Brightness, red, green, blue)}`)
553
+ this.infoLog(`RGB: ${(this.LightBulb.Brightness, red, green, blue)}`)
554
554
  return await device_list[0].setRGB(this.LightBulb.Brightness, red, green, blue)
555
555
  })
556
556
  .then(async () => {
557
- await this.successLog(`RGB: ${(this.LightBulb.Brightness, red, green, blue)} sent over SwitchBot BLE, sent successfully`)
557
+ this.successLog(`RGB: ${(this.LightBulb.Brightness, red, green, blue)} sent over SwitchBot BLE, sent successfully`)
558
558
  await this.updateHomeKitCharacteristics()
559
559
  })
560
560
  .catch(async (e: any) => {
561
561
  await this.apiError(e)
562
- await this.errorLog(`failed BLEpushRGBChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
562
+ this.errorLog(`failed BLEpushRGBChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
563
563
  await this.BLEPushConnection()
564
564
  })
565
565
  } else {
566
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`)
566
+ this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`)
567
567
  await this.BLEPushConnection()
568
568
  }
569
569
  } catch (error) {
570
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
570
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
571
571
  }
572
572
  } else {
573
- await this.debugLog(`No changes (BLEpushRGBChanges), Hue: ${this.LightBulb.Hue}, HueCached: ${this.accessory.context.Hue}, Saturation: ${this.LightBulb.Saturation}, SaturationCached: ${this.accessory.context.Saturation}`)
573
+ this.debugLog(`No changes (BLEpushRGBChanges), Hue: ${this.LightBulb.Hue}, HueCached: ${this.accessory.context.Hue}, Saturation: ${this.LightBulb.Saturation}, SaturationCached: ${this.accessory.context.Saturation}`)
574
574
  }
575
575
  }
576
576
 
577
577
  async openAPIpushChanges() {
578
- await this.debugLog('openAPIpushChanges')
578
+ this.debugLog('openAPIpushChanges')
579
579
  if (this.LightBulb.On !== this.accessory.context.On) {
580
580
  const command = this.LightBulb.On ? 'turnOn' : 'turnOff'
581
581
  const bodyChange: bodyChange = {
@@ -583,82 +583,82 @@ export class StripLight extends deviceBase {
583
583
  parameter: 'default',
584
584
  commandType: 'command',
585
585
  }
586
- await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
586
+ this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
587
587
  try {
588
- const { body } = await this.pushChangeRequest(bodyChange)
589
- const deviceStatus: any = await body
590
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
588
+ const response = await this.pushChangeRequest(bodyChange)
589
+ const deviceStatus: any = response.body
590
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
591
591
  if (await this.successfulStatusCodes(deviceStatus)) {
592
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
592
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
593
593
  await this.updateHomeKitCharacteristics()
594
594
  } else {
595
595
  await this.statusCode(deviceStatus.statusCode)
596
596
  }
597
597
  } catch (e: any) {
598
598
  await this.apiError(e)
599
- await this.errorLog(`failed openAPIpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
599
+ this.errorLog(`failed openAPIpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
600
600
  }
601
601
  } else {
602
- await this.debugLog(`No changes (openAPIpushChanges), On: ${this.LightBulb.On}, OnCached: ${this.accessory.context.On}`)
602
+ this.debugLog(`No changes (openAPIpushChanges), On: ${this.LightBulb.On}, OnCached: ${this.accessory.context.On}`)
603
603
  }
604
604
  }
605
605
 
606
606
  async pushHueSaturationChanges(): Promise<void> {
607
- await this.debugLog('pushHueSaturationChanges')
607
+ this.debugLog('pushHueSaturationChanges')
608
608
  if ((this.LightBulb.Hue !== this.accessory.context.Hue) || (this.LightBulb.Saturation !== this.accessory.context.Saturation)) {
609
- await this.debugLog(`Hue: ${JSON.stringify(this.LightBulb.Hue)}, Saturation: ${JSON.stringify(this.LightBulb.Saturation)}`)
609
+ this.debugLog(`Hue: ${JSON.stringify(this.LightBulb.Hue)}, Saturation: ${JSON.stringify(this.LightBulb.Saturation)}`)
610
610
  const [red, green, blue] = hs2rgb(this.LightBulb.Hue, this.LightBulb.Saturation)
611
- await this.debugLog(`rgb: ${JSON.stringify([red, green, blue])}`)
611
+ this.debugLog(`rgb: ${JSON.stringify([red, green, blue])}`)
612
612
  const bodyChange: bodyChange = {
613
613
  command: 'setColor',
614
614
  parameter: `${red}:${green}:${blue}`,
615
615
  commandType: 'command',
616
616
  }
617
- await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
617
+ this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
618
618
  try {
619
- const { body } = await this.pushChangeRequest(bodyChange)
620
- const deviceStatus: any = await body
621
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
619
+ const response = await this.pushChangeRequest(bodyChange)
620
+ const deviceStatus: any = response.body
621
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
622
622
  if (await this.successfulStatusCodes(deviceStatus)) {
623
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
623
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
624
624
  await this.updateHomeKitCharacteristics()
625
625
  } else {
626
626
  await this.statusCode(deviceStatus.statusCode)
627
627
  }
628
628
  } catch (e: any) {
629
629
  await this.apiError(e)
630
- await this.errorLog(`failed pushHueSaturationChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
630
+ this.errorLog(`failed pushHueSaturationChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
631
631
  }
632
632
  } else {
633
- await this.debugLog(`No changes (pushHueSaturationChanges), Hue: ${this.LightBulb.Hue}, HueCached: ${this.accessory.context.Hue}, Saturation: ${this.LightBulb.Saturation}, SaturationCached: ${this.accessory.context.Saturation}`)
633
+ this.debugLog(`No changes (pushHueSaturationChanges), Hue: ${this.LightBulb.Hue}, HueCached: ${this.accessory.context.Hue}, Saturation: ${this.LightBulb.Saturation}, SaturationCached: ${this.accessory.context.Saturation}`)
634
634
  }
635
635
  }
636
636
 
637
637
  async pushBrightnessChanges(): Promise<void> {
638
- await this.debugLog('pushBrightnessChanges')
638
+ this.debugLog('pushBrightnessChanges')
639
639
  if (this.LightBulb.Brightness !== this.accessory.context.Brightness) {
640
640
  const bodyChange: bodyChange = {
641
641
  command: 'setBrightness',
642
642
  parameter: `${this.LightBulb.Brightness}`,
643
643
  commandType: 'command',
644
644
  }
645
- await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
645
+ this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
646
646
  try {
647
- const { body } = await this.pushChangeRequest(bodyChange)
648
- const deviceStatus: any = await body
649
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
647
+ const response = await this.pushChangeRequest(bodyChange)
648
+ const deviceStatus: any = response.body
649
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
650
650
  if (await this.successfulStatusCodes(deviceStatus)) {
651
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
651
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
652
652
  await this.updateHomeKitCharacteristics()
653
653
  } else {
654
654
  await this.statusCode(deviceStatus.statusCode)
655
655
  }
656
656
  } catch (e: any) {
657
657
  await this.apiError(e)
658
- await this.errorLog(`failed pushBrightnessChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
658
+ this.errorLog(`failed pushBrightnessChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
659
659
  }
660
660
  } else {
661
- await this.debugLog(`No changes (pushBrightnessChanges), Brightness: ${this.LightBulb.Brightness}, BrightnessCached: ${this.accessory.context.Brightness}`)
661
+ this.debugLog(`No changes (pushBrightnessChanges), Brightness: ${this.LightBulb.Brightness}, BrightnessCached: ${this.accessory.context.Brightness}`)
662
662
  }
663
663
  }
664
664
 
@@ -667,9 +667,9 @@ export class StripLight extends deviceBase {
667
667
  */
668
668
  async OnSet(value: CharacteristicValue): Promise<void> {
669
669
  if (this.LightBulb.On !== this.accessory.context.On) {
670
- await this.infoLog(`Set On: ${value}`)
670
+ this.infoLog(`Set On: ${value}`)
671
671
  } else {
672
- await this.debugLog(`No Changes, On: ${value}`)
672
+ this.debugLog(`No Changes, On: ${value}`)
673
673
  }
674
674
 
675
675
  this.LightBulb.On = value
@@ -681,7 +681,7 @@ export class StripLight extends deviceBase {
681
681
  */
682
682
  async BrightnessSet(value: CharacteristicValue): Promise<void> {
683
683
  if (this.LightBulb.On && (this.LightBulb.Brightness !== this.accessory.context.Brightness)) {
684
- await this.infoLog(`Set Brightness: ${value}`)
684
+ this.infoLog(`Set Brightness: ${value}`)
685
685
  } else {
686
686
  if (this.LightBulb.On) {
687
687
  this.debugLog(`No Changes, Brightness: ${value}`)
@@ -784,7 +784,7 @@ export class StripLight extends deviceBase {
784
784
  async getAdaptiveLightingSettings(accessory: PlatformAccessory, device: device & devicesConfig): Promise<void> {
785
785
  // Adaptive Lighting
786
786
  this.adaptiveLighting = accessory.context.adaptiveLighting ?? true
787
- await this.debugLog(`adaptiveLighting: ${this.adaptiveLighting}`)
787
+ this.debugLog(`adaptiveLighting: ${this.adaptiveLighting}`)
788
788
  // Adaptive Lighting Shift
789
789
  this.adaptiveLightingShift = (device as stripLightConfig).adaptiveLightingShift ?? 0
790
790
  this.debugLog(`adaptiveLightingShift: ${this.adaptiveLightingShift}`)
@@ -792,15 +792,15 @@ export class StripLight extends deviceBase {
792
792
 
793
793
  async BLEPushConnection() {
794
794
  if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
795
- await this.warnLog('Using OpenAPI Connection to Push Changes')
795
+ this.warnLog('Using OpenAPI Connection to Push Changes')
796
796
  await this.openAPIpushChanges()
797
797
  }
798
798
  }
799
799
 
800
800
  async BLERefreshConnection(switchbot: any): Promise<void> {
801
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`)
801
+ this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`)
802
802
  if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
803
- await this.warnLog('Using OpenAPI Connection to Refresh Status')
803
+ this.warnLog('Using OpenAPI Connection to Refresh Status')
804
804
  await this.openAPIRefreshStatus()
805
805
  }
806
806
  }