@switchbot/homebridge-switchbot 4.3.2-beta.9 → 4.3.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 (222) hide show
  1. package/.github/copilot-instructions.md +328 -0
  2. package/.github/scripts/npm-version-script-esm-auto.js +207 -0
  3. package/.github/workflows/beta-release.yml +8 -12
  4. package/.github/workflows/release.yml +54 -22
  5. package/CHANGELOG.md +11 -1
  6. package/README.md +13 -10
  7. package/config.schema.json +248 -5
  8. package/coverage/base.css +224 -0
  9. package/coverage/block-navigation.js +87 -0
  10. package/coverage/clover.xml +15847 -0
  11. package/coverage/coverage-final.json +42 -0
  12. package/coverage/docs/assets/dmt/dmt-component-data.js.html +85 -0
  13. package/coverage/docs/assets/dmt/dmt-components.js.html +286 -0
  14. package/coverage/docs/assets/dmt/index.html +131 -0
  15. package/coverage/docs/assets/hierarchy.js.html +85 -0
  16. package/coverage/docs/assets/icons.js.html +136 -0
  17. package/coverage/docs/assets/index.html +146 -0
  18. package/coverage/docs/assets/main.js.html +265 -0
  19. package/coverage/favicon.png +0 -0
  20. package/coverage/index.html +191 -0
  21. package/coverage/prettify.css +1 -0
  22. package/coverage/prettify.js +2 -0
  23. package/coverage/sort-arrow-sprite.png +0 -0
  24. package/coverage/sorter.js +196 -0
  25. package/coverage/src/device/blindtilt.ts.html +3238 -0
  26. package/coverage/src/device/bot.ts.html +2803 -0
  27. package/coverage/src/device/ceilinglight.ts.html +2338 -0
  28. package/coverage/src/device/colorbulb.ts.html +2824 -0
  29. package/coverage/src/device/contact.ts.html +1465 -0
  30. package/coverage/src/device/curtain.ts.html +2869 -0
  31. package/coverage/src/device/device.ts.html +2500 -0
  32. package/coverage/src/device/fan.ts.html +2242 -0
  33. package/coverage/src/device/hub.ts.html +1408 -0
  34. package/coverage/src/device/humidifier.ts.html +2116 -0
  35. package/coverage/src/device/index.html +416 -0
  36. package/coverage/src/device/iosensor.ts.html +1375 -0
  37. package/coverage/src/device/lightstrip.ts.html +2617 -0
  38. package/coverage/src/device/lock.ts.html +1963 -0
  39. package/coverage/src/device/meter.ts.html +1372 -0
  40. package/coverage/src/device/meterplus.ts.html +1384 -0
  41. package/coverage/src/device/meterpro.ts.html +1618 -0
  42. package/coverage/src/device/motion.ts.html +1264 -0
  43. package/coverage/src/device/plug.ts.html +1372 -0
  44. package/coverage/src/device/relayswitch.ts.html +2284 -0
  45. package/coverage/src/device/robotvacuumcleaner.ts.html +1810 -0
  46. package/coverage/src/device/waterdetector.ts.html +1294 -0
  47. package/coverage/src/homebridge-ui/index.html +116 -0
  48. package/coverage/src/homebridge-ui/server.ts.html +229 -0
  49. package/coverage/src/index.html +161 -0
  50. package/coverage/src/index.ts.html +124 -0
  51. package/coverage/src/irdevice/airconditioner.ts.html +1687 -0
  52. package/coverage/src/irdevice/airpurifier.ts.html +844 -0
  53. package/coverage/src/irdevice/camera.ts.html +475 -0
  54. package/coverage/src/irdevice/fan.ts.html +766 -0
  55. package/coverage/src/irdevice/index.html +251 -0
  56. package/coverage/src/irdevice/irdevice.ts.html +1117 -0
  57. package/coverage/src/irdevice/light.ts.html +826 -0
  58. package/coverage/src/irdevice/other.ts.html +2458 -0
  59. package/coverage/src/irdevice/tv.ts.html +1222 -0
  60. package/coverage/src/irdevice/vacuumcleaner.ts.html +466 -0
  61. package/coverage/src/irdevice/waterheater.ts.html +469 -0
  62. package/coverage/src/platform.ts.html +8776 -0
  63. package/coverage/src/settings.ts.html +934 -0
  64. package/coverage/src/utils.ts.html +2092 -0
  65. package/dist/device/blindtilt.d.ts.map +1 -1
  66. package/dist/device/blindtilt.js +12 -4
  67. package/dist/device/blindtilt.js.map +1 -1
  68. package/dist/device/bot.d.ts.map +1 -1
  69. package/dist/device/bot.js +12 -4
  70. package/dist/device/bot.js.map +1 -1
  71. package/dist/device/ceilinglight.d.ts.map +1 -1
  72. package/dist/device/ceilinglight.js +18 -7
  73. package/dist/device/ceilinglight.js.map +1 -1
  74. package/dist/device/colorbulb.d.ts.map +1 -1
  75. package/dist/device/colorbulb.js +18 -7
  76. package/dist/device/colorbulb.js.map +1 -1
  77. package/dist/device/contact.d.ts.map +1 -1
  78. package/dist/device/contact.js +6 -2
  79. package/dist/device/contact.js.map +1 -1
  80. package/dist/device/curtain.d.ts.map +1 -1
  81. package/dist/device/curtain.js +12 -4
  82. package/dist/device/curtain.js.map +1 -1
  83. package/dist/device/device.d.ts +5 -7
  84. package/dist/device/device.d.ts.map +1 -1
  85. package/dist/device/device.js +11 -5
  86. package/dist/device/device.js.map +1 -1
  87. package/dist/device/fan.d.ts.map +1 -1
  88. package/dist/device/fan.js +16 -6
  89. package/dist/device/fan.js.map +1 -1
  90. package/dist/device/hub.d.ts +2 -2
  91. package/dist/device/hub.d.ts.map +1 -1
  92. package/dist/device/hub.js +8 -3
  93. package/dist/device/hub.js.map +1 -1
  94. package/dist/device/humidifier.d.ts.map +1 -1
  95. package/dist/device/humidifier.js +16 -6
  96. package/dist/device/humidifier.js.map +1 -1
  97. package/dist/device/iosensor.d.ts.map +1 -1
  98. package/dist/device/iosensor.js +6 -2
  99. package/dist/device/iosensor.js.map +1 -1
  100. package/dist/device/lightstrip.d.ts.map +1 -1
  101. package/dist/device/lightstrip.js +16 -6
  102. package/dist/device/lightstrip.js.map +1 -1
  103. package/dist/device/lock.d.ts.map +1 -1
  104. package/dist/device/lock.js +12 -4
  105. package/dist/device/lock.js.map +1 -1
  106. package/dist/device/meter.d.ts.map +1 -1
  107. package/dist/device/meter.js +6 -2
  108. package/dist/device/meter.js.map +1 -1
  109. package/dist/device/meterplus.d.ts.map +1 -1
  110. package/dist/device/meterplus.js +6 -2
  111. package/dist/device/meterplus.js.map +1 -1
  112. package/dist/device/meterpro.d.ts.map +1 -1
  113. package/dist/device/meterpro.js +7 -4
  114. package/dist/device/meterpro.js.map +1 -1
  115. package/dist/device/motion.d.ts.map +1 -1
  116. package/dist/device/motion.js +6 -2
  117. package/dist/device/motion.js.map +1 -1
  118. package/dist/device/plug.d.ts.map +1 -1
  119. package/dist/device/plug.js +12 -4
  120. package/dist/device/plug.js.map +1 -1
  121. package/dist/device/presence.d.ts +42 -0
  122. package/dist/device/presence.d.ts.map +1 -0
  123. package/dist/device/presence.js +349 -0
  124. package/dist/device/presence.js.map +1 -0
  125. package/dist/device/relayswitch.d.ts.map +1 -1
  126. package/dist/device/relayswitch.js +12 -4
  127. package/dist/device/relayswitch.js.map +1 -1
  128. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  129. package/dist/device/robotvacuumcleaner.js +14 -5
  130. package/dist/device/robotvacuumcleaner.js.map +1 -1
  131. package/dist/device/waterdetector.d.ts.map +1 -1
  132. package/dist/device/waterdetector.js +6 -2
  133. package/dist/device/waterdetector.js.map +1 -1
  134. package/dist/homebridge-ui/public/index.html +1 -1
  135. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  136. package/dist/irdevice/airconditioner.js +2 -1
  137. package/dist/irdevice/airconditioner.js.map +1 -1
  138. package/dist/irdevice/airpurifier.d.ts +1 -1
  139. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  140. package/dist/irdevice/airpurifier.js +6 -5
  141. package/dist/irdevice/airpurifier.js.map +1 -1
  142. package/dist/irdevice/camera.d.ts.map +1 -1
  143. package/dist/irdevice/camera.js +2 -1
  144. package/dist/irdevice/camera.js.map +1 -1
  145. package/dist/irdevice/fan.d.ts.map +1 -1
  146. package/dist/irdevice/fan.js +2 -1
  147. package/dist/irdevice/fan.js.map +1 -1
  148. package/dist/irdevice/irdevice.d.ts +2 -6
  149. package/dist/irdevice/irdevice.d.ts.map +1 -1
  150. package/dist/irdevice/irdevice.js.map +1 -1
  151. package/dist/irdevice/light.d.ts.map +1 -1
  152. package/dist/irdevice/light.js +2 -1
  153. package/dist/irdevice/light.js.map +1 -1
  154. package/dist/irdevice/other.d.ts.map +1 -1
  155. package/dist/irdevice/other.js +2 -1
  156. package/dist/irdevice/other.js.map +1 -1
  157. package/dist/irdevice/tv.d.ts.map +1 -1
  158. package/dist/irdevice/tv.js +2 -1
  159. package/dist/irdevice/tv.js.map +1 -1
  160. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  161. package/dist/irdevice/vacuumcleaner.js +2 -1
  162. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  163. package/dist/irdevice/waterheater.d.ts.map +1 -1
  164. package/dist/irdevice/waterheater.js +2 -1
  165. package/dist/irdevice/waterheater.js.map +1 -1
  166. package/dist/platform.d.ts +2 -2
  167. package/dist/platform.d.ts.map +1 -1
  168. package/dist/platform.js +77 -78
  169. package/dist/platform.js.map +1 -1
  170. package/dist/settings.d.ts +6 -0
  171. package/dist/settings.d.ts.map +1 -1
  172. package/dist/settings.js +1 -0
  173. package/dist/settings.js.map +1 -1
  174. package/docs/index.html +20 -11
  175. package/docs/variables/default.html +1 -1
  176. package/eslint.config.js +0 -1
  177. package/package.json +9 -10
  178. package/src/device/blindtilt.ts +10 -4
  179. package/src/device/bot.ts +10 -4
  180. package/src/device/ceilinglight.ts +16 -7
  181. package/src/device/colorbulb.ts +16 -7
  182. package/src/device/contact.ts +5 -2
  183. package/src/device/curtain.ts +12 -6
  184. package/src/device/device.ts +14 -8
  185. package/src/device/fan.ts +14 -6
  186. package/src/device/hub.ts +10 -6
  187. package/src/device/humidifier.ts +14 -6
  188. package/src/device/iosensor.ts +5 -2
  189. package/src/device/lightstrip.ts +14 -6
  190. package/src/device/lock.ts +10 -4
  191. package/src/device/meter.ts +6 -3
  192. package/src/device/meterplus.ts +5 -2
  193. package/src/device/meterpro.ts +7 -5
  194. package/src/device/motion.ts +5 -2
  195. package/src/device/plug.ts +10 -4
  196. package/src/device/presence.ts +393 -0
  197. package/src/device/relayswitch.ts +10 -4
  198. package/src/device/robotvacuumcleaner.ts +12 -5
  199. package/src/device/waterdetector.ts +5 -2
  200. package/src/homebridge-ui/public/index.html +1 -1
  201. package/src/irdevice/airconditioner.ts +2 -1
  202. package/src/irdevice/airpurifier.ts +6 -5
  203. package/src/irdevice/camera.ts +2 -1
  204. package/src/irdevice/fan.ts +2 -1
  205. package/src/irdevice/irdevice.ts +2 -2
  206. package/src/irdevice/light.ts +2 -1
  207. package/src/irdevice/other.ts +2 -1
  208. package/src/irdevice/tv.ts +2 -1
  209. package/src/irdevice/vacuumcleaner.ts +2 -1
  210. package/src/irdevice/waterheater.ts +2 -1
  211. package/src/platform.ts +80 -88
  212. package/src/settings.ts +7 -0
  213. package/.github/npm-version-script-esm.js +0 -97
  214. package/.github/workflows/build.yml +0 -18
  215. package/.github/workflows/changerelease.yml +0 -11
  216. package/.github/workflows/labeler.yml +0 -16
  217. package/.github/workflows/release-drafter.yml +0 -14
  218. package/dist/device/airpurifier.d.ts +0 -54
  219. package/dist/device/airpurifier.d.ts.map +0 -1
  220. package/dist/device/airpurifier.js +0 -527
  221. package/dist/device/airpurifier.js.map +0 -1
  222. package/src/device/airpurifier.ts +0 -563
@@ -318,7 +318,7 @@ export abstract class deviceBase {
318
318
  try {
319
319
  await switchbot.startScan({ model: this.device.bleModel, id: this.device.bleMac })
320
320
  } catch (e: any) {
321
- this.errorLog(`Failed to start BLE scanning. Error:${e.message ?? e}`)
321
+ this.errorLog(`Failed to start BLE scanning. Error: ${e.message ?? e}`)
322
322
  }
323
323
  // Set an event handler
324
324
  let serviceData = { model: this.device.bleModel, modelName: this.device.bleModelName } as ad['serviceData']
@@ -337,7 +337,7 @@ export abstract class deviceBase {
337
337
  try {
338
338
  await switchbot.stopScan()
339
339
  } catch (e: any) {
340
- this.errorLog(`Failed to stop BLE scanning. Error:${e.message ?? e}`)
340
+ this.errorLog(`Failed to stop BLE scanning. Error: ${e.message ?? e}`)
341
341
  }
342
342
  return serviceData
343
343
  }
@@ -350,7 +350,7 @@ export abstract class deviceBase {
350
350
  try {
351
351
  await switchbot.startScan({ model: this.device.bleModel })
352
352
  } catch (e: any) {
353
- this.errorLog(`Failed to start BLE scanning. Error:${e.message ?? e}`)
353
+ this.errorLog(`Failed to start BLE scanning. Error: ${e.message ?? e}`)
354
354
  }
355
355
  // Set an event handler
356
356
  switchbot.onadvertisement = (ad: ad) => {
@@ -361,23 +361,23 @@ export abstract class deviceBase {
361
361
  try {
362
362
  switchbot.stopScan()
363
363
  } catch (e: any) {
364
- this.errorLog(`Failed to stop BLE scanning. Error:${e.message ?? e}`)
364
+ this.errorLog(`Failed to stop BLE scanning. Error: ${e.message ?? e}`)
365
365
  }
366
366
  })()
367
367
  }
368
368
  }
369
369
 
370
- async pushChangeRequest<T extends pushResponse['body']>(bodyChange: bodyChange): Promise<{ body: T, statusCode: pushResponse['statusCode'] }> {
370
+ async pushChangeRequest(bodyChange: bodyChange): Promise<{ body: pushResponse['body'], statusCode: pushResponse['statusCode'] }> {
371
371
  const { response, statusCode } = await this.platform.retryCommand(this.device, bodyChange, this.deviceMaxRetries, this.deviceDelayBetweenRetries)
372
372
  return { body: response, statusCode }
373
373
  }
374
374
 
375
- async deviceRefreshStatus<T extends deviceStatus>(): Promise<{ body: T, statusCode: deviceStatusRequest['statusCode'] }> {
375
+ async deviceRefreshStatus(): Promise<{ body: deviceStatus, statusCode: deviceStatusRequest['statusCode'] }> {
376
376
  const { response, statusCode } = await this.platform.retryRequest(this.device, this.deviceMaxRetries, this.deviceDelayBetweenRetries)
377
377
  return { body: response, statusCode }
378
378
  }
379
379
 
380
- async successfulStatusCodes<T extends { statusCode: number }>(deviceStatus: T) {
380
+ async successfulStatusCodes(deviceStatus: deviceStatusRequest) {
381
381
  return (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)
382
382
  }
383
383
 
@@ -446,6 +446,12 @@ export abstract class deviceBase {
446
446
  bleModelName: SwitchBotBLEModelName.Hub2,
447
447
  bleModelFriendlyName: SwitchBotBLEModelFriendlyName.Hub2,
448
448
  },
449
+ 'Hub 3': {
450
+ model: SwitchBotModel.Hub3,
451
+ bleModel: SwitchBotBLEModel.Hub3,
452
+ bleModelName: SwitchBotBLEModelName.Hub3,
453
+ bleModelFriendlyName: SwitchBotBLEModelFriendlyName.Hub3,
454
+ },
449
455
  'Bot': {
450
456
  model: SwitchBotModel.Bot,
451
457
  bleModel: SwitchBotBLEModel.Bot,
@@ -482,7 +488,7 @@ export abstract class deviceBase {
482
488
  bleModelName: SwitchBotBLEModelName.MeterPlus,
483
489
  bleModelFriendlyName: SwitchBotBLEModelFriendlyName.MeterPlus,
484
490
  },
485
- 'MeterPro': {
491
+ 'Meter Pro': {
486
492
  model: SwitchBotModel.MeterPro,
487
493
  bleModel: SwitchBotBLEModel.MeterPro,
488
494
  bleModelName: SwitchBotBLEModelName.MeterPro,
package/src/device/fan.ts CHANGED
@@ -306,7 +306,9 @@ export class Fan extends deviceBase {
306
306
  * Asks the SwitchBot API for the latest device information
307
307
  */
308
308
  async refreshStatus(): Promise<void> {
309
- if (this.BLE) {
309
+ if (!this.device.enableCloudService && this.OpenAPI) {
310
+ this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
311
+ } else if (this.BLE) {
310
312
  await this.BLERefreshStatus()
311
313
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
312
314
  await this.openAPIRefreshStatus()
@@ -378,7 +380,8 @@ export class Fan extends deviceBase {
378
380
  async openAPIRefreshStatus(): Promise<void> {
379
381
  this.debugLog('openAPIRefreshStatus')
380
382
  try {
381
- const deviceStatus = await this.deviceRefreshStatus<batteryCirculatorFanStatus>()
383
+ const response = await this.deviceRefreshStatus()
384
+ const deviceStatus: any = response.body
382
385
  this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
383
386
  if (await this.successfulStatusCodes(deviceStatus)) {
384
387
  this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
@@ -427,7 +430,9 @@ export class Fan extends deviceBase {
427
430
  */
428
431
 
429
432
  async pushChanges(): Promise<void> {
430
- if (this.BLE) {
433
+ if (!this.device.enableCloudService && this.OpenAPI) {
434
+ this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`)
435
+ } else if (this.BLE) {
431
436
  await this.BLEpushChanges()
432
437
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
433
438
  await this.openAPIpushChanges()
@@ -511,7 +516,8 @@ export class Fan extends deviceBase {
511
516
  }
512
517
  this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
513
518
  try {
514
- const deviceStatus = await this.pushChangeRequest(bodyChange)
519
+ const response = await this.pushChangeRequest(bodyChange)
520
+ const deviceStatus: any = response.body
515
521
  this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
516
522
  if (await this.successfulStatusCodes(deviceStatus)) {
517
523
  this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
@@ -538,7 +544,8 @@ export class Fan extends deviceBase {
538
544
  }
539
545
  this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
540
546
  try {
541
- const deviceStatus = await this.pushChangeRequest(bodyChange)
547
+ const response = await this.pushChangeRequest(bodyChange)
548
+ const deviceStatus: any = response.body
542
549
  this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
543
550
  if (await this.successfulStatusCodes(deviceStatus)) {
544
551
  this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
@@ -566,7 +573,8 @@ export class Fan extends deviceBase {
566
573
  }
567
574
  this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
568
575
  try {
569
- const deviceStatus = await this.pushChangeRequest(bodyChange)
576
+ const response = await this.pushChangeRequest(bodyChange)
577
+ const deviceStatus: any = response.body
570
578
  this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
571
579
  if (await this.successfulStatusCodes(deviceStatus)) {
572
580
  this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
package/src/device/hub.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * hub.ts: @switchbot/homebridge-switchbot.
4
4
  */
5
5
  import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'
6
- import type { device, hub2ServiceData, hub2Status, hub2WebhookContext, SwitchBotBLE } from 'node-switchbot'
6
+ import type { device, hub2ServiceData, hub2Status, hub2WebhookContext, hub3ServiceData, SwitchBotBLE } from 'node-switchbot'
7
7
 
8
8
  import type { SwitchBotPlatform } from '../platform.js'
9
9
  import type { devicesConfig, hubConfig } from '../settings.js'
@@ -46,7 +46,7 @@ export class Hub extends deviceBase {
46
46
  webhookContext!: hub2WebhookContext
47
47
 
48
48
  // BLE
49
- serviceData!: hub2ServiceData
49
+ serviceData!: hub2ServiceData | hub3ServiceData
50
50
 
51
51
  // Updates
52
52
  hubUpdateInProgress!: boolean
@@ -273,7 +273,9 @@ export class Hub extends deviceBase {
273
273
  * Asks the SwitchBot API for the latest device information
274
274
  */
275
275
  async refreshStatus(): Promise<void> {
276
- if (this.BLE) {
276
+ if (!this.device.enableCloudService && this.OpenAPI) {
277
+ this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
278
+ } else if (this.BLE) {
277
279
  await this.BLERefreshStatus()
278
280
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
279
281
  await this.openAPIRefreshStatus()
@@ -292,9 +294,10 @@ export class Hub extends deviceBase {
292
294
  // Start to monitor advertisement packets
293
295
  (async () => {
294
296
  // Start to monitor advertisement packets
295
- const serviceData = await this.monitorAdvertisementPackets(switchBotBLE) as hub2ServiceData
297
+ const serviceData = await this.monitorAdvertisementPackets(switchBotBLE) as hub2ServiceData | hub3ServiceData
296
298
  // Update HomeKit
297
- if (serviceData.model === SwitchBotBLEModel.Hub2 && serviceData.modelName === SwitchBotBLEModelName.Hub2) {
299
+ if ((serviceData.model === SwitchBotBLEModel.Hub2 && serviceData.modelName === SwitchBotBLEModelName.Hub2)
300
+ || (serviceData.model === SwitchBotBLEModel.Hub3 && serviceData.modelName === SwitchBotBLEModelName.Hub3)) {
298
301
  this.serviceData = serviceData
299
302
  if (serviceData !== undefined || serviceData !== null) {
300
303
  await this.BLEparseStatus()
@@ -345,7 +348,8 @@ export class Hub extends deviceBase {
345
348
  async openAPIRefreshStatus(): Promise<void> {
346
349
  this.debugLog('openAPIRefreshStatus')
347
350
  try {
348
- const deviceStatus = await this.deviceRefreshStatus<hub2Status>()
351
+ const response = await this.deviceRefreshStatus()
352
+ const deviceStatus: any = response.body
349
353
  this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
350
354
  if (await this.successfulStatusCodes(deviceStatus)) {
351
355
  this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
@@ -303,7 +303,9 @@ export class Humidifier extends deviceBase {
303
303
  * Asks the SwitchBot API for the latest device information
304
304
  */
305
305
  async refreshStatus(): Promise<void> {
306
- if (this.BLE) {
306
+ if (!this.device.enableCloudService && this.OpenAPI) {
307
+ this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
308
+ } else if (this.BLE) {
307
309
  await this.BLERefreshStatus()
308
310
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
309
311
  await this.openAPIRefreshStatus()
@@ -375,7 +377,8 @@ export class Humidifier extends deviceBase {
375
377
  async openAPIRefreshStatus(): Promise<void> {
376
378
  this.debugLog('openAPIRefreshStatus')
377
379
  try {
378
- const deviceStatus = await this.deviceRefreshStatus<humidifierStatus | humidifier2Status>()
380
+ const response = await this.deviceRefreshStatus()
381
+ const deviceStatus: any = response.body
379
382
  this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
380
383
  if (await this.successfulStatusCodes(deviceStatus)) {
381
384
  this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
@@ -415,7 +418,9 @@ export class Humidifier extends deviceBase {
415
418
  * Pushes the requested changes to the SwitchBot API
416
419
  */
417
420
  async pushChanges(): Promise<void> {
418
- if (this.BLE) {
421
+ if (!this.device.enableCloudService && this.OpenAPI) {
422
+ this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`)
423
+ } else if (this.BLE) {
419
424
  await this.BLEpushChanges()
420
425
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
421
426
  await this.openAPIpushChanges()
@@ -482,7 +487,8 @@ export class Humidifier extends deviceBase {
482
487
  }
483
488
  this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
484
489
  try {
485
- const deviceStatus = await this.pushChangeRequest(bodyChange)
490
+ const response = await this.pushChangeRequest(bodyChange)
491
+ const deviceStatus: any = response.body
486
492
  this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
487
493
  if (await this.successfulStatusCodes(deviceStatus)) {
488
494
  this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
@@ -515,7 +521,8 @@ export class Humidifier extends deviceBase {
515
521
  }
516
522
  this.debugLog(`pushAutoChanges, SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
517
523
  try {
518
- const deviceStatus = await this.pushChangeRequest(bodyChange)
524
+ const response = await this.pushChangeRequest(bodyChange)
525
+ const deviceStatus: any = response.body
519
526
  this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
520
527
  if (await this.successfulStatusCodes(deviceStatus)) {
521
528
  this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
@@ -546,7 +553,8 @@ export class Humidifier extends deviceBase {
546
553
  }
547
554
  this.debugLog(`pushActiveChanges, SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
548
555
  try {
549
- const deviceStatus = await this.pushChangeRequest(bodyChange)
556
+ const response = await this.pushChangeRequest(bodyChange)
557
+ const deviceStatus: any = response.body
550
558
  this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
551
559
  if (await this.successfulStatusCodes(deviceStatus)) {
552
560
  this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
@@ -267,7 +267,9 @@ export class IOSensor extends deviceBase {
267
267
  * Asks the SwitchBot API for the latest device information
268
268
  */
269
269
  async refreshStatus(): Promise<void> {
270
- if (this.BLE) {
270
+ if (!this.device.enableCloudService && this.OpenAPI) {
271
+ this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
272
+ } else if (this.BLE) {
271
273
  await this.BLERefreshStatus()
272
274
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
273
275
  await this.openAPIRefreshStatus()
@@ -339,7 +341,8 @@ export class IOSensor extends deviceBase {
339
341
  async openAPIRefreshStatus(): Promise<void> {
340
342
  this.debugLog('openAPIRefreshStatus')
341
343
  try {
342
- const deviceStatus = await this.deviceRefreshStatus<outdoorMeterStatus>()
344
+ const response = await this.deviceRefreshStatus()
345
+ const deviceStatus: any = response.body
343
346
  this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
344
347
  if (await this.successfulStatusCodes(deviceStatus)) {
345
348
  this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
@@ -305,7 +305,9 @@ export class StripLight extends deviceBase {
305
305
  * Asks the SwitchBot API for the latest device information
306
306
  */
307
307
  async refreshStatus(): Promise<void> {
308
- if (this.BLE) {
308
+ if (!this.device.enableCloudService && this.OpenAPI) {
309
+ this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
310
+ } else if (this.BLE) {
309
311
  await this.BLERefreshStatus()
310
312
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
311
313
  await this.openAPIRefreshStatus()
@@ -377,7 +379,8 @@ export class StripLight extends deviceBase {
377
379
  async openAPIRefreshStatus(): Promise<void> {
378
380
  this.debugLog('openAPIRefreshStatus')
379
381
  try {
380
- const deviceStatus = await this.deviceRefreshStatus<stripLightStatus>()
382
+ const response = await this.deviceRefreshStatus()
383
+ const deviceStatus: any = response.body
381
384
  this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
382
385
  if (await this.successfulStatusCodes(deviceStatus)) {
383
386
  this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
@@ -426,7 +429,9 @@ export class StripLight extends deviceBase {
426
429
  *
427
430
  */
428
431
  async pushChanges(): Promise<void> {
429
- if (this.BLE) {
432
+ if (!this.device.enableCloudService && this.OpenAPI) {
433
+ this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`)
434
+ } else if (this.BLE) {
430
435
  await this.BLEpushChanges()
431
436
  if (this.LightBulb.On) {
432
437
  // Push Brightness Update
@@ -603,7 +608,8 @@ export class StripLight extends deviceBase {
603
608
  }
604
609
  this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
605
610
  try {
606
- const deviceStatus = await this.pushChangeRequest(bodyChange)
611
+ const response = await this.pushChangeRequest(bodyChange)
612
+ const deviceStatus: any = response.body
607
613
  this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
608
614
  if (await this.successfulStatusCodes(deviceStatus)) {
609
615
  this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
@@ -633,7 +639,8 @@ export class StripLight extends deviceBase {
633
639
  }
634
640
  this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
635
641
  try {
636
- const deviceStatus = await this.pushChangeRequest(bodyChange)
642
+ const response = await this.pushChangeRequest(bodyChange)
643
+ const deviceStatus: any = response.body
637
644
  this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
638
645
  if (await this.successfulStatusCodes(deviceStatus)) {
639
646
  this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
@@ -660,7 +667,8 @@ export class StripLight extends deviceBase {
660
667
  }
661
668
  this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
662
669
  try {
663
- const deviceStatus = await this.pushChangeRequest(bodyChange)
670
+ const response = await this.pushChangeRequest(bodyChange)
671
+ const deviceStatus: any = response.body
664
672
  this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
665
673
  if (await this.successfulStatusCodes(deviceStatus)) {
666
674
  this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
@@ -308,7 +308,9 @@ export class Lock extends deviceBase {
308
308
  * Asks the SwitchBot API for the latest device information
309
309
  */
310
310
  async refreshStatus(): Promise<void> {
311
- if (this.BLE) {
311
+ if (!this.device.enableCloudService && this.OpenAPI) {
312
+ this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
313
+ } else if (this.BLE) {
312
314
  await this.BLERefreshStatus()
313
315
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
314
316
  await this.openAPIRefreshStatus()
@@ -381,7 +383,8 @@ export class Lock extends deviceBase {
381
383
  async openAPIRefreshStatus(): Promise<void> {
382
384
  this.debugLog('openAPIRefreshStatus')
383
385
  try {
384
- const deviceStatus = await this.deviceRefreshStatus<lockStatus | lockProStatus>()
386
+ const response = await this.deviceRefreshStatus()
387
+ const deviceStatus: any = response.body
385
388
  this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
386
389
  if (await this.successfulStatusCodes(deviceStatus)) {
387
390
  this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
@@ -426,7 +429,9 @@ export class Lock extends deviceBase {
426
429
  * Lock - "command" "unlock" "default" = set to ???? state - LockCurrentState
427
430
  */
428
431
  async pushChanges(): Promise<void> {
429
- if (this.BLE) {
432
+ if (!this.device.enableCloudService && this.OpenAPI) {
433
+ this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`)
434
+ } else if (this.BLE) {
430
435
  await this.BLEpushChanges()
431
436
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
432
437
  await this.openAPIpushChanges()
@@ -499,7 +504,8 @@ export class Lock extends deviceBase {
499
504
  }
500
505
  this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
501
506
  try {
502
- const deviceStatus = await this.pushChangeRequest(bodyChange)
507
+ const response = await this.pushChangeRequest(bodyChange)
508
+ const deviceStatus: any = response.body
503
509
  this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
504
510
  if (await this.successfulStatusCodes(deviceStatus)) {
505
511
  this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
@@ -264,7 +264,9 @@ export class Meter extends deviceBase {
264
264
  * Asks the SwitchBot API for the latest device information
265
265
  */
266
266
  async refreshStatus(): Promise<void> {
267
- if (this.BLE) {
267
+ if (!this.device.enableCloudService && this.OpenAPI) {
268
+ this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
269
+ } else if (this.BLE) {
268
270
  await this.BLERefreshStatus()
269
271
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
270
272
  await this.openAPIRefreshStatus()
@@ -283,7 +285,7 @@ export class Meter extends deviceBase {
283
285
  // Start to monitor advertisement packets
284
286
  (async () => {
285
287
  // Start to monitor advertisement packets
286
- const serviceData = await this.monitorAdvertisementPackets(switchBotBLE) as unknown as meterServiceData
288
+ const serviceData = await this.monitorAdvertisementPackets(switchBotBLE) as meterServiceData
287
289
  // Update HomeKit
288
290
  if (serviceData.model === SwitchBotBLEModel.Meter && serviceData.modelName === SwitchBotBLEModelName.Meter) {
289
291
  this.serviceData = serviceData
@@ -336,7 +338,8 @@ export class Meter extends deviceBase {
336
338
  async openAPIRefreshStatus(): Promise<void> {
337
339
  this.debugLog('openAPIRefreshStatus')
338
340
  try {
339
- const deviceStatus = await this.deviceRefreshStatus<meterStatus>()
341
+ const response = await this.deviceRefreshStatus()
342
+ const deviceStatus: any = response.body
340
343
  this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
341
344
  if (await this.successfulStatusCodes(deviceStatus)) {
342
345
  this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
@@ -268,7 +268,9 @@ export class MeterPlus extends deviceBase {
268
268
  * Asks the SwitchBot API for the latest device information
269
269
  */
270
270
  async refreshStatus(): Promise<void> {
271
- if (this.BLE) {
271
+ if (!this.device.enableCloudService && this.OpenAPI) {
272
+ this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
273
+ } else if (this.BLE) {
272
274
  await this.BLERefreshStatus()
273
275
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
274
276
  await this.openAPIRefreshStatus()
@@ -340,7 +342,8 @@ export class MeterPlus extends deviceBase {
340
342
  async openAPIRefreshStatus(): Promise<void> {
341
343
  this.debugLog('openAPIRefreshStatus')
342
344
  try {
343
- const deviceStatus = await this.deviceRefreshStatus<meterPlusStatus>()
345
+ const response = await this.deviceRefreshStatus()
346
+ const deviceStatus: any = response.body
344
347
  this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
345
348
  if (await this.successfulStatusCodes(deviceStatus)) {
346
349
  this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
@@ -282,7 +282,7 @@ export class MeterPro extends deviceBase {
282
282
 
283
283
  // Battery Info
284
284
  if ('battery' in this.deviceStatus) {
285
- // BatteryLevel
285
+ // BatteryLevel
286
286
  this.Battery.BatteryLevel = this.deviceStatus.battery
287
287
  this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
288
288
 
@@ -346,7 +346,9 @@ export class MeterPro extends deviceBase {
346
346
  * Asks the SwitchBot API for the latest device information
347
347
  */
348
348
  async refreshStatus(): Promise<void> {
349
- if (this.BLE) {
349
+ if (!this.device.enableCloudService && this.OpenAPI) {
350
+ this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
351
+ } else if (this.BLE) {
350
352
  await this.BLERefreshStatus()
351
353
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
352
354
  await this.openAPIRefreshStatus()
@@ -367,8 +369,7 @@ export class MeterPro extends deviceBase {
367
369
  // Start to monitor advertisement packets
368
370
  const serviceData = await this.monitorAdvertisementPackets(switchBotBLE) as meterProServiceData | meterProCO2ServiceData
369
371
  // Update HomeKit
370
- if ((serviceData.model === SwitchBotBLEModel.MeterPro && serviceData.modelName === SwitchBotBLEModelName.MeterPro)
371
- || (serviceData.model === SwitchBotBLEModel.MeterProCO2 && serviceData.modelName === SwitchBotBLEModelName.MeterProCO2)) {
372
+ if (serviceData.model === SwitchBotBLEModel.MeterPro && serviceData.modelName === SwitchBotBLEModelName.MeterPro) {
372
373
  this.serviceData = serviceData
373
374
  if (serviceData !== undefined || serviceData !== null) {
374
375
  await this.BLEparseStatus()
@@ -419,7 +420,8 @@ export class MeterPro extends deviceBase {
419
420
  async openAPIRefreshStatus(): Promise<void> {
420
421
  this.debugLog('openAPIRefreshStatus')
421
422
  try {
422
- const deviceStatus = await this.deviceRefreshStatus<meterProStatus>()
423
+ const response = await this.deviceRefreshStatus()
424
+ const deviceStatus: any = response.body
423
425
  this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
424
426
  if (await this.successfulStatusCodes(deviceStatus)) {
425
427
  this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
@@ -239,7 +239,9 @@ export class Motion extends deviceBase {
239
239
  * Asks the SwitchBot API for the latest device information
240
240
  */
241
241
  async refreshStatus(): Promise<void> {
242
- if (this.BLE) {
242
+ if (!this.device.enableCloudService && this.OpenAPI) {
243
+ this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
244
+ } else if (this.BLE) {
243
245
  await this.BLERefreshStatus()
244
246
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
245
247
  await this.openAPIRefreshStatus()
@@ -311,7 +313,8 @@ export class Motion extends deviceBase {
311
313
  async openAPIRefreshStatus(): Promise<void> {
312
314
  this.debugLog('openAPIRefreshStatus')
313
315
  try {
314
- const deviceStatus = await this.deviceRefreshStatus<motionSensorStatus>()
316
+ const response = await this.deviceRefreshStatus()
317
+ const deviceStatus: any = response.body
315
318
  this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
316
319
  if (await this.successfulStatusCodes(deviceStatus)) {
317
320
  this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
@@ -163,7 +163,9 @@ export class Plug extends deviceBase {
163
163
  * Asks the SwitchBot API for the latest device information
164
164
  */
165
165
  async refreshStatus(): Promise<void> {
166
- if (this.BLE) {
166
+ if (!this.device.enableCloudService && this.OpenAPI) {
167
+ this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
168
+ } else if (this.BLE) {
167
169
  await this.BLERefreshStatus()
168
170
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
169
171
  await this.openAPIRefreshStatus()
@@ -236,7 +238,8 @@ export class Plug extends deviceBase {
236
238
  async openAPIRefreshStatus(): Promise<void> {
237
239
  this.debugLog('openAPIRefreshStatus')
238
240
  try {
239
- const deviceStatus = await this.deviceRefreshStatus<plugStatus | plugMiniStatus>()
241
+ const response = await this.deviceRefreshStatus()
242
+ const deviceStatus: any = response.body
240
243
  this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
241
244
  if (await this.successfulStatusCodes(deviceStatus)) {
242
245
  this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
@@ -285,7 +288,9 @@ export class Plug extends deviceBase {
285
288
  */
286
289
 
287
290
  async pushChanges(): Promise<void> {
288
- if (this.BLE) {
291
+ if (!this.device.enableCloudService && this.OpenAPI) {
292
+ this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`)
293
+ } else if (this.BLE) {
289
294
  await this.BLEpushChanges()
290
295
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
291
296
  await this.openAPIpushChanges()
@@ -360,7 +365,8 @@ export class Plug extends deviceBase {
360
365
  }
361
366
  this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
362
367
  try {
363
- const deviceStatus = await this.pushChangeRequest(bodyChange)
368
+ const response = await this.pushChangeRequest(bodyChange)
369
+ const deviceStatus: any = response.body
364
370
  this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
365
371
  if (await this.successfulStatusCodes(deviceStatus)) {
366
372
  this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)