@switchbot/homebridge-switchbot 4.1.1-beta.0 → 4.1.1-beta.10

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 (104) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/config.schema.json +2 -2
  3. package/dist/device/blindtilt.js +104 -104
  4. package/dist/device/blindtilt.js.map +1 -1
  5. package/dist/device/bot.js +86 -86
  6. package/dist/device/bot.js.map +1 -1
  7. package/dist/device/ceilinglight.js +98 -98
  8. package/dist/device/ceilinglight.js.map +1 -1
  9. package/dist/device/colorbulb.js +140 -140
  10. package/dist/device/colorbulb.js.map +1 -1
  11. package/dist/device/contact.js +47 -47
  12. package/dist/device/contact.js.map +1 -1
  13. package/dist/device/curtain.d.ts +1 -1
  14. package/dist/device/curtain.d.ts.map +1 -1
  15. package/dist/device/curtain.js +95 -93
  16. package/dist/device/curtain.js.map +1 -1
  17. package/dist/device/device.d.ts +13 -13
  18. package/dist/device/device.d.ts.map +1 -1
  19. package/dist/device/device.js +46 -46
  20. package/dist/device/device.js.map +1 -1
  21. package/dist/device/fan.js +96 -96
  22. package/dist/device/fan.js.map +1 -1
  23. package/dist/device/hub.js +46 -46
  24. package/dist/device/hub.js.map +1 -1
  25. package/dist/device/humidifier.d.ts.map +1 -1
  26. package/dist/device/humidifier.js +85 -87
  27. package/dist/device/humidifier.js.map +1 -1
  28. package/dist/device/iosensor.js +44 -44
  29. package/dist/device/iosensor.js.map +1 -1
  30. package/dist/device/lightstrip.js +119 -119
  31. package/dist/device/lightstrip.js.map +1 -1
  32. package/dist/device/lock.js +75 -75
  33. package/dist/device/lock.js.map +1 -1
  34. package/dist/device/meter.js +44 -44
  35. package/dist/device/meter.js.map +1 -1
  36. package/dist/device/meterplus.js +42 -42
  37. package/dist/device/meterplus.js.map +1 -1
  38. package/dist/device/meterpro.js +42 -42
  39. package/dist/device/meterpro.js.map +1 -1
  40. package/dist/device/motion.js +44 -44
  41. package/dist/device/motion.js.map +1 -1
  42. package/dist/device/plug.d.ts.map +1 -1
  43. package/dist/device/plug.js +60 -60
  44. package/dist/device/plug.js.map +1 -1
  45. package/dist/device/robotvacuumcleaner.js +74 -74
  46. package/dist/device/robotvacuumcleaner.js.map +1 -1
  47. package/dist/device/waterdetector.d.ts.map +1 -1
  48. package/dist/device/waterdetector.js +54 -56
  49. package/dist/device/waterdetector.js.map +1 -1
  50. package/dist/irdevice/airconditioner.js +31 -31
  51. package/dist/irdevice/airconditioner.js.map +1 -1
  52. package/dist/irdevice/airpurifier.js +10 -10
  53. package/dist/irdevice/airpurifier.js.map +1 -1
  54. package/dist/irdevice/camera.js +9 -9
  55. package/dist/irdevice/camera.js.map +1 -1
  56. package/dist/irdevice/fan.js +11 -11
  57. package/dist/irdevice/fan.js.map +1 -1
  58. package/dist/irdevice/irdevice.js +11 -11
  59. package/dist/irdevice/irdevice.js.map +1 -1
  60. package/dist/irdevice/light.js +9 -9
  61. package/dist/irdevice/light.js.map +1 -1
  62. package/dist/irdevice/other.js +93 -93
  63. package/dist/irdevice/other.js.map +1 -1
  64. package/dist/irdevice/tv.js +33 -33
  65. package/dist/irdevice/tv.js.map +1 -1
  66. package/dist/irdevice/vacuumcleaner.js +9 -9
  67. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  68. package/dist/irdevice/waterheater.js +9 -9
  69. package/dist/irdevice/waterheater.js.map +1 -1
  70. package/dist/platform.js +228 -228
  71. package/dist/platform.js.map +1 -1
  72. package/docs/functions/default.html +1 -1
  73. package/package.json +9 -9
  74. package/src/device/blindtilt.ts +104 -104
  75. package/src/device/bot.ts +86 -86
  76. package/src/device/ceilinglight.ts +98 -98
  77. package/src/device/colorbulb.ts +140 -140
  78. package/src/device/contact.ts +47 -47
  79. package/src/device/curtain.ts +95 -93
  80. package/src/device/device.ts +46 -46
  81. package/src/device/fan.ts +96 -96
  82. package/src/device/hub.ts +46 -46
  83. package/src/device/humidifier.ts +85 -87
  84. package/src/device/iosensor.ts +44 -44
  85. package/src/device/lightstrip.ts +119 -119
  86. package/src/device/lock.ts +75 -75
  87. package/src/device/meter.ts +44 -44
  88. package/src/device/meterplus.ts +42 -42
  89. package/src/device/meterpro.ts +42 -42
  90. package/src/device/motion.ts +44 -44
  91. package/src/device/plug.ts +62 -62
  92. package/src/device/robotvacuumcleaner.ts +74 -74
  93. package/src/device/waterdetector.ts +54 -55
  94. package/src/irdevice/airconditioner.ts +31 -31
  95. package/src/irdevice/airpurifier.ts +10 -10
  96. package/src/irdevice/camera.ts +9 -9
  97. package/src/irdevice/fan.ts +11 -11
  98. package/src/irdevice/irdevice.ts +11 -11
  99. package/src/irdevice/light.ts +9 -9
  100. package/src/irdevice/other.ts +93 -93
  101. package/src/irdevice/tv.ts +33 -33
  102. package/src/irdevice/vacuumcleaner.ts +9 -9
  103. package/src/irdevice/waterheater.ts +9 -9
  104. package/src/platform.ts +228 -228
@@ -156,59 +156,59 @@ export class RobotVacuumCleaner extends deviceBase {
156
156
  await this.pushChanges()
157
157
  } catch (e: any) {
158
158
  await this.apiError(e)
159
- await this.errorLog(`failed pushChanges with ${device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
159
+ this.errorLog(`failed pushChanges with ${device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
160
160
  }
161
161
  this.robotVacuumCleanerUpdateInProgress = false
162
162
  })
163
163
  }
164
164
 
165
165
  async BLEparseStatus(): Promise<void> {
166
- await this.debugLog('BLEparseStatus')
167
- await this.debugLog(`(state, battery) = BLE: (${this.serviceData.state}, ${this.serviceData.battery}), current: (${this.LightBulb.On}, ${this.Battery.BatteryLevel})`)
166
+ this.debugLog('BLEparseStatus')
167
+ this.debugLog(`(state, battery) = BLE: (${this.serviceData.state}, ${this.serviceData.battery}), current: (${this.LightBulb.On}, ${this.Battery.BatteryLevel})`)
168
168
 
169
169
  // On
170
170
  this.LightBulb.On = !!['InDustCollecting', 'Clearing'].includes(this.deviceStatus.workingStatus)
171
- await this.debugLog(`On: ${this.LightBulb.On}`)
171
+ this.debugLog(`On: ${this.LightBulb.On}`)
172
172
 
173
173
  // BatteryLevel
174
174
  this.Battery.BatteryLevel = this.serviceData.battery
175
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
175
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
176
176
 
177
177
  // StatusLowBattery
178
178
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
179
179
  ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
180
180
  : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
181
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
181
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
182
182
  }
183
183
 
184
184
  async openAPIparseStatus() {
185
- await this.debugLog('openAPIparseStatus')
186
- await this.debugLog(`(onlineStatus, battery, workingStatus) = API: (${this.deviceStatus.onlineStatus}, ${this.deviceStatus.battery}, ${this.deviceStatus.workingStatus}), current: (${this.LightBulb.On}, ${this.Battery.BatteryLevel}, ${this.Battery.ChargingState})`)
185
+ this.debugLog('openAPIparseStatus')
186
+ this.debugLog(`(onlineStatus, battery, workingStatus) = API: (${this.deviceStatus.onlineStatus}, ${this.deviceStatus.battery}, ${this.deviceStatus.workingStatus}), current: (${this.LightBulb.On}, ${this.Battery.BatteryLevel}, ${this.Battery.ChargingState})`)
187
187
 
188
188
  // On
189
189
  this.LightBulb.On = this.deviceStatus.onlineStatus === 'online'
190
- await this.debugLog(`On: ${this.LightBulb.On}`)
190
+ this.debugLog(`On: ${this.LightBulb.On}`)
191
191
 
192
192
  // BatteryLevel
193
193
  this.Battery.BatteryLevel = this.deviceStatus.battery
194
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
194
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
195
195
 
196
196
  // StatusLowBattery
197
197
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
198
198
  ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
199
199
  : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
200
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
200
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
201
201
 
202
202
  // ChargingState
203
203
  this.Battery.ChargingState = this.deviceStatus.workingStatus === 'Charging'
204
204
  ? this.hap.Characteristic.ChargingState.CHARGING
205
205
  : this.hap.Characteristic.ChargingState.NOT_CHARGING
206
- await this.debugLog(`ChargingState: ${this.Battery.ChargingState}`)
206
+ this.debugLog(`ChargingState: ${this.Battery.ChargingState}`)
207
207
 
208
208
  // Firmware Version
209
209
  if (this.deviceStatus.version) {
210
210
  const version = this.deviceStatus.version.toString()
211
- await this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`)
211
+ this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`)
212
212
  const deviceVersion = version.replace(/^V|-.*$/g, '') ?? '0.0.0'
213
213
  this.accessory
214
214
  .getService(this.hap.Service.AccessoryInformation)!
@@ -217,33 +217,33 @@ export class RobotVacuumCleaner extends deviceBase {
217
217
  .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
218
218
  .updateValue(deviceVersion)
219
219
  this.accessory.context.version = deviceVersion
220
- await this.debugSuccessLog(`version: ${this.accessory.context.version}`)
220
+ this.debugSuccessLog(`version: ${this.accessory.context.version}`)
221
221
  }
222
222
  }
223
223
 
224
224
  async parseStatusWebhook(): Promise<void> {
225
- await this.debugLog('parseStatusWebhook')
226
- await this.debugLog(`(onlineStatus, battery, workingStatus) = Webhook: (${this.webhookContext.onlineStatus}, ${this.webhookContext.battery}, ${this.webhookContext.workingStatus}), current: (${this.LightBulb.On}, ${this.Battery.BatteryLevel}, ${this.Battery.ChargingState})`)
225
+ this.debugLog('parseStatusWebhook')
226
+ this.debugLog(`(onlineStatus, battery, workingStatus) = Webhook: (${this.webhookContext.onlineStatus}, ${this.webhookContext.battery}, ${this.webhookContext.workingStatus}), current: (${this.LightBulb.On}, ${this.Battery.BatteryLevel}, ${this.Battery.ChargingState})`)
227
227
 
228
228
  // On
229
229
  this.LightBulb.On = this.webhookContext.onlineStatus === 'online'
230
- await this.debugLog(`On: ${this.LightBulb.On}`)
230
+ this.debugLog(`On: ${this.LightBulb.On}`)
231
231
 
232
232
  // BatteryLevel
233
233
  this.Battery.BatteryLevel = this.webhookContext.battery
234
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
234
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
235
235
 
236
236
  // StatusLowBattery
237
237
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
238
238
  ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
239
239
  : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
240
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
240
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
241
241
 
242
242
  // ChargingState
243
243
  this.Battery.ChargingState = this.webhookContext.workingStatus === 'Charging'
244
244
  ? this.hap.Characteristic.ChargingState.CHARGING
245
245
  : this.hap.Characteristic.ChargingState.NOT_CHARGING
246
- await this.debugLog(`ChargingState: ${this.Battery.ChargingState}`)
246
+ this.debugLog(`ChargingState: ${this.Battery.ChargingState}`)
247
247
  }
248
248
 
249
249
  /**
@@ -251,19 +251,19 @@ export class RobotVacuumCleaner extends deviceBase {
251
251
  */
252
252
  async refreshStatus(): Promise<void> {
253
253
  if (!this.device.enableCloudService && this.OpenAPI) {
254
- await this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
254
+ this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
255
255
  } else if (this.BLE) {
256
256
  await this.BLERefreshStatus()
257
257
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
258
258
  await this.openAPIRefreshStatus()
259
259
  } else {
260
260
  await this.offlineOff()
261
- await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`)
261
+ this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`)
262
262
  }
263
263
  }
264
264
 
265
265
  async BLERefreshStatus(): Promise<void> {
266
- await this.debugLog('BLERefreshStatus')
266
+ this.debugLog('BLERefreshStatus')
267
267
  const switchBotBLE = await this.switchbotBLE()
268
268
  if (switchBotBLE === undefined) {
269
269
  await this.BLERefreshConnection(switchBotBLE)
@@ -278,7 +278,7 @@ export class RobotVacuumCleaner extends deviceBase {
278
278
  await this.BLEparseStatus()
279
279
  await this.updateHomeKitCharacteristics()
280
280
  } else {
281
- await this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
281
+ this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
282
282
  await this.BLERefreshConnection(switchBotBLE)
283
283
  }
284
284
  })()
@@ -286,67 +286,67 @@ export class RobotVacuumCleaner extends deviceBase {
286
286
  }
287
287
 
288
288
  async registerPlatformBLE(): Promise<void> {
289
- await this.debugLog('registerPlatformBLE')
289
+ this.debugLog('registerPlatformBLE')
290
290
  if (this.config.options?.BLE) {
291
- await this.debugLog('is listening to Platform BLE.')
291
+ this.debugLog('is listening to Platform BLE.')
292
292
  try {
293
293
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId)
294
294
  this.device.bleMac = formattedDeviceId
295
- await this.debugLog(`bleMac: ${this.device.bleMac}`)
295
+ this.debugLog(`bleMac: ${this.device.bleMac}`)
296
296
  this.platform.bleEventHandler[this.device.bleMac] = async (context: robotVacuumCleanerServiceData) => {
297
297
  try {
298
- await this.debugLog(`received BLE: ${JSON.stringify(context)}`)
298
+ this.debugLog(`received BLE: ${JSON.stringify(context)}`)
299
299
  this.serviceData = context
300
300
  await this.BLEparseStatus()
301
301
  await this.updateHomeKitCharacteristics()
302
302
  } catch (e: any) {
303
- await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
303
+ this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
304
304
  }
305
305
  }
306
306
  } catch (error) {
307
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
307
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
308
308
  }
309
309
  } else {
310
- await this.debugLog('is not listening to Platform BLE')
310
+ this.debugLog('is not listening to Platform BLE')
311
311
  }
312
312
  }
313
313
 
314
314
  async openAPIRefreshStatus(): Promise<void> {
315
- await this.debugLog('openAPIRefreshStatus')
315
+ this.debugLog('openAPIRefreshStatus')
316
316
  try {
317
- const { body } = await this.deviceRefreshStatus()
318
- const deviceStatus: any = await body
319
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
317
+ const response = await this.deviceRefreshStatus()
318
+ const deviceStatus: any = response.body
319
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
320
320
  if (await this.successfulStatusCodes(deviceStatus)) {
321
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
321
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
322
322
  this.deviceStatus = deviceStatus.body
323
323
  await this.openAPIparseStatus()
324
324
  await this.updateHomeKitCharacteristics()
325
325
  } else {
326
- await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
327
- await this.debugWarnLog(deviceStatus)
326
+ this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
327
+ this.debugWarnLog(deviceStatus)
328
328
  }
329
329
  } catch (e: any) {
330
330
  await this.apiError(e)
331
- await this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
331
+ this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
332
332
  }
333
333
  }
334
334
 
335
335
  async registerWebhook() {
336
336
  if (this.device.webhook) {
337
- await this.debugLog('is listening webhook.')
337
+ this.debugLog('is listening webhook.')
338
338
  this.platform.webhookEventHandler[this.device.deviceId] = async (context: robotVacuumCleanerS1WebhookContext | robotVacuumCleanerS1PlusWebhookContext | floorCleaningRobotS10WebhookContext) => {
339
339
  try {
340
- await this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
340
+ this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
341
341
  this.webhookContext = context
342
342
  await this.parseStatusWebhook()
343
343
  await this.updateHomeKitCharacteristics()
344
344
  } catch (e: any) {
345
- await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
345
+ this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
346
346
  }
347
347
  }
348
348
  } else {
349
- await this.debugLog('is not listening webhook.')
349
+ this.debugLog('is not listening webhook.')
350
350
  }
351
351
  }
352
352
 
@@ -360,14 +360,14 @@ export class RobotVacuumCleaner extends deviceBase {
360
360
  */
361
361
  async pushChanges(): Promise<void> {
362
362
  if (!this.device.enableCloudService && this.OpenAPI) {
363
- await this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`)
363
+ this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`)
364
364
  } else if (this.BLE) {
365
365
  await this.BLEpushChanges()
366
366
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
367
367
  await this.openAPIpushChanges()
368
368
  } else {
369
369
  await this.offlineOff()
370
- await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, pushChanges will not happen.`)
370
+ this.debugWarnLog(`Connection Type: ${this.device.connectionType}, pushChanges will not happen.`)
371
371
  }
372
372
  // Refresh the status from the API
373
373
  interval(15000)
@@ -379,21 +379,21 @@ export class RobotVacuumCleaner extends deviceBase {
379
379
  }
380
380
 
381
381
  async BLEpushChanges(): Promise<void> {
382
- await this.debugLog('BLEpushChanges')
382
+ this.debugLog('BLEpushChanges')
383
383
  if (this.LightBulb.On !== this.accessory.context.On) {
384
384
  const switchBotBLE = await this.platform.connectBLE(this.accessory, this.device)
385
385
  try {
386
386
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId)
387
387
  this.device.bleMac = formattedDeviceId
388
- await this.debugLog(`bleMac: ${this.device.bleMac}`)
388
+ this.debugLog(`bleMac: ${this.device.bleMac}`)
389
389
  if (switchBotBLE !== false) {
390
390
  switchBotBLE
391
391
  .discover({ model: this.device.bleModel, id: this.device.bleMac })
392
392
  .then(async (device_list: SwitchbotDevice[]) => {
393
393
  const deviceList = device_list as unknown as SwitchbotDevice[]
394
- await this.infoLog(`On: ${this.LightBulb.On}`)
394
+ this.infoLog(`On: ${this.LightBulb.On}`)
395
395
  return await this.retryBLE({
396
- max: await this.maxRetryBLE(),
396
+ max: this.maxRetryBLE(),
397
397
  fn: async () => {
398
398
  if (this.LightBulb.On) {
399
399
  return await deviceList[0].turnOn()
@@ -404,28 +404,28 @@ export class RobotVacuumCleaner extends deviceBase {
404
404
  })
405
405
  })
406
406
  .then(async () => {
407
- await this.successLog(`On: ${this.LightBulb.On} sent over SwitchBot BLE, sent successfully`)
407
+ this.successLog(`On: ${this.LightBulb.On} sent over SwitchBot BLE, sent successfully`)
408
408
  await this.updateHomeKitCharacteristics()
409
409
  })
410
410
  .catch(async (e: any) => {
411
411
  await this.apiError(e)
412
- await this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
412
+ this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
413
413
  await this.BLEPushConnection()
414
414
  })
415
415
  } else {
416
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`)
416
+ this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`)
417
417
  await this.BLEPushConnection()
418
418
  }
419
419
  } catch (error) {
420
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
420
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
421
421
  }
422
422
  } else {
423
- await this.debugLog(`No changes (BLEpushChanges), On: ${this.LightBulb.On}, OnCached: ${this.accessory.context.On}`)
423
+ this.debugLog(`No changes (BLEpushChanges), On: ${this.LightBulb.On}, OnCached: ${this.accessory.context.On}`)
424
424
  }
425
425
  }
426
426
 
427
427
  async openAPIpushChanges() {
428
- await this.debugLog('openAPIpushChanges')
428
+ this.debugLog('openAPIpushChanges')
429
429
  if (this.LightBulb.On !== this.accessory.context.On) {
430
430
  const command = this.LightBulb.On ? 'start' : 'dock'
431
431
  const bodyChange: bodyChange = {
@@ -433,28 +433,28 @@ export class RobotVacuumCleaner extends deviceBase {
433
433
  parameter: 'default',
434
434
  commandType: 'command',
435
435
  }
436
- await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
436
+ this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
437
437
  try {
438
- const { body } = await this.pushChangeRequest(bodyChange)
439
- const deviceStatus: any = await body
440
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
438
+ const response = await this.pushChangeRequest(bodyChange)
439
+ const deviceStatus: any = response.body
440
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
441
441
  if (await this.successfulStatusCodes(deviceStatus)) {
442
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
442
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
443
443
  await this.updateHomeKitCharacteristics()
444
444
  } else {
445
445
  await this.statusCode(deviceStatus.statusCode)
446
446
  }
447
447
  } catch (e: any) {
448
448
  await this.apiError(e)
449
- await this.errorLog(`failed openAPIpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
449
+ this.errorLog(`failed openAPIpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
450
450
  }
451
451
  } else {
452
- await this.debugLog(`No changes (openAPIpushChanges), On: ${this.LightBulb.On}, OnCached: ${this.accessory.context.On}`)
452
+ this.debugLog(`No changes (openAPIpushChanges), On: ${this.LightBulb.On}, OnCached: ${this.accessory.context.On}`)
453
453
  }
454
454
  }
455
455
 
456
456
  async openAPIpushBrightnessChanges() {
457
- await this.debugLog('openAPIpushBrightnessChanges')
457
+ this.debugLog('openAPIpushBrightnessChanges')
458
458
  if (this.LightBulb.Brightness !== this.accessory.context.Brightness) {
459
459
  const command = this.LightBulb.Brightness === 0 ? 'dock' : 'PowLevel'
460
460
  const parameter = this.LightBulb.Brightness === 25
@@ -469,23 +469,23 @@ export class RobotVacuumCleaner extends deviceBase {
469
469
  parameter: `${parameter}`,
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 (openAPIpushBrightnessChanges), Brightness: ${this.LightBulb.Brightness}, BrightnessCached: ${this.accessory.context.Brightness}`)
488
+ this.debugLog(`No changes (openAPIpushBrightnessChanges), Brightness: ${this.LightBulb.Brightness}, BrightnessCached: ${this.accessory.context.Brightness}`)
489
489
  }
490
490
  }
491
491
 
@@ -508,7 +508,7 @@ export class RobotVacuumCleaner extends deviceBase {
508
508
  */
509
509
  async BrightnessSet(value: CharacteristicValue): Promise<void> {
510
510
  if (this.LightBulb.On && (this.LightBulb.Brightness !== this.accessory.context.Brightness)) {
511
- await this.infoLog(`Set Brightness: ${value}`)
511
+ this.infoLog(`Set Brightness: ${value}`)
512
512
  } else {
513
513
  if (this.LightBulb.On) {
514
514
  this.debugLog(`No Changes, Brightness: ${value}`)
@@ -536,15 +536,15 @@ export class RobotVacuumCleaner extends deviceBase {
536
536
 
537
537
  async BLEPushConnection() {
538
538
  if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
539
- await this.warnLog('Using OpenAPI Connection to Push Changes')
539
+ this.warnLog('Using OpenAPI Connection to Push Changes')
540
540
  await this.openAPIpushChanges()
541
541
  }
542
542
  }
543
543
 
544
544
  async BLERefreshConnection(switchbot: any): Promise<void> {
545
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`)
545
+ this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`)
546
546
  if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
547
- await this.warnLog('Using OpenAPI Connection to Refresh Status')
547
+ this.warnLog('Using OpenAPI Connection to Refresh Status')
548
548
  await this.openAPIRefreshStatus()
549
549
  }
550
550
  }