@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
@@ -169,63 +169,63 @@ export class Meter extends deviceBase {
169
169
  }
170
170
 
171
171
  async BLEparseStatus(): Promise<void> {
172
- await this.debugLog('BLEparseStatus')
173
- await this.debugLog(`(scale, temperature, humidity) = BLE:(${this.serviceData.fahrenheit}, ${this.serviceData.celsius}, ${this.serviceData.humidity}), current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity})`)
172
+ this.debugLog('BLEparseStatus')
173
+ this.debugLog(`(scale, temperature, humidity) = BLE:(${this.serviceData.fahrenheit}, ${this.serviceData.celsius}, ${this.serviceData.humidity}), current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity})`)
174
174
 
175
175
  // CurrentRelativeHumidity
176
176
  if (!(this.device as meterConfig).hide_humidity && this.HumiditySensor?.Service) {
177
177
  this.HumiditySensor.CurrentRelativeHumidity = validHumidity(this.serviceData.humidity, 0, 100)
178
- await this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}%`)
178
+ this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}%`)
179
179
  }
180
180
 
181
181
  // Current Temperature
182
182
  if (!(this.device as meterConfig).hide_temperature && this.TemperatureSensor?.Service) {
183
183
  const CELSIUS = this.serviceData.celsius < 0 ? 0 : this.serviceData.celsius > 100 ? 100 : this.serviceData.celsius
184
184
  this.TemperatureSensor.CurrentTemperature = CELSIUS
185
- await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}°c`)
185
+ this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}°c`)
186
186
  }
187
187
 
188
188
  // BatteryLevel
189
189
  this.Battery.BatteryLevel = this.serviceData.battery
190
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
190
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
191
191
 
192
192
  // StatusLowBattery
193
193
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
194
194
  ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
195
195
  : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
196
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
196
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
197
197
  }
198
198
 
199
199
  async openAPIparseStatus(): Promise<void> {
200
- await this.debugLog('openAPIparseStatus')
201
- await this.debugLog(`(battery, temperature, humidity) = OpenAPI:(${this.deviceStatus.battery}, ${this.deviceStatus.temperature}, ${this.deviceStatus.humidity}), current:(${this.Battery?.BatteryLevel}, ${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity})`)
200
+ this.debugLog('openAPIparseStatus')
201
+ this.debugLog(`(battery, temperature, humidity) = OpenAPI:(${this.deviceStatus.battery}, ${this.deviceStatus.temperature}, ${this.deviceStatus.humidity}), current:(${this.Battery?.BatteryLevel}, ${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity})`)
202
202
 
203
203
  // CurrentRelativeHumidity
204
204
  if (!(this.device as meterConfig).hide_humidity && this.HumiditySensor?.Service) {
205
205
  this.HumiditySensor.CurrentRelativeHumidity = this.deviceStatus.humidity
206
- await this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}%`)
206
+ this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}%`)
207
207
  }
208
208
 
209
209
  // CurrentTemperature
210
210
  if (!(this.device as meterConfig).hide_temperature && this.TemperatureSensor?.Service) {
211
211
  this.TemperatureSensor.CurrentTemperature = this.deviceStatus.temperature
212
- await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}°c`)
212
+ this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}°c`)
213
213
  }
214
214
 
215
215
  // BatteryLevel
216
216
  this.Battery.BatteryLevel = this.deviceStatus.battery
217
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
217
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
218
218
 
219
219
  // StatusLowBattery
220
220
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
221
221
  ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
222
222
  : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
223
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
223
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
224
224
 
225
225
  // FirmwareVersion
226
226
  if (this.deviceStatus.version) {
227
227
  const version = this.deviceStatus.version.toString()
228
- await this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`)
228
+ this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`)
229
229
  const deviceVersion = version.replace(/^V|-.*$/g, '') ?? '0.0.0'
230
230
  this.accessory
231
231
  .getService(this.hap.Service.AccessoryInformation)!
@@ -234,28 +234,28 @@ export class Meter extends deviceBase {
234
234
  .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
235
235
  .updateValue(deviceVersion)
236
236
  this.accessory.context.version = deviceVersion
237
- await this.debugSuccessLog(`version: ${this.accessory.context.version}`)
237
+ this.debugSuccessLog(`version: ${this.accessory.context.version}`)
238
238
  }
239
239
  }
240
240
 
241
241
  async parseStatusWebhook(): Promise<void> {
242
- await this.debugLog('parseStatusWebhook')
243
- await this.debugLog(`(scale, temperature, humidity) = Webhook:(${this.webhookContext.scale}, ${convertUnits(this.webhookContext.temperature, this.webhookContext.scale, (this.device as meterConfig).convertUnitTo)}, ${this.webhookContext.humidity}), current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity})`)
242
+ this.debugLog('parseStatusWebhook')
243
+ this.debugLog(`(scale, temperature, humidity) = Webhook:(${this.webhookContext.scale}, ${convertUnits(this.webhookContext.temperature, this.webhookContext.scale, (this.device as meterConfig).convertUnitTo)}, ${this.webhookContext.humidity}), current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity})`)
244
244
  // Check if the scale is not CELSIUS
245
245
  if (this.webhookContext.scale !== 'CELSIUS' && (this.device as meterConfig).convertUnitTo === undefined) {
246
- await this.warnLog(`received a non-CELSIUS Webhook scale: ${this.webhookContext.scale}, Use the *convertUnitsTo* config under Hub settings, if displaying incorrectly in HomeKit.`)
246
+ this.warnLog(`received a non-CELSIUS Webhook scale: ${this.webhookContext.scale}, Use the *convertUnitsTo* config under Hub settings, if displaying incorrectly in HomeKit.`)
247
247
  }
248
248
 
249
249
  // CurrentRelativeHumidity
250
250
  if (!(this.device as meterConfig).hide_humidity && this.HumiditySensor?.Service) {
251
251
  this.HumiditySensor.CurrentRelativeHumidity = this.webhookContext.humidity
252
- await this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}`)
252
+ this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}`)
253
253
  }
254
254
 
255
255
  // CurrentTemperature
256
256
  if (!(this.device as meterConfig).hide_temperature && this.TemperatureSensor?.Service) {
257
257
  this.TemperatureSensor.CurrentTemperature = convertUnits(this.webhookContext.temperature, this.webhookContext.scale, (this.device as meterConfig).convertUnitTo)
258
- await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`)
258
+ this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`)
259
259
  }
260
260
  }
261
261
 
@@ -264,19 +264,19 @@ export class Meter extends deviceBase {
264
264
  */
265
265
  async refreshStatus(): Promise<void> {
266
266
  if (!this.device.enableCloudService && this.OpenAPI) {
267
- await this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
267
+ this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
268
268
  } else if (this.BLE) {
269
269
  await this.BLERefreshStatus()
270
270
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
271
271
  await this.openAPIRefreshStatus()
272
272
  } else {
273
273
  await this.offlineOff()
274
- await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`)
274
+ this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`)
275
275
  }
276
276
  }
277
277
 
278
278
  async BLERefreshStatus(): Promise<void> {
279
- await this.debugLog('BLERefreshStatus')
279
+ this.debugLog('BLERefreshStatus')
280
280
  const switchBotBLE = await this.switchbotBLE()
281
281
  if (switchBotBLE === undefined) {
282
282
  await this.BLERefreshConnection(switchBotBLE)
@@ -291,7 +291,7 @@ export class Meter extends deviceBase {
291
291
  await this.BLEparseStatus()
292
292
  await this.updateHomeKitCharacteristics()
293
293
  } else {
294
- await this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
294
+ this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
295
295
  await this.BLERefreshConnection(switchBotBLE)
296
296
  }
297
297
  })()
@@ -299,67 +299,67 @@ export class Meter extends deviceBase {
299
299
  }
300
300
 
301
301
  async registerPlatformBLE(): Promise<void> {
302
- await this.debugLog('registerPlatformBLE')
302
+ this.debugLog('registerPlatformBLE')
303
303
  if (this.config.options?.BLE) {
304
- await this.debugLog('is listening to Platform BLE.')
304
+ this.debugLog('is listening to Platform BLE.')
305
305
  try {
306
306
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId)
307
307
  this.device.bleMac = formattedDeviceId
308
- await this.debugLog(`bleMac: ${this.device.bleMac}`)
308
+ this.debugLog(`bleMac: ${this.device.bleMac}`)
309
309
  this.platform.bleEventHandler[this.device.bleMac] = async (context: meterServiceData) => {
310
310
  try {
311
- await this.debugLog(`received BLE: ${JSON.stringify(context)}`)
311
+ this.debugLog(`received BLE: ${JSON.stringify(context)}`)
312
312
  this.serviceData = context
313
313
  await this.BLEparseStatus()
314
314
  await this.updateHomeKitCharacteristics()
315
315
  } catch (e: any) {
316
- await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
316
+ this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
317
317
  }
318
318
  }
319
319
  } catch (error) {
320
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
320
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
321
321
  }
322
322
  } else {
323
- await this.debugLog('is not listening to Platform BLE')
323
+ this.debugLog('is not listening to Platform BLE')
324
324
  }
325
325
  }
326
326
 
327
327
  async openAPIRefreshStatus(): Promise<void> {
328
- await this.debugLog('openAPIRefreshStatus')
328
+ this.debugLog('openAPIRefreshStatus')
329
329
  try {
330
- const { body } = await this.deviceRefreshStatus()
331
- const deviceStatus: any = await body
332
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
330
+ const response = await this.deviceRefreshStatus()
331
+ const deviceStatus: any = response.body
332
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
333
333
  if (await this.successfulStatusCodes(deviceStatus)) {
334
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
334
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
335
335
  this.deviceStatus = deviceStatus.body
336
336
  await this.openAPIparseStatus()
337
337
  await this.updateHomeKitCharacteristics()
338
338
  } else {
339
- await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
340
- await this.debugWarnLog(deviceStatus)
339
+ this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
340
+ this.debugWarnLog(deviceStatus)
341
341
  }
342
342
  } catch (e: any) {
343
343
  await this.apiError(e)
344
- await this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
344
+ this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
345
345
  }
346
346
  }
347
347
 
348
348
  async registerWebhook() {
349
349
  if (this.device.webhook) {
350
- await this.debugLog('is listening webhook.')
350
+ this.debugLog('is listening webhook.')
351
351
  this.platform.webhookEventHandler[this.device.deviceId] = async (context: meterWebhookContext) => {
352
352
  try {
353
- await this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
353
+ this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
354
354
  this.webhookContext = context
355
355
  await this.parseStatusWebhook()
356
356
  await this.updateHomeKitCharacteristics()
357
357
  } catch (e: any) {
358
- await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
358
+ this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
359
359
  }
360
360
  }
361
361
  } else {
362
- await this.debugLog('is not listening webhook.')
362
+ this.debugLog('is not listening webhook.')
363
363
  }
364
364
  }
365
365
 
@@ -382,9 +382,9 @@ export class Meter extends deviceBase {
382
382
  }
383
383
 
384
384
  async BLERefreshConnection(switchbot: any): Promise<void> {
385
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`)
385
+ this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`)
386
386
  if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
387
- await this.warnLog('Using OpenAPI Connection to Refresh Status')
387
+ this.warnLog('Using OpenAPI Connection to Refresh Status')
388
388
  await this.openAPIRefreshStatus()
389
389
  }
390
390
  }
@@ -174,55 +174,55 @@ export class MeterPlus extends deviceBase {
174
174
  }
175
175
 
176
176
  async BLEparseStatus(): Promise<void> {
177
- await this.debugLog('BLEparseStatus')
178
- await this.debugLog(`(temperature, humidity) = BLE:(${this.serviceData.celsius}, ${this.serviceData.humidity}), current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity})`)
177
+ this.debugLog('BLEparseStatus')
178
+ this.debugLog(`(temperature, humidity) = BLE:(${this.serviceData.celsius}, ${this.serviceData.humidity}), current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity})`)
179
179
 
180
180
  // CurrentRelativeHumidity
181
181
  if (!(this.device as meterConfig).hide_humidity && this.HumiditySensor?.Service) {
182
182
  this.HumiditySensor.CurrentRelativeHumidity = validHumidity(this.serviceData.humidity, 0, 100)
183
- await this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}%`)
183
+ this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}%`)
184
184
  }
185
185
  // Current Temperature
186
186
  if (!(this.device as meterConfig).hide_temperature && this.TemperatureSensor?.Service) {
187
187
  const CELSIUS = this.serviceData.celsius < 0 ? 0 : this.serviceData.celsius > 100 ? 100 : this.serviceData.celsius
188
188
  this.TemperatureSensor.CurrentTemperature = CELSIUS
189
- await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}°c`)
189
+ this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}°c`)
190
190
  }
191
191
  // BatteryLevel
192
192
  this.Battery.BatteryLevel = this.serviceData.battery
193
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
193
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
194
194
  // StatusLowBattery
195
195
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
196
196
  ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
197
197
  : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
198
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
198
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
199
199
  }
200
200
 
201
201
  async openAPIparseStatus(): Promise<void> {
202
- await this.debugLog('openAPIparseStatus')
203
- await this.debugLog(`(temperature, humidity) = OpenAPI:(${this.deviceStatus.temperature}, ${this.deviceStatus.humidity}), current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity})`)
202
+ this.debugLog('openAPIparseStatus')
203
+ this.debugLog(`(temperature, humidity) = OpenAPI:(${this.deviceStatus.temperature}, ${this.deviceStatus.humidity}), current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity})`)
204
204
 
205
205
  // CurrentRelativeHumidity
206
206
  if (!(this.device as meterConfig).hide_humidity && this.HumiditySensor?.Service) {
207
207
  this.HumiditySensor.CurrentRelativeHumidity = this.deviceStatus.humidity
208
- await this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}%`)
208
+ this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}%`)
209
209
  }
210
210
 
211
211
  // CurrentTemperature
212
212
  if (!(this.device as meterConfig).hide_temperature && this.TemperatureSensor?.Service) {
213
213
  this.TemperatureSensor.CurrentTemperature = this.deviceStatus.temperature
214
- await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}°c`)
214
+ this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}°c`)
215
215
  }
216
216
 
217
217
  // BatteryLevel
218
218
  this.Battery.BatteryLevel = this.deviceStatus.battery
219
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
219
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
220
220
 
221
221
  // StatusLowBattery
222
222
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
223
223
  ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
224
224
  : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
225
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
225
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
226
226
 
227
227
  // FirmwareVersion
228
228
  if (this.deviceStatus.version) {
@@ -241,23 +241,23 @@ export class MeterPlus extends deviceBase {
241
241
  }
242
242
 
243
243
  async parseStatusWebhook(): Promise<void> {
244
- await this.debugLog('parseStatusWebhook')
245
- await this.debugLog(`(scale, temperature, humidity) = Webhook:(${this.webhookContext.scale}, ${convertUnits(this.webhookContext.temperature, this.webhookContext.scale, (this.device as meterConfig).convertUnitTo)}, ${this.webhookContext.humidity}) current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity})`)
244
+ this.debugLog('parseStatusWebhook')
245
+ this.debugLog(`(scale, temperature, humidity) = Webhook:(${this.webhookContext.scale}, ${convertUnits(this.webhookContext.temperature, this.webhookContext.scale, (this.device as meterConfig).convertUnitTo)}, ${this.webhookContext.humidity}) current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity})`)
246
246
  // Check if the scale is not CELSIUS
247
247
  if (this.webhookContext.scale !== 'CELSIUS' && (this.device as meterConfig).convertUnitTo === undefined) {
248
- await this.warnLog(`received a non-CELSIUS Webhook scale: ${this.webhookContext.scale}, Use the *convertUnitsTo* config under Hub settings, if displaying incorrectly in HomeKit.`)
248
+ this.warnLog(`received a non-CELSIUS Webhook scale: ${this.webhookContext.scale}, Use the *convertUnitsTo* config under Hub settings, if displaying incorrectly in HomeKit.`)
249
249
  }
250
250
 
251
251
  // CurrentRelativeHumidity
252
252
  if (!(this.device as meterConfig).hide_humidity && this.HumiditySensor?.Service) {
253
253
  this.HumiditySensor.CurrentRelativeHumidity = this.webhookContext.humidity
254
- await this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}`)
254
+ this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}`)
255
255
  }
256
256
 
257
257
  // CurrentTemperature
258
258
  if (!(this.device as meterConfig).hide_temperature && this.TemperatureSensor?.Service) {
259
259
  this.TemperatureSensor.CurrentTemperature = convertUnits(this.webhookContext.temperature, this.webhookContext.scale, (this.device as meterConfig).convertUnitTo)
260
- await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`)
260
+ this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`)
261
261
  }
262
262
  }
263
263
 
@@ -266,19 +266,19 @@ export class MeterPlus extends deviceBase {
266
266
  */
267
267
  async refreshStatus(): Promise<void> {
268
268
  if (!this.device.enableCloudService && this.OpenAPI) {
269
- await this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
269
+ this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
270
270
  } else if (this.BLE) {
271
271
  await this.BLERefreshStatus()
272
272
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
273
273
  await this.openAPIRefreshStatus()
274
274
  } else {
275
275
  await this.offlineOff()
276
- await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`)
276
+ this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`)
277
277
  }
278
278
  }
279
279
 
280
280
  async BLERefreshStatus(): Promise<void> {
281
- await this.debugLog('BLERefreshStatus')
281
+ this.debugLog('BLERefreshStatus')
282
282
  const switchBotBLE = await this.switchbotBLE()
283
283
  if (switchBotBLE === undefined) {
284
284
  await this.BLERefreshConnection(switchBotBLE)
@@ -293,7 +293,7 @@ export class MeterPlus extends deviceBase {
293
293
  await this.BLEparseStatus()
294
294
  await this.updateHomeKitCharacteristics()
295
295
  } else {
296
- await this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
296
+ this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
297
297
  await this.BLERefreshConnection(switchBotBLE)
298
298
  }
299
299
  })()
@@ -301,67 +301,67 @@ export class MeterPlus extends deviceBase {
301
301
  }
302
302
 
303
303
  async registerPlatformBLE(): Promise<void> {
304
- await this.debugLog('registerPlatformBLE')
304
+ this.debugLog('registerPlatformBLE')
305
305
  if (this.config.options?.BLE) {
306
- await this.debugLog('is listening to Platform BLE.')
306
+ this.debugLog('is listening to Platform BLE.')
307
307
  try {
308
308
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId)
309
309
  this.device.bleMac = formattedDeviceId
310
- await this.debugLog(`bleMac: ${this.device.bleMac}`)
310
+ this.debugLog(`bleMac: ${this.device.bleMac}`)
311
311
  this.platform.bleEventHandler[this.device.bleMac] = async (context: meterPlusServiceData) => {
312
312
  try {
313
- await this.debugLog(`received BLE: ${JSON.stringify(context)}`)
313
+ this.debugLog(`received BLE: ${JSON.stringify(context)}`)
314
314
  this.serviceData = context
315
315
  await this.BLEparseStatus()
316
316
  await this.updateHomeKitCharacteristics()
317
317
  } catch (e: any) {
318
- await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
318
+ this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
319
319
  }
320
320
  }
321
321
  } catch (error) {
322
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
322
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
323
323
  }
324
324
  } else {
325
- await this.debugLog('is not listening to Platform BLE')
325
+ this.debugLog('is not listening to Platform BLE')
326
326
  }
327
327
  }
328
328
 
329
329
  async openAPIRefreshStatus(): Promise<void> {
330
- await this.debugLog('openAPIRefreshStatus')
330
+ this.debugLog('openAPIRefreshStatus')
331
331
  try {
332
- const { body } = await this.deviceRefreshStatus()
333
- const deviceStatus: any = await body
334
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
332
+ const response = await this.deviceRefreshStatus()
333
+ const deviceStatus: any = response.body
334
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
335
335
  if (await this.successfulStatusCodes(deviceStatus)) {
336
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
336
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
337
337
  this.deviceStatus = deviceStatus.body
338
338
  await this.openAPIparseStatus()
339
339
  await this.updateHomeKitCharacteristics()
340
340
  } else {
341
- await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
342
- await this.debugWarnLog(deviceStatus)
341
+ this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
342
+ this.debugWarnLog(deviceStatus)
343
343
  }
344
344
  } catch (e: any) {
345
345
  await this.apiError(e)
346
- await this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
346
+ this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
347
347
  }
348
348
  }
349
349
 
350
350
  async registerWebhook() {
351
351
  if (this.device.webhook) {
352
- await this.debugLog('is listening webhook.')
352
+ this.debugLog('is listening webhook.')
353
353
  this.platform.webhookEventHandler[this.device.deviceId] = async (context: meterPlusWebhookContext) => {
354
354
  try {
355
- await this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
355
+ this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
356
356
  this.webhookContext = context
357
357
  await this.parseStatusWebhook()
358
358
  await this.updateHomeKitCharacteristics()
359
359
  } catch (e: any) {
360
- await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
360
+ this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
361
361
  }
362
362
  }
363
363
  } else {
364
- await this.debugLog('is not listening webhook.')
364
+ this.debugLog('is not listening webhook.')
365
365
  }
366
366
  }
367
367
 
@@ -384,9 +384,9 @@ export class MeterPlus extends deviceBase {
384
384
  }
385
385
 
386
386
  async BLERefreshConnection(switchbot: any): Promise<void> {
387
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`)
387
+ this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`)
388
388
  if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
389
- await this.warnLog('Using OpenAPI Connection to Refresh Status')
389
+ this.warnLog('Using OpenAPI Connection to Refresh Status')
390
390
  await this.openAPIRefreshStatus()
391
391
  }
392
392
  }