@switchbot/homebridge-switchbot 2.2.2-beta.15 → 2.2.2-beta.17

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 (51) hide show
  1. package/dist/device/bot.d.ts.map +1 -1
  2. package/dist/device/bot.js +3 -1
  3. package/dist/device/bot.js.map +1 -1
  4. package/dist/device/ceilinglight.d.ts.map +1 -1
  5. package/dist/device/ceilinglight.js +3 -1
  6. package/dist/device/ceilinglight.js.map +1 -1
  7. package/dist/device/colorbulb.d.ts.map +1 -1
  8. package/dist/device/colorbulb.js +3 -1
  9. package/dist/device/colorbulb.js.map +1 -1
  10. package/dist/device/contact.d.ts.map +1 -1
  11. package/dist/device/contact.js +3 -1
  12. package/dist/device/contact.js.map +1 -1
  13. package/dist/device/curtain.d.ts +0 -1
  14. package/dist/device/curtain.d.ts.map +1 -1
  15. package/dist/device/curtain.js +16 -14
  16. package/dist/device/curtain.js.map +1 -1
  17. package/dist/device/humidifier.d.ts.map +1 -1
  18. package/dist/device/humidifier.js +3 -1
  19. package/dist/device/humidifier.js.map +1 -1
  20. package/dist/device/lock.d.ts.map +1 -1
  21. package/dist/device/lock.js +3 -1
  22. package/dist/device/lock.js.map +1 -1
  23. package/dist/device/meter.d.ts.map +1 -1
  24. package/dist/device/meter.js +3 -1
  25. package/dist/device/meter.js.map +1 -1
  26. package/dist/device/meterplus.d.ts.map +1 -1
  27. package/dist/device/meterplus.js +3 -1
  28. package/dist/device/meterplus.js.map +1 -1
  29. package/dist/device/motion.d.ts +0 -3
  30. package/dist/device/motion.d.ts.map +1 -1
  31. package/dist/device/motion.js +16 -12
  32. package/dist/device/motion.js.map +1 -1
  33. package/dist/device/plug.d.ts.map +1 -1
  34. package/dist/device/plug.js +3 -1
  35. package/dist/device/plug.js.map +1 -1
  36. package/dist/device/striplight.d.ts.map +1 -1
  37. package/dist/device/striplight.js +3 -1
  38. package/dist/device/striplight.js.map +1 -1
  39. package/package.json +1 -1
  40. package/src/device/bot.ts +3 -1
  41. package/src/device/ceilinglight.ts +3 -1
  42. package/src/device/colorbulb.ts +3 -1
  43. package/src/device/contact.ts +3 -1
  44. package/src/device/curtain.ts +14 -14
  45. package/src/device/humidifier.ts +3 -1
  46. package/src/device/lock.ts +3 -1
  47. package/src/device/meter.ts +3 -1
  48. package/src/device/meterplus.ts +3 -1
  49. package/src/device/motion.ts +14 -12
  50. package/src/device/plug.ts +3 -1
  51. package/src/device/striplight.ts +3 -1
@@ -441,7 +441,13 @@ export class Curtain {
441
441
  if (this.serviceData) {
442
442
  this.connected = true;
443
443
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
444
- await this.stopScanning({ switchbot: { switchbot } });
444
+ await switchbot.stopScan();
445
+ if (this.connected) {
446
+ await this.BLEparseStatus();
447
+ await this.updateHomeKitCharacteristics();
448
+ } else {
449
+ await this.BLERefreshConnection(switchbot);
450
+ }
445
451
  } else {
446
452
  this.connected = false;
447
453
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
@@ -452,7 +458,13 @@ export class Curtain {
452
458
  })
453
459
  .then(async () => {
454
460
  // Stop to monitor
455
- await this.stopScanning({ switchbot: { switchbot } });
461
+ await switchbot.stopScan();
462
+ if (this.connected) {
463
+ await this.BLEparseStatus();
464
+ await this.updateHomeKitCharacteristics();
465
+ } else {
466
+ await this.BLERefreshConnection(switchbot);
467
+ }
456
468
  })
457
469
  .catch(async (e: any) => {
458
470
  this.apiError(e);
@@ -806,18 +818,6 @@ export class Curtain {
806
818
  }
807
819
  }
808
820
 
809
- async stopScanning(switchbot: any) {
810
- if (switchbot) {
811
- await switchbot.stopScan();
812
- }
813
- if (this.connected) {
814
- await this.BLEparseStatus();
815
- await this.updateHomeKitCharacteristics();
816
- } else {
817
- await this.BLERefreshConnection(switchbot);
818
- }
819
- }
820
-
821
821
  async getCustomBLEAddress(switchbot: any) {
822
822
  if (this.device.customBLEaddress && this.deviceLogging.includes('debug')) {
823
823
  (async () => {
@@ -766,7 +766,9 @@ export class Humidifier {
766
766
  }
767
767
 
768
768
  async stopScanning({ switchbot }: { switchbot: any; }): Promise<void> {
769
- await switchbot.stopScan();
769
+ if (switchbot) {
770
+ await switchbot.stopScan();
771
+ }
770
772
  if (this.connected) {
771
773
  await this.BLEparseStatus();
772
774
  await this.updateHomeKitCharacteristics();
@@ -491,7 +491,9 @@ export class Lock {
491
491
  }
492
492
 
493
493
  async stopScanning({ switchbot }: { switchbot: any; }): Promise<void> {
494
- await switchbot.stopScan();
494
+ if (switchbot) {
495
+ await switchbot.stopScan();
496
+ }
495
497
  if (this.connected) {
496
498
  await this.BLEparseStatus();
497
499
  await this.updateHomeKitCharacteristics();
@@ -489,7 +489,9 @@ export class Meter {
489
489
  }
490
490
 
491
491
  async stopScanning({ switchbot }: { switchbot: any; }): Promise<void> {
492
- await switchbot.stopScan();
492
+ if (switchbot) {
493
+ await switchbot.stopScan();
494
+ }
493
495
  if (this.connected) {
494
496
  await this.BLEparseStatus();
495
497
  await this.updateHomeKitCharacteristics();
@@ -488,7 +488,9 @@ export class MeterPlus {
488
488
  }
489
489
 
490
490
  async stopScanning({ switchbot }: { switchbot: any; }): Promise<void> {
491
- await switchbot.stopScan();
491
+ if (switchbot) {
492
+ await switchbot.stopScan();
493
+ }
492
494
  if (this.connected) {
493
495
  await this.BLEparseStatus();
494
496
  await this.updateHomeKitCharacteristics();
@@ -277,7 +277,13 @@ export class Motion {
277
277
  if (this.serviceData) {
278
278
  this.connected = true;
279
279
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
280
- await this.stopScanning({ switchbot: { switchbot } });
280
+ await switchbot.stopScan();
281
+ if (this.connected) {
282
+ await this.BLEparseStatus();
283
+ await this.updateHomeKitCharacteristics();
284
+ } else {
285
+ await this.BLERefreshConnection(switchbot);
286
+ }
281
287
  } else {
282
288
  this.connected = false;
283
289
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
@@ -288,7 +294,13 @@ export class Motion {
288
294
  })
289
295
  .then(async () => {
290
296
  // Stop to monitor
291
- await this.stopScanning({ switchbot: { switchbot } });
297
+ await switchbot.stopScan();
298
+ if (this.connected) {
299
+ await this.BLEparseStatus();
300
+ await this.updateHomeKitCharacteristics();
301
+ } else {
302
+ await this.BLERefreshConnection(switchbot);
303
+ }
292
304
  })
293
305
  .catch(async (e: any) => {
294
306
  this.apiError(e);
@@ -394,16 +406,6 @@ export class Motion {
394
406
  }
395
407
  }
396
408
 
397
- async stopScanning({ switchbot }: { switchbot: any; }): Promise<void> {
398
- await await switchbot.stopScan();
399
- if (this.connected) {
400
- await this.BLEparseStatus();
401
- await this.updateHomeKitCharacteristics();
402
- } else {
403
- await this.BLERefreshConnection(switchbot);
404
- }
405
- }
406
-
407
409
  async getCustomBLEAddress(switchbot: any) {
408
410
  if (this.device.customBLEaddress && this.deviceLogging.includes('debug')) {
409
411
  (async () => {
@@ -459,7 +459,9 @@ export class Plug {
459
459
  }
460
460
 
461
461
  async stopScanning({ switchbot }: { switchbot: any; }): Promise<void> {
462
- await switchbot.stopScan();
462
+ if (switchbot) {
463
+ await switchbot.stopScan();
464
+ }
463
465
  if (this.connected) {
464
466
  await this.BLEparseStatus();
465
467
  await this.updateHomeKitCharacteristics();
@@ -831,7 +831,9 @@ export class StripLight {
831
831
  }
832
832
 
833
833
  async stopScanning({ switchbot }: { switchbot: any; }): Promise<void> {
834
- await switchbot.stopScan();
834
+ if (switchbot) {
835
+ await switchbot.stopScan();
836
+ }
835
837
  if (this.connected) {
836
838
  await this.BLEparseStatus();
837
839
  await this.updateHomeKitCharacteristics();