@switchbot/homebridge-switchbot 3.6.1-beta.0 → 3.6.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 (93) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/config.schema.json +11 -0
  3. package/dist/device/blindtilt.d.ts.map +1 -1
  4. package/dist/device/blindtilt.js +36 -18
  5. package/dist/device/blindtilt.js.map +1 -1
  6. package/dist/device/bot.d.ts +1 -2
  7. package/dist/device/bot.d.ts.map +1 -1
  8. package/dist/device/bot.js +186 -396
  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 +36 -19
  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 +36 -19
  15. package/dist/device/colorbulb.js.map +1 -1
  16. package/dist/device/contact.d.ts.map +1 -1
  17. package/dist/device/contact.js +36 -19
  18. package/dist/device/contact.js.map +1 -1
  19. package/dist/device/curtain.d.ts.map +1 -1
  20. package/dist/device/curtain.js +37 -18
  21. package/dist/device/curtain.js.map +1 -1
  22. package/dist/device/device.js +2 -2
  23. package/dist/device/device.js.map +1 -1
  24. package/dist/device/fan.d.ts.map +1 -1
  25. package/dist/device/fan.js +36 -19
  26. package/dist/device/fan.js.map +1 -1
  27. package/dist/device/hub.d.ts.map +1 -1
  28. package/dist/device/hub.js +36 -17
  29. package/dist/device/hub.js.map +1 -1
  30. package/dist/device/humidifier.d.ts.map +1 -1
  31. package/dist/device/humidifier.js +36 -17
  32. package/dist/device/humidifier.js.map +1 -1
  33. package/dist/device/iosensor.d.ts.map +1 -1
  34. package/dist/device/iosensor.js +36 -17
  35. package/dist/device/iosensor.js.map +1 -1
  36. package/dist/device/lightstrip.d.ts.map +1 -1
  37. package/dist/device/lightstrip.js +36 -17
  38. package/dist/device/lightstrip.js.map +1 -1
  39. package/dist/device/lock.d.ts.map +1 -1
  40. package/dist/device/lock.js +37 -18
  41. package/dist/device/lock.js.map +1 -1
  42. package/dist/device/meter.d.ts.map +1 -1
  43. package/dist/device/meter.js +36 -17
  44. package/dist/device/meter.js.map +1 -1
  45. package/dist/device/meterplus.d.ts.map +1 -1
  46. package/dist/device/meterplus.js +36 -17
  47. package/dist/device/meterplus.js.map +1 -1
  48. package/dist/device/motion.d.ts.map +1 -1
  49. package/dist/device/motion.js +36 -17
  50. package/dist/device/motion.js.map +1 -1
  51. package/dist/device/plug.d.ts.map +1 -1
  52. package/dist/device/plug.js +37 -18
  53. package/dist/device/plug.js.map +1 -1
  54. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  55. package/dist/device/robotvacuumcleaner.js +36 -17
  56. package/dist/device/robotvacuumcleaner.js.map +1 -1
  57. package/dist/device/waterdetector.d.ts.map +1 -1
  58. package/dist/device/waterdetector.js +36 -17
  59. package/dist/device/waterdetector.js.map +1 -1
  60. package/dist/irdevice/other.d.ts +1 -0
  61. package/dist/irdevice/other.d.ts.map +1 -1
  62. package/dist/irdevice/other.js +186 -228
  63. package/dist/irdevice/other.js.map +1 -1
  64. package/dist/platform.d.ts +4 -0
  65. package/dist/platform.d.ts.map +1 -1
  66. package/dist/platform.js +32 -0
  67. package/dist/platform.js.map +1 -1
  68. package/dist/settings.d.ts +1 -0
  69. package/dist/settings.d.ts.map +1 -1
  70. package/dist/settings.js.map +1 -1
  71. package/package.json +3 -3
  72. package/src/device/blindtilt.ts +33 -18
  73. package/src/device/bot.ts +179 -406
  74. package/src/device/ceilinglight.ts +33 -20
  75. package/src/device/colorbulb.ts +33 -20
  76. package/src/device/contact.ts +33 -20
  77. package/src/device/curtain.ts +34 -18
  78. package/src/device/device.ts +2 -2
  79. package/src/device/fan.ts +33 -20
  80. package/src/device/hub.ts +33 -17
  81. package/src/device/humidifier.ts +33 -17
  82. package/src/device/iosensor.ts +33 -17
  83. package/src/device/lightstrip.ts +33 -17
  84. package/src/device/lock.ts +34 -18
  85. package/src/device/meter.ts +33 -17
  86. package/src/device/meterplus.ts +33 -17
  87. package/src/device/motion.ts +33 -17
  88. package/src/device/plug.ts +34 -18
  89. package/src/device/robotvacuumcleaner.ts +33 -17
  90. package/src/device/waterdetector.ts +33 -17
  91. package/src/irdevice/other.ts +214 -283
  92. package/src/platform.ts +30 -0
  93. package/src/settings.ts +1 -0
package/src/platform.ts CHANGED
@@ -78,6 +78,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
78
78
  public readonly eve: any;
79
79
  public readonly fakegatoAPI: any;
80
80
  public readonly webhookEventHandler: { [x: string]: (context: any) => void } = {};
81
+ public readonly bleEventHandler: { [x: string]: (context: any) => void } = {};
81
82
 
82
83
  constructor(
83
84
  log: Logging,
@@ -148,6 +149,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
148
149
 
149
150
  this.setupMqtt();
150
151
  this.setupwebhook();
152
+ this.setupBlE();
151
153
  }
152
154
 
153
155
  async setupMqtt(): Promise<void> {
@@ -312,6 +314,34 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
312
314
  }
313
315
  }
314
316
 
317
+ async setupBlE() {
318
+ if (this.config.options?.BLE) {
319
+ await this.debugLog('setupBLE');
320
+ const SwitchBot = (await import('node-switchbot')).SwitchBot;
321
+ const switchbot = new SwitchBot();
322
+ if (switchbot === undefined) {
323
+ await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
324
+ } else {
325
+ // Start to monitor advertisement packets
326
+ (async () => {
327
+ // Start to monitor advertisement packets
328
+ await this.debugLog('Scanning for BLE SwitchBot devices...');
329
+ await switchbot.startScan();
330
+ // Set an event handler to monitor advertisement packets
331
+ switchbot.onadvertisement = async (ad: any) => {
332
+ try {
333
+ this.bleEventHandler[ad.address]?.(ad.serviceData);
334
+ } catch (e: any) {
335
+ await this.errorLog(`Failed to handle BLE event. Error:${e}`);
336
+ }
337
+ };
338
+ })();
339
+ }
340
+ } else {
341
+ await this.debugLog('Platform BLE is not enabled');
342
+ }
343
+ }
344
+
315
345
  /**
316
346
  * This function is invoked when homebridge restores cached accessories from disk at startup.
317
347
  * It should be used to setup event handlers for characteristics and update respective values.
package/src/settings.ts CHANGED
@@ -61,6 +61,7 @@ interface options {
61
61
  mqttURL?: string;
62
62
  mqttOptions?: IClientOptions;
63
63
  mqttPubOptions?: IClientOptions;
64
+ BLE?: boolean;
64
65
  webhookURL?: string;
65
66
  maxRetries?: number;
66
67
  delayBetweenRetries?: number;