@switchbot/homebridge-switchbot 3.5.1-beta.0 → 3.5.1-beta.2

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 (126) hide show
  1. package/README.md +16 -0
  2. package/dist/device/blindtilt.d.ts.map +1 -1
  3. package/dist/device/blindtilt.js +32 -126
  4. package/dist/device/blindtilt.js.map +1 -1
  5. package/dist/device/bot.d.ts.map +1 -1
  6. package/dist/device/bot.js +3 -5
  7. package/dist/device/bot.js.map +1 -1
  8. package/dist/device/ceilinglight.d.ts +1 -1
  9. package/dist/device/ceilinglight.d.ts.map +1 -1
  10. package/dist/device/ceilinglight.js +14 -47
  11. package/dist/device/ceilinglight.js.map +1 -1
  12. package/dist/device/colorbulb.d.ts.map +1 -1
  13. package/dist/device/colorbulb.js +9 -46
  14. package/dist/device/colorbulb.js.map +1 -1
  15. package/dist/device/contact.d.ts.map +1 -1
  16. package/dist/device/contact.js +20 -56
  17. package/dist/device/contact.js.map +1 -1
  18. package/dist/device/curtain.d.ts +1 -0
  19. package/dist/device/curtain.d.ts.map +1 -1
  20. package/dist/device/curtain.js +34 -147
  21. package/dist/device/curtain.js.map +1 -1
  22. package/dist/device/device.d.ts +25 -2
  23. package/dist/device/device.d.ts.map +1 -1
  24. package/dist/device/device.js +75 -5
  25. package/dist/device/device.js.map +1 -1
  26. package/dist/device/fan.d.ts.map +1 -1
  27. package/dist/device/fan.js +34 -50
  28. package/dist/device/fan.js.map +1 -1
  29. package/dist/device/hub.d.ts.map +1 -1
  30. package/dist/device/hub.js +2 -3
  31. package/dist/device/hub.js.map +1 -1
  32. package/dist/device/humidifier.d.ts.map +1 -1
  33. package/dist/device/humidifier.js +3 -5
  34. package/dist/device/humidifier.js.map +1 -1
  35. package/dist/device/iosensor.d.ts.map +1 -1
  36. package/dist/device/iosensor.js +2 -3
  37. package/dist/device/iosensor.js.map +1 -1
  38. package/dist/device/lightstrip.d.ts.map +1 -1
  39. package/dist/device/lightstrip.js +3 -5
  40. package/dist/device/lightstrip.js.map +1 -1
  41. package/dist/device/lock.d.ts.map +1 -1
  42. package/dist/device/lock.js +3 -5
  43. package/dist/device/lock.js.map +1 -1
  44. package/dist/device/meter.d.ts.map +1 -1
  45. package/dist/device/meter.js +2 -3
  46. package/dist/device/meter.js.map +1 -1
  47. package/dist/device/meterplus.d.ts.map +1 -1
  48. package/dist/device/meterplus.js +2 -3
  49. package/dist/device/meterplus.js.map +1 -1
  50. package/dist/device/motion.d.ts.map +1 -1
  51. package/dist/device/motion.js +2 -3
  52. package/dist/device/motion.js.map +1 -1
  53. package/dist/device/plug.d.ts.map +1 -1
  54. package/dist/device/plug.js +3 -5
  55. package/dist/device/plug.js.map +1 -1
  56. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  57. package/dist/device/robotvacuumcleaner.js +7 -11
  58. package/dist/device/robotvacuumcleaner.js.map +1 -1
  59. package/dist/device/waterdetector.d.ts.map +1 -1
  60. package/dist/device/waterdetector.js +2 -3
  61. package/dist/device/waterdetector.js.map +1 -1
  62. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  63. package/dist/irdevice/airconditioner.js +2 -3
  64. package/dist/irdevice/airconditioner.js.map +1 -1
  65. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  66. package/dist/irdevice/airpurifier.js +2 -3
  67. package/dist/irdevice/airpurifier.js.map +1 -1
  68. package/dist/irdevice/camera.d.ts.map +1 -1
  69. package/dist/irdevice/camera.js +2 -3
  70. package/dist/irdevice/camera.js.map +1 -1
  71. package/dist/irdevice/fan.d.ts.map +1 -1
  72. package/dist/irdevice/fan.js +2 -3
  73. package/dist/irdevice/fan.js.map +1 -1
  74. package/dist/irdevice/irdevice.d.ts +1 -0
  75. package/dist/irdevice/irdevice.d.ts.map +1 -1
  76. package/dist/irdevice/irdevice.js +4 -0
  77. package/dist/irdevice/irdevice.js.map +1 -1
  78. package/dist/irdevice/light.d.ts.map +1 -1
  79. package/dist/irdevice/light.js +2 -3
  80. package/dist/irdevice/light.js.map +1 -1
  81. package/dist/irdevice/other.d.ts.map +1 -1
  82. package/dist/irdevice/other.js +2 -3
  83. package/dist/irdevice/other.js.map +1 -1
  84. package/dist/irdevice/tv.d.ts.map +1 -1
  85. package/dist/irdevice/tv.js +2 -3
  86. package/dist/irdevice/tv.js.map +1 -1
  87. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  88. package/dist/irdevice/vacuumcleaner.js +2 -3
  89. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  90. package/dist/irdevice/waterheater.d.ts.map +1 -1
  91. package/dist/irdevice/waterheater.js +2 -3
  92. package/dist/irdevice/waterheater.js.map +1 -1
  93. package/dist/settings.d.ts +3 -2
  94. package/dist/settings.d.ts.map +1 -1
  95. package/dist/settings.js.map +1 -1
  96. package/package.json +5 -5
  97. package/src/device/blindtilt.ts +42 -124
  98. package/src/device/bot.ts +3 -5
  99. package/src/device/ceilinglight.ts +19 -42
  100. package/src/device/colorbulb.ts +14 -41
  101. package/src/device/contact.ts +29 -55
  102. package/src/device/curtain.ts +43 -140
  103. package/src/device/device.ts +89 -7
  104. package/src/device/fan.ts +36 -51
  105. package/src/device/hub.ts +2 -3
  106. package/src/device/humidifier.ts +3 -5
  107. package/src/device/iosensor.ts +2 -3
  108. package/src/device/lightstrip.ts +3 -5
  109. package/src/device/lock.ts +3 -5
  110. package/src/device/meter.ts +2 -3
  111. package/src/device/meterplus.ts +2 -3
  112. package/src/device/motion.ts +2 -3
  113. package/src/device/plug.ts +3 -5
  114. package/src/device/robotvacuumcleaner.ts +7 -11
  115. package/src/device/waterdetector.ts +2 -3
  116. package/src/irdevice/airconditioner.ts +2 -3
  117. package/src/irdevice/airpurifier.ts +2 -3
  118. package/src/irdevice/camera.ts +2 -3
  119. package/src/irdevice/fan.ts +2 -3
  120. package/src/irdevice/irdevice.ts +5 -0
  121. package/src/irdevice/light.ts +2 -3
  122. package/src/irdevice/other.ts +2 -3
  123. package/src/irdevice/tv.ts +2 -3
  124. package/src/irdevice/vacuumcleaner.ts +2 -3
  125. package/src/irdevice/waterheater.ts +2 -3
  126. package/src/settings.ts +3 -2
@@ -278,9 +278,8 @@ export class IOSensor extends deviceBase {
278
278
  await this.statusCodes(statusCode, deviceStatus);
279
279
  }
280
280
  } catch (e: any) {
281
- this.apiError(e);
282
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}`
283
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
281
+ await this.apiError(e);
282
+ await this.openAPIRefreshError(e);
284
283
  }
285
284
  }
286
285
 
@@ -327,9 +327,8 @@ export class StripLight extends deviceBase {
327
327
  await this.statusCodes(statusCode, deviceStatus);
328
328
  }
329
329
  } catch (e: any) {
330
- this.apiError(e);
331
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}`
332
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
330
+ await this.apiError(e);
331
+ await this.openAPIRefreshError(e);
333
332
  }
334
333
  }
335
334
 
@@ -423,8 +422,7 @@ export class StripLight extends deviceBase {
423
422
  await this.openAPIpushChanges();
424
423
  } else {
425
424
  await this.offlineOff();
426
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
427
- + ` ${this.device.connectionType}, pushChanges will not happen.`);
425
+ await this.pushChangeDisabled();
428
426
  }
429
427
  // Refresh the status from the API
430
428
  interval(15000)
@@ -326,9 +326,8 @@ export class Lock extends deviceBase {
326
326
  await this.statusCodes(statusCode, deviceStatus);
327
327
  }
328
328
  } catch (e: any) {
329
- this.apiError(e);
330
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}`
331
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
329
+ await this.apiError(e);
330
+ await this.openAPIRefreshError(e);
332
331
  }
333
332
  }
334
333
 
@@ -367,8 +366,7 @@ export class Lock extends deviceBase {
367
366
  await this.openAPIpushChanges();
368
367
  } else {
369
368
  await this.offlineOff();
370
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
371
- + ` ${this.device.connectionType}, pushChanges will not happen.`);
369
+ await this.pushChangeDisabled();
372
370
  }
373
371
  // Refresh the status from the API
374
372
  interval(15000)
@@ -271,9 +271,8 @@ export class Meter extends deviceBase {
271
271
  await this.statusCodes(statusCode, deviceStatus);
272
272
  }
273
273
  } catch (e: any) {
274
- this.apiError(e);
275
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}`
276
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
274
+ await this.apiError(e);
275
+ await this.openAPIRefreshError(e);
277
276
  }
278
277
  }
279
278
 
@@ -275,9 +275,8 @@ export class MeterPlus extends deviceBase {
275
275
  await this.statusCodes(statusCode, deviceStatus);
276
276
  }
277
277
  } catch (e: any) {
278
- this.apiError(e);
279
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}`
280
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
278
+ await this.apiError(e);
279
+ await this.openAPIRefreshError(e);
281
280
  }
282
281
  }
283
282
 
@@ -284,9 +284,8 @@ export class Motion extends deviceBase {
284
284
  await this.statusCodes(statusCode, deviceStatus);
285
285
  }
286
286
  } catch (e: any) {
287
- this.apiError(e);
288
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}`
289
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
287
+ await this.apiError(e);
288
+ await this.openAPIRefreshError(e);
290
289
  }
291
290
  }
292
291
 
@@ -179,9 +179,8 @@ export class Plug extends deviceBase {
179
179
  await this.statusCodes(statusCode, deviceStatus);
180
180
  }
181
181
  } catch (e: any) {
182
- this.apiError(e);
183
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}`
184
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
182
+ await this.apiError(e);
183
+ await this.openAPIRefreshError(e);
185
184
  }
186
185
  }
187
186
 
@@ -224,8 +223,7 @@ export class Plug extends deviceBase {
224
223
  await this.openAPIpushChanges();
225
224
  } else {
226
225
  await this.offlineOff();
227
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
228
- + ` ${this.device.connectionType}, pushChanges will not happen.`);
226
+ await this.pushChangeDisabled();
229
227
  }
230
228
  // Refresh the status from the API
231
229
  interval(15000)
@@ -264,9 +264,8 @@ export class RobotVacuumCleaner extends deviceBase {
264
264
  await this.statusCodes(statusCode, deviceStatus);
265
265
  }
266
266
  } catch (e: any) {
267
- this.apiError(e);
268
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}`
269
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
267
+ await this.apiError(e);
268
+ await this.openAPIRefreshError(e);
270
269
  }
271
270
  }
272
271
 
@@ -313,8 +312,7 @@ export class RobotVacuumCleaner extends deviceBase {
313
312
  await this.openAPIpushChanges();
314
313
  } else {
315
314
  await this.offlineOff();
316
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
317
- + ` ${this.device.connectionType}, pushChanges will not happen.`);
315
+ await this.pushChangeDisabled();
318
316
  }
319
317
  // Refresh the status from the API
320
318
  interval(15000)
@@ -388,9 +386,8 @@ export class RobotVacuumCleaner extends deviceBase {
388
386
  this.statusCode(deviceStatus.statusCode);
389
387
  }
390
388
  } catch (e: any) {
391
- this.apiError(e);
392
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIpushChanges with ${this.device.connectionType}`
393
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
389
+ await this.apiError(e);
390
+ await this.pushChangeError('openAPIpushChanges', e);
394
391
  }
395
392
  } else {
396
393
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No openAPIpushChanges, On: ${this.LightBulb.On}, `
@@ -414,9 +411,8 @@ export class RobotVacuumCleaner extends deviceBase {
414
411
  await this.statusCode(deviceStatus.statusCode);
415
412
  }
416
413
  } catch (e: any) {
417
- this.apiError(e);
418
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIpushChanges with ${this.device.connectionType}`
419
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
414
+ await this.apiError(e);
415
+ await this.pushChangeError('openAPIpushBrightnessChanges', e);
420
416
  }
421
417
  }
422
418
 
@@ -227,9 +227,8 @@ export class WaterDetector extends deviceBase {
227
227
  await this.statusCodes(statusCode, deviceStatus);
228
228
  }
229
229
  } catch (e: any) {
230
- this.apiError(e);
231
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}`
232
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
230
+ await this.apiError(e);
231
+ await this.openAPIRefreshError(e);
233
232
  }
234
233
  }
235
234
 
@@ -358,9 +358,8 @@ export class AirConditioner extends irdeviceBase {
358
358
  await this.statusCode(deviceStatus.statusCode);
359
359
  }
360
360
  } catch (e: any) {
361
- this.apiError(e);
362
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}`
363
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
361
+ await this.apiError(e);
362
+ await this.pushChangeError(e);
364
363
  }
365
364
  } else {
366
365
  this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
@@ -235,9 +235,8 @@ export class AirPurifier extends irdeviceBase {
235
235
  await this.statusCode(deviceStatus.statusCode);
236
236
  }
237
237
  } catch (e: any) {
238
- this.apiError(e);
239
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}`
240
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
238
+ await this.apiError(e);
239
+ await this.pushChangeError(e);
241
240
  }
242
241
  } else {
243
242
  this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
@@ -113,9 +113,8 @@ export class Camera extends irdeviceBase {
113
113
  await this.statusCode(deviceStatus.statusCode);
114
114
  }
115
115
  } catch (e: any) {
116
- this.apiError(e);
117
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}`
118
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
116
+ await this.apiError(e);
117
+ await this.pushChangeError(e);
119
118
  }
120
119
  } else {
121
120
  this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
@@ -213,9 +213,8 @@ export class IRFan extends irdeviceBase {
213
213
  await this.statusCode(deviceStatus.statusCode);
214
214
  }
215
215
  } catch (e: any) {
216
- this.apiError(e);
217
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}`
218
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
216
+ await this.apiError(e);
217
+ await this.pushChangeError(e);
219
218
  }
220
219
  } else {
221
220
  this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
@@ -213,6 +213,11 @@ export abstract class irdeviceBase {
213
213
  + ` body: ${JSON.stringify(JSON.parse(bodyChange))} sent successfully`);
214
214
  }
215
215
 
216
+ async pushChangeError(e: Error) {
217
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}`
218
+ + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
219
+ }
220
+
216
221
  async disablePushOnChanges(device: irdevice & irDevicesConfig): Promise<void> {
217
222
  if (device.disablePushOn === undefined) {
218
223
  this.disablePushOn = false;
@@ -227,9 +227,8 @@ export class Light extends irdeviceBase {
227
227
  await this.statusCode(deviceStatus.statusCode);
228
228
  }
229
229
  } catch (e: any) {
230
- this.apiError(e);
231
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}`
232
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
230
+ await this.apiError(e);
231
+ await this.pushChangeError(e);
233
232
  }
234
233
  } else {
235
234
  this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName} Connection Type: `
@@ -544,9 +544,8 @@ export class Others extends irdeviceBase {
544
544
  await this.statusCode(deviceStatus.statusCode);
545
545
  }
546
546
  } catch (e: any) {
547
- this.apiError(e);
548
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}`
549
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
547
+ await this.apiError(e);
548
+ await this.pushChangeError(e);
550
549
  }
551
550
  } else {
552
551
  this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
@@ -376,9 +376,8 @@ export class TV extends irdeviceBase {
376
376
  await this.statusCode(deviceStatus.statusCode);
377
377
  }
378
378
  } catch (e: any) {
379
- this.apiError(e);
380
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushTVChanges with ${this.device.connectionType}`
381
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
379
+ await this.apiError(e);
380
+ await this.pushChangeError(e);
382
381
  }
383
382
  } else {
384
383
  this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
@@ -110,9 +110,8 @@ export class VacuumCleaner extends irdeviceBase {
110
110
  await this.statusCode(deviceStatus.statusCode);
111
111
  }
112
112
  } catch (e: any) {
113
- this.apiError(e);
114
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChange`
115
- + ` with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
113
+ await this.apiError(e);
114
+ await this.pushChangeError(e);
116
115
  }
117
116
  } else {
118
117
  this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
@@ -112,9 +112,8 @@ export class WaterHeater extends irdeviceBase {
112
112
  await this.statusCode(deviceStatus.statusCode);
113
113
  }
114
114
  } catch (e: any) {
115
- this.apiError(e);
116
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}`
117
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
115
+ await this.apiError(e);
116
+ await this.pushChangeError(e);
118
117
  }
119
118
  } else {
120
119
  this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
package/src/settings.ts CHANGED
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import type { IClientOptions } from 'async-mqtt';
6
6
  import type { MacAddress, PlatformConfig } from 'homebridge';
7
+ import type { SwitchBotBLEModel, SwitchBotBLEModelName } from './utils';
7
8
  /**
8
9
  * This is the name of the platform that users will use to register the plugin in the Homebridge config.json
9
10
  */
@@ -70,8 +71,8 @@ export type options = {
70
71
  export interface devicesConfig extends device {
71
72
  bleMac?: string;
72
73
  model?: string;
73
- bleModel?: string;
74
- bleModelName?: string;
74
+ bleModel?: SwitchBotBLEModel;
75
+ bleModelName?: SwitchBotBLEModelName;
75
76
  configDeviceType: string;
76
77
  configDeviceName?: string;
77
78
  deviceId: string;