@switchbot/homebridge-switchbot 3.8.3-beta.30 → 3.8.3-beta.32

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 (80) hide show
  1. package/.github/workflows/release.yml +1 -1
  2. package/CHANGELOG.md +2 -1
  3. package/config.schema.json +24 -0
  4. package/dist/device/blindtilt.d.ts.map +1 -1
  5. package/dist/device/blindtilt.js +26 -23
  6. package/dist/device/blindtilt.js.map +1 -1
  7. package/dist/device/bot.d.ts.map +1 -1
  8. package/dist/device/bot.js +30 -22
  9. package/dist/device/bot.js.map +1 -1
  10. package/dist/device/ceilinglight.d.ts.map +1 -1
  11. package/dist/device/ceilinglight.js +18 -17
  12. package/dist/device/ceilinglight.js.map +1 -1
  13. package/dist/device/colorbulb.d.ts.map +1 -1
  14. package/dist/device/colorbulb.js +35 -32
  15. package/dist/device/colorbulb.js.map +1 -1
  16. package/dist/device/contact.js +11 -11
  17. package/dist/device/contact.js.map +1 -1
  18. package/dist/device/curtain.d.ts.map +1 -1
  19. package/dist/device/curtain.js +21 -20
  20. package/dist/device/curtain.js.map +1 -1
  21. package/dist/device/device.js +8 -8
  22. package/dist/device/device.js.map +1 -1
  23. package/dist/device/fan.d.ts.map +1 -1
  24. package/dist/device/fan.js +18 -17
  25. package/dist/device/fan.js.map +1 -1
  26. package/dist/device/hub.js +11 -11
  27. package/dist/device/hub.js.map +1 -1
  28. package/dist/device/humidifier.d.ts.map +1 -1
  29. package/dist/device/humidifier.js +17 -16
  30. package/dist/device/humidifier.js.map +1 -1
  31. package/dist/device/iosensor.js +11 -11
  32. package/dist/device/iosensor.js.map +1 -1
  33. package/dist/device/lightstrip.d.ts.map +1 -1
  34. package/dist/device/lightstrip.js +26 -25
  35. package/dist/device/lightstrip.js.map +1 -1
  36. package/dist/device/lock.d.ts.map +1 -1
  37. package/dist/device/lock.js +16 -16
  38. package/dist/device/lock.js.map +1 -1
  39. package/dist/device/meter.js +11 -11
  40. package/dist/device/meter.js.map +1 -1
  41. package/dist/device/meterplus.js +11 -11
  42. package/dist/device/meterplus.js.map +1 -1
  43. package/dist/device/motion.js +11 -11
  44. package/dist/device/motion.js.map +1 -1
  45. package/dist/device/plug.d.ts.map +1 -1
  46. package/dist/device/plug.js +18 -17
  47. package/dist/device/plug.js.map +1 -1
  48. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  49. package/dist/device/robotvacuumcleaner.js +18 -17
  50. package/dist/device/robotvacuumcleaner.js.map +1 -1
  51. package/dist/device/waterdetector.js +11 -11
  52. package/dist/device/waterdetector.js.map +1 -1
  53. package/dist/platform.d.ts.map +1 -1
  54. package/dist/platform.js +80 -76
  55. package/dist/platform.js.map +1 -1
  56. package/dist/settings.d.ts +3 -0
  57. package/dist/settings.d.ts.map +1 -1
  58. package/dist/settings.js.map +1 -1
  59. package/package.json +3 -3
  60. package/src/device/blindtilt.ts +29 -26
  61. package/src/device/bot.ts +34 -26
  62. package/src/device/ceilinglight.ts +20 -19
  63. package/src/device/colorbulb.ts +40 -37
  64. package/src/device/contact.ts +11 -11
  65. package/src/device/curtain.ts +25 -23
  66. package/src/device/device.ts +8 -8
  67. package/src/device/fan.ts +20 -19
  68. package/src/device/hub.ts +11 -11
  69. package/src/device/humidifier.ts +19 -18
  70. package/src/device/iosensor.ts +11 -11
  71. package/src/device/lightstrip.ts +30 -29
  72. package/src/device/lock.ts +18 -18
  73. package/src/device/meter.ts +11 -11
  74. package/src/device/meterplus.ts +11 -11
  75. package/src/device/motion.ts +11 -11
  76. package/src/device/plug.ts +20 -19
  77. package/src/device/robotvacuumcleaner.ts +20 -19
  78. package/src/device/waterdetector.ts +11 -11
  79. package/src/platform.ts +82 -78
  80. package/src/settings.ts +3 -0
@@ -146,7 +146,7 @@ export class MeterPlus extends deviceBase {
146
146
  this.debugLog('Retrieve initial values and update Homekit')
147
147
  this.refreshStatus()
148
148
  } catch (e: any) {
149
- this.errorLog(`failed to retrieve initial values and update Homekit, Error: ${e}`)
149
+ this.errorLog(`failed to retrieve initial values and update Homekit, Error: ${e.message ?? e}`)
150
150
  }
151
151
 
152
152
  // regisiter webhook event handler if enabled
@@ -154,7 +154,7 @@ export class MeterPlus extends deviceBase {
154
154
  this.debugLog('Registering Webhook Event Handler')
155
155
  this.registerWebhook()
156
156
  } catch (e: any) {
157
- this.errorLog(`failed to registerWebhook, Error: ${e}`)
157
+ this.errorLog(`failed to registerWebhook, Error: ${e.message ?? e}`)
158
158
  }
159
159
 
160
160
  // regisiter platform BLE event handler if enabled
@@ -162,7 +162,7 @@ export class MeterPlus extends deviceBase {
162
162
  this.debugLog('Registering Platform BLE Event Handler')
163
163
  this.registerPlatformBLE()
164
164
  } catch (e: any) {
165
- this.errorLog(`failed to registerPlatformBLE, Error: ${e}`)
165
+ this.errorLog(`failed to registerPlatformBLE, Error: ${e.message ?? e}`)
166
166
  }
167
167
 
168
168
  // Start an update interval
@@ -279,22 +279,22 @@ export class MeterPlus extends deviceBase {
279
279
 
280
280
  async BLERefreshStatus(): Promise<void> {
281
281
  await this.debugLog('BLERefreshStatus')
282
- const switchbot = await this.switchbotBLE()
283
- if (switchbot === undefined) {
284
- await this.BLERefreshConnection(switchbot)
282
+ const switchBotBLE = await this.switchbotBLE()
283
+ if (switchBotBLE === undefined) {
284
+ await this.BLERefreshConnection(switchBotBLE)
285
285
  } else {
286
286
  // Start to monitor advertisement packets
287
287
  (async () => {
288
288
  // Start to monitor advertisement packets
289
- const serviceData = await this.monitorAdvertisementPackets(switchbot) as meterPlusServiceData
289
+ const serviceData = await this.monitorAdvertisementPackets(switchBotBLE) as meterPlusServiceData
290
290
  // Update HomeKit
291
291
  if (serviceData.model === SwitchBotBLEModel.MeterPlus && serviceData.modelName === SwitchBotBLEModelName.MeterPlus) {
292
292
  this.serviceData = serviceData
293
293
  await this.BLEparseStatus()
294
294
  await this.updateHomeKitCharacteristics()
295
295
  } else {
296
- await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`)
297
- await this.BLERefreshConnection(switchbot)
296
+ await this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
297
+ await this.BLERefreshConnection(switchBotBLE)
298
298
  }
299
299
  })()
300
300
  }
@@ -315,7 +315,7 @@ export class MeterPlus extends deviceBase {
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}`)
318
+ await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
319
319
  }
320
320
  }
321
321
  } catch (error) {
@@ -357,7 +357,7 @@ export class MeterPlus extends deviceBase {
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}`)
360
+ await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
361
361
  }
362
362
  }
363
363
  } else {
@@ -130,7 +130,7 @@ export class Motion extends deviceBase {
130
130
  this.debugLog('Retrieve initial values and update Homekit')
131
131
  this.refreshStatus()
132
132
  } catch (e: any) {
133
- this.errorLog(`failed to retrieve initial values and update Homekit, Error: ${e}`)
133
+ this.errorLog(`failed to retrieve initial values and update Homekit, Error: ${e.message ?? e}`)
134
134
  }
135
135
 
136
136
  // regisiter webhook event handler if enabled
@@ -138,7 +138,7 @@ export class Motion extends deviceBase {
138
138
  this.debugLog('Registering Webhook Event Handler')
139
139
  this.registerWebhook()
140
140
  } catch (e: any) {
141
- this.errorLog(`failed to registerWebhook, Error: ${e}`)
141
+ this.errorLog(`failed to registerWebhook, Error: ${e.message ?? e}`)
142
142
  }
143
143
 
144
144
  // regisiter platform BLE event handler if enabled
@@ -146,7 +146,7 @@ export class Motion extends deviceBase {
146
146
  this.debugLog('Registering Platform BLE Event Handler')
147
147
  this.registerPlatformBLE()
148
148
  } catch (e: any) {
149
- this.errorLog(`failed to registerPlatformBLE, Error: ${e}`)
149
+ this.errorLog(`failed to registerPlatformBLE, Error: ${e.message ?? e}`)
150
150
  }
151
151
 
152
152
  // Start an update interval
@@ -254,22 +254,22 @@ export class Motion extends deviceBase {
254
254
 
255
255
  async BLERefreshStatus(): Promise<void> {
256
256
  await this.debugLog('BLERefreshStatus')
257
- const switchbot = await this.switchbotBLE()
258
- if (switchbot === undefined) {
259
- await this.BLERefreshConnection(switchbot)
257
+ const switchBotBLE = await this.switchbotBLE()
258
+ if (switchBotBLE === undefined) {
259
+ await this.BLERefreshConnection(switchBotBLE)
260
260
  } else {
261
261
  // Start to monitor advertisement packets
262
262
  (async () => {
263
263
  // Start to monitor advertisement packets
264
- const serviceData = await this.monitorAdvertisementPackets(switchbot) as motionSensorServiceData
264
+ const serviceData = await this.monitorAdvertisementPackets(switchBotBLE) as motionSensorServiceData
265
265
  // Update HomeKit
266
266
  if (serviceData.model === SwitchBotBLEModel.MotionSensor && serviceData.modelName === SwitchBotBLEModelName.MotionSensor) {
267
267
  this.serviceData = serviceData
268
268
  await this.BLEparseStatus()
269
269
  await this.updateHomeKitCharacteristics()
270
270
  } else {
271
- await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`)
272
- await this.BLERefreshConnection(switchbot)
271
+ await this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
272
+ await this.BLERefreshConnection(switchBotBLE)
273
273
  }
274
274
  })()
275
275
  }
@@ -290,7 +290,7 @@ export class Motion extends deviceBase {
290
290
  await this.BLEparseStatus()
291
291
  await this.updateHomeKitCharacteristics()
292
292
  } catch (e: any) {
293
- await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e}`)
293
+ await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
294
294
  }
295
295
  }
296
296
  } catch (error) {
@@ -332,7 +332,7 @@ export class Motion extends deviceBase {
332
332
  await this.parseStatusWebhook()
333
333
  await this.updateHomeKitCharacteristics()
334
334
  } catch (e: any) {
335
- await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e}`)
335
+ await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
336
336
  }
337
337
  }
338
338
  } else {
@@ -3,7 +3,7 @@
3
3
  * plug.ts: @switchbot/homebridge-switchbot.
4
4
  */
5
5
  import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'
6
- import type { bodyChange, device, plugMiniJPServiceData, plugMiniJPWebhookContext, plugMiniStatus, plugMiniUSServiceData, plugMiniUSWebhookContext, plugStatus, plugWebhookContext } from 'node-switchbot'
6
+ import type { bodyChange, device, plugMiniJPServiceData, plugMiniJPWebhookContext, plugMiniStatus, plugMiniUSServiceData, plugMiniUSWebhookContext, plugStatus, plugWebhookContext, SwitchbotDevice, WoPlugMini } from 'node-switchbot'
7
7
 
8
8
  import type { SwitchBotPlatform } from '../platform.js'
9
9
  import type { devicesConfig } from '../settings.js'
@@ -71,7 +71,7 @@ export class Plug extends deviceBase {
71
71
  this.debugLog('Retrieve initial values and update Homekit')
72
72
  this.refreshStatus()
73
73
  } catch (e: any) {
74
- this.errorLog(`failed to retrieve initial values and update Homekit, Error: ${e}`)
74
+ this.errorLog(`failed to retrieve initial values and update Homekit, Error: ${e.message ?? e}`)
75
75
  }
76
76
 
77
77
  // regisiter webhook event handler if enabled
@@ -79,7 +79,7 @@ export class Plug extends deviceBase {
79
79
  this.debugLog('Registering Webhook Event Handler')
80
80
  this.registerWebhook()
81
81
  } catch (e: any) {
82
- this.errorLog(`failed to registerWebhook, Error: ${e}`)
82
+ this.errorLog(`failed to registerWebhook, Error: ${e.message ?? e}`)
83
83
  }
84
84
 
85
85
  // regisiter platform BLE event handler if enabled
@@ -87,7 +87,7 @@ export class Plug extends deviceBase {
87
87
  this.debugLog('Registering Platform BLE Event Handler')
88
88
  this.registerPlatformBLE()
89
89
  } catch (e: any) {
90
- this.errorLog(`failed to registerPlatformBLE, Error: ${e}`)
90
+ this.errorLog(`failed to registerPlatformBLE, Error: ${e.message ?? e}`)
91
91
  }
92
92
 
93
93
  // Start an update interval
@@ -177,14 +177,14 @@ export class Plug extends deviceBase {
177
177
 
178
178
  async BLERefreshStatus(): Promise<void> {
179
179
  await this.debugLog('BLERefreshStatus')
180
- const switchbot = await this.switchbotBLE()
181
- if (switchbot === undefined) {
182
- await this.BLERefreshConnection(switchbot)
180
+ const switchBotBLE = await this.switchbotBLE()
181
+ if (switchBotBLE === undefined) {
182
+ await this.BLERefreshConnection(switchBotBLE)
183
183
  } else {
184
184
  // Start to monitor advertisement packets
185
185
  (async () => {
186
186
  // Start to monitor advertisement packets
187
- const serviceData = await this.monitorAdvertisementPackets(switchbot) as plugMiniUSServiceData | plugMiniJPServiceData
187
+ const serviceData = await this.monitorAdvertisementPackets(switchBotBLE) as plugMiniUSServiceData | plugMiniJPServiceData
188
188
  // Update HomeKit
189
189
  if ((serviceData.model === SwitchBotBLEModel.PlugMiniUS || SwitchBotBLEModel.PlugMiniJP)
190
190
  && serviceData.modelName === (SwitchBotBLEModelName.PlugMini || SwitchBotBLEModelName.PlugMini)) {
@@ -192,8 +192,8 @@ export class Plug extends deviceBase {
192
192
  await this.BLEparseStatus()
193
193
  await this.updateHomeKitCharacteristics()
194
194
  } else {
195
- await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`)
196
- await this.BLERefreshConnection(switchbot)
195
+ await this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
196
+ await this.BLERefreshConnection(switchBotBLE)
197
197
  }
198
198
  })()
199
199
  }
@@ -214,7 +214,7 @@ export class Plug extends deviceBase {
214
214
  await this.BLEparseStatus()
215
215
  await this.updateHomeKitCharacteristics()
216
216
  } catch (e: any) {
217
- await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e}`)
217
+ await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
218
218
  }
219
219
  }
220
220
  } catch (error) {
@@ -256,7 +256,7 @@ export class Plug extends deviceBase {
256
256
  await this.parseStatusWebhook()
257
257
  await this.updateHomeKitCharacteristics()
258
258
  } catch (e: any) {
259
- await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e}`)
259
+ await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
260
260
  }
261
261
  }
262
262
  } else {
@@ -298,23 +298,24 @@ export class Plug extends deviceBase {
298
298
  await this.debugLog('BLEpushChanges')
299
299
  if (this.Outlet.On !== this.accessory.context.On) {
300
300
  await this.debugLog(`BLEpushChanges On: ${this.Outlet.On}, OnCached: ${this.accessory.context.On}`)
301
- const switchbot = await this.platform.connectBLE(this.accessory, this.device)
301
+ const switchBotBLE = await this.platform.connectBLE(this.accessory, this.device)
302
302
  try {
303
303
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId)
304
304
  this.device.bleMac = formattedDeviceId
305
305
  await this.debugLog(`bleMac: ${this.device.bleMac}`)
306
- if (switchbot !== false) {
307
- switchbot
306
+ if (switchBotBLE !== false) {
307
+ switchBotBLE
308
308
  .discover({ model: this.device.bleModel, id: this.device.bleMac })
309
- .then(async (device_list: any) => {
309
+ .then(async (device_list: SwitchbotDevice[]) => {
310
+ const deviceList = device_list as unknown as WoPlugMini[]
310
311
  await this.infoLog(`On: ${this.Outlet.On}`)
311
312
  return await this.retryBLE({
312
313
  max: await this.maxRetryBLE(),
313
314
  fn: async () => {
314
315
  if (this.Outlet.On) {
315
- return await device_list[0].turnOn({ id: this.device.bleMac })
316
+ return await deviceList[0].turnOn()
316
317
  } else {
317
- return await device_list[0].turnOff({ id: this.device.bleMac })
318
+ return await deviceList[0].turnOff()
318
319
  }
319
320
  },
320
321
  })
@@ -329,7 +330,7 @@ export class Plug extends deviceBase {
329
330
  await this.BLEPushConnection()
330
331
  })
331
332
  } else {
332
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`)
333
+ await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`)
333
334
  await this.BLEPushConnection()
334
335
  }
335
336
  } catch (error) {
@@ -3,7 +3,7 @@
3
3
  * robotvacuumcleaner.ts: @switchbot/homebridge-switchbot.
4
4
  */
5
5
  import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'
6
- import type { bodyChange, device, floorCleaningRobotS10Status, floorCleaningRobotS10WebhookContext, robotVacuumCleanerS1PlusStatus, robotVacuumCleanerS1PlusWebhookContext, robotVacuumCleanerS1Status, robotVacuumCleanerS1WebhookContext, robotVacuumCleanerServiceData } from 'node-switchbot'
6
+ import type { bodyChange, device, floorCleaningRobotS10Status, floorCleaningRobotS10WebhookContext, robotVacuumCleanerS1PlusStatus, robotVacuumCleanerS1PlusWebhookContext, robotVacuumCleanerS1Status, robotVacuumCleanerS1WebhookContext, robotVacuumCleanerServiceData, SwitchbotDevice } from 'node-switchbot'
7
7
 
8
8
  import type { SwitchBotPlatform } from '../platform.js'
9
9
  import type { devicesConfig } from '../settings.js'
@@ -116,7 +116,7 @@ export class RobotVacuumCleaner extends deviceBase {
116
116
  this.debugLog('Retrieve initial values and update Homekit')
117
117
  this.refreshStatus()
118
118
  } catch (e: any) {
119
- this.errorLog(`failed to retrieve initial values and update Homekit, Error: ${e}`)
119
+ this.errorLog(`failed to retrieve initial values and update Homekit, Error: ${e.message ?? e}`)
120
120
  }
121
121
 
122
122
  // regisiter webhook event handler if enabled
@@ -124,7 +124,7 @@ export class RobotVacuumCleaner extends deviceBase {
124
124
  this.debugLog('Registering Webhook Event Handler')
125
125
  this.registerWebhook()
126
126
  } catch (e: any) {
127
- this.errorLog(`failed to registerWebhook, Error: ${e}`)
127
+ this.errorLog(`failed to registerWebhook, Error: ${e.message ?? e}`)
128
128
  }
129
129
 
130
130
  // regisiter platform BLE event handler if enabled
@@ -132,7 +132,7 @@ export class RobotVacuumCleaner extends deviceBase {
132
132
  this.debugLog('Registering Platform BLE Event Handler')
133
133
  this.registerPlatformBLE()
134
134
  } catch (e: any) {
135
- this.errorLog(`failed to registerPlatformBLE, Error: ${e}`)
135
+ this.errorLog(`failed to registerPlatformBLE, Error: ${e.message ?? e}`)
136
136
  }
137
137
 
138
138
  // Start an update interval
@@ -264,22 +264,22 @@ export class RobotVacuumCleaner extends deviceBase {
264
264
 
265
265
  async BLERefreshStatus(): Promise<void> {
266
266
  await this.debugLog('BLERefreshStatus')
267
- const switchbot = await this.switchbotBLE()
268
- if (switchbot === undefined) {
269
- await this.BLERefreshConnection(switchbot)
267
+ const switchBotBLE = await this.switchbotBLE()
268
+ if (switchBotBLE === undefined) {
269
+ await this.BLERefreshConnection(switchBotBLE)
270
270
  } else {
271
271
  // Start to monitor advertisement packets
272
272
  (async () => {
273
273
  // Start to monitor advertisement packets
274
- const serviceData = await this.monitorAdvertisementPackets(switchbot) as unknown as robotVacuumCleanerServiceData
274
+ const serviceData = await this.monitorAdvertisementPackets(switchBotBLE) as unknown as robotVacuumCleanerServiceData
275
275
  // Update HomeKit
276
276
  if (serviceData.model === SwitchBotBLEModel.Unknown && serviceData.modelName === SwitchBotBLEModelName.Unknown) {
277
277
  this.serviceData = serviceData
278
278
  await this.BLEparseStatus()
279
279
  await this.updateHomeKitCharacteristics()
280
280
  } else {
281
- await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`)
282
- await this.BLERefreshConnection(switchbot)
281
+ await this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
282
+ await this.BLERefreshConnection(switchBotBLE)
283
283
  }
284
284
  })()
285
285
  }
@@ -300,7 +300,7 @@ export class RobotVacuumCleaner extends deviceBase {
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}`)
303
+ await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
304
304
  }
305
305
  }
306
306
  } catch (error) {
@@ -342,7 +342,7 @@ export class RobotVacuumCleaner extends deviceBase {
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}`)
345
+ await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
346
346
  }
347
347
  }
348
348
  } else {
@@ -381,23 +381,24 @@ export class RobotVacuumCleaner extends deviceBase {
381
381
  async BLEpushChanges(): Promise<void> {
382
382
  await this.debugLog('BLEpushChanges')
383
383
  if (this.LightBulb.On !== this.accessory.context.On) {
384
- const switchbot = await this.platform.connectBLE(this.accessory, this.device)
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
388
  await this.debugLog(`bleMac: ${this.device.bleMac}`)
389
- if (switchbot !== false) {
390
- switchbot
389
+ if (switchBotBLE !== false) {
390
+ switchBotBLE
391
391
  .discover({ model: this.device.bleModel, id: this.device.bleMac })
392
- .then(async (device_list: any) => {
392
+ .then(async (device_list: SwitchbotDevice[]) => {
393
+ const deviceList = device_list as unknown as SwitchbotDevice[]
393
394
  await this.infoLog(`On: ${this.LightBulb.On}`)
394
395
  return await this.retryBLE({
395
396
  max: await this.maxRetryBLE(),
396
397
  fn: async () => {
397
398
  if (this.LightBulb.On) {
398
- return await device_list[0].turnOn({ id: this.device.bleMac })
399
+ return await deviceList[0].turnOn()
399
400
  } else {
400
- return await device_list[0].turnOff({ id: this.device.bleMac })
401
+ return await deviceList[0].turnOff()
401
402
  }
402
403
  },
403
404
  })
@@ -412,7 +413,7 @@ export class RobotVacuumCleaner extends deviceBase {
412
413
  await this.BLEPushConnection()
413
414
  })
414
415
  } else {
415
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`)
416
+ await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`)
416
417
  await this.BLEPushConnection()
417
418
  }
418
419
  } catch (error) {
@@ -116,7 +116,7 @@ export class WaterDetector extends deviceBase {
116
116
  this.debugLog('Retrieve initial values and update Homekit')
117
117
  this.refreshStatus()
118
118
  } catch (e: any) {
119
- this.errorLog(`failed to retrieve initial values and update Homekit, Error: ${e}`)
119
+ this.errorLog(`failed to retrieve initial values and update Homekit, Error: ${e.message ?? e}`)
120
120
  }
121
121
 
122
122
  // regisiter webhook event handler if enabled
@@ -124,7 +124,7 @@ export class WaterDetector extends deviceBase {
124
124
  this.debugLog('Registering Webhook Event Handler')
125
125
  this.registerWebhook()
126
126
  } catch (e: any) {
127
- this.errorLog(`failed to registerWebhook, Error: ${e}`)
127
+ this.errorLog(`failed to registerWebhook, Error: ${e.message ?? e}`)
128
128
  }
129
129
 
130
130
  // regisiter platform BLE event handler if enabled
@@ -132,7 +132,7 @@ export class WaterDetector extends deviceBase {
132
132
  this.debugLog('Registering Platform BLE Event Handler')
133
133
  this.registerPlatformBLE()
134
134
  } catch (e: any) {
135
- this.errorLog(`failed to registerPlatformBLE, Error: ${e}`)
135
+ this.errorLog(`failed to registerPlatformBLE, Error: ${e.message ?? e}`)
136
136
  }
137
137
 
138
138
  // Start an update interval
@@ -268,22 +268,22 @@ export class WaterDetector extends deviceBase {
268
268
 
269
269
  async BLERefreshStatus(): Promise<void> {
270
270
  await this.debugLog('BLERefreshStatus')
271
- const switchbot = await this.switchbotBLE()
272
- if (switchbot === undefined) {
273
- await this.BLERefreshConnection(switchbot)
271
+ const switchBotBLE = await this.switchbotBLE()
272
+ if (switchBotBLE === undefined) {
273
+ await this.BLERefreshConnection(switchBotBLE)
274
274
  } else {
275
275
  // Start to monitor advertisement packets
276
276
  (async () => {
277
277
  // Start to monitor advertisement packets
278
- const serviceData = await this.monitorAdvertisementPackets(switchbot) as waterLeakDetectorServiceData
278
+ const serviceData = await this.monitorAdvertisementPackets(switchBotBLE) as waterLeakDetectorServiceData
279
279
  // Update HomeKit
280
280
  if (serviceData.model === SwitchBotBLEModel.Unknown && serviceData.modelName === SwitchBotBLEModelName.Unknown) {
281
281
  this.serviceData = serviceData
282
282
  await this.BLEparseStatus()
283
283
  await this.updateHomeKitCharacteristics()
284
284
  } else {
285
- await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`)
286
- await this.BLERefreshConnection(switchbot)
285
+ await this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
286
+ await this.BLERefreshConnection(switchBotBLE)
287
287
  }
288
288
  })()
289
289
  }
@@ -304,7 +304,7 @@ export class WaterDetector extends deviceBase {
304
304
  await this.BLEparseStatus()
305
305
  await this.updateHomeKitCharacteristics()
306
306
  } catch (e: any) {
307
- await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e}`)
307
+ await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
308
308
  }
309
309
  }
310
310
  } catch (error) {
@@ -346,7 +346,7 @@ export class WaterDetector extends deviceBase {
346
346
  await this.parseStatusWebhook()
347
347
  await this.updateHomeKitCharacteristics()
348
348
  } catch (e: any) {
349
- await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e}`)
349
+ await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
350
350
  }
351
351
  }
352
352
  } else {