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