@switchbot/homebridge-switchbot 2.4.0 → 2.4.1-beta.0

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 (43) hide show
  1. package/.github/npm-version-script.js +81 -0
  2. package/dist/device/bot.d.ts +1 -2
  3. package/dist/device/bot.d.ts.map +1 -1
  4. package/dist/device/bot.js +4 -4
  5. package/dist/device/bot.js.map +1 -1
  6. package/dist/device/ceilinglight.d.ts +1 -2
  7. package/dist/device/ceilinglight.d.ts.map +1 -1
  8. package/dist/device/ceilinglight.js +4 -4
  9. package/dist/device/ceilinglight.js.map +1 -1
  10. package/dist/device/colorbulb.d.ts +1 -2
  11. package/dist/device/colorbulb.d.ts.map +1 -1
  12. package/dist/device/colorbulb.js +4 -4
  13. package/dist/device/colorbulb.js.map +1 -1
  14. package/dist/device/curtain.d.ts +1 -2
  15. package/dist/device/curtain.d.ts.map +1 -1
  16. package/dist/device/curtain.js +4 -4
  17. package/dist/device/curtain.js.map +1 -1
  18. package/dist/device/plug.d.ts +1 -2
  19. package/dist/device/plug.d.ts.map +1 -1
  20. package/dist/device/plug.js +4 -4
  21. package/dist/device/plug.js.map +1 -1
  22. package/dist/device/robotvacuumcleaner.d.ts +1 -2
  23. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  24. package/dist/device/robotvacuumcleaner.js +4 -4
  25. package/dist/device/robotvacuumcleaner.js.map +1 -1
  26. package/dist/device/striplight.d.ts +1 -2
  27. package/dist/device/striplight.d.ts.map +1 -1
  28. package/dist/device/striplight.js +4 -4
  29. package/dist/device/striplight.js.map +1 -1
  30. package/dist/utils.d.ts +2 -0
  31. package/dist/utils.d.ts.map +1 -0
  32. package/dist/utils.js +8 -0
  33. package/dist/utils.js.map +1 -0
  34. package/homebridge-ui/public/index.html +1 -1
  35. package/package.json +1 -1
  36. package/src/device/bot.ts +4 -4
  37. package/src/device/ceilinglight.ts +4 -4
  38. package/src/device/colorbulb.ts +4 -4
  39. package/src/device/curtain.ts +4 -4
  40. package/src/device/plug.ts +4 -4
  41. package/src/device/robotvacuumcleaner.ts +4 -4
  42. package/src/device/striplight.ts +4 -4
  43. package/src/utils.ts +3 -0
@@ -8,6 +8,7 @@ import { SwitchBotPlatform } from '../platform';
8
8
  import { debounceTime, skipWhile, take, tap } from 'rxjs/operators';
9
9
  import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
10
10
  import { device, devicesConfig, deviceStatus, ad, serviceData, switchbot, HostDomain, DevicePath } from '../settings';
11
+ import { sleep } from '../utils';
11
12
 
12
13
  export class Plug {
13
14
  // Services
@@ -351,7 +352,6 @@ export class Plug {
351
352
  this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
352
353
  return await this.retry({
353
354
  max: await this.maxRetry(),
354
- switchbot,
355
355
  fn: () => {
356
356
  if (this.On) {
357
357
  return device_list[0].turnOn({ id: this.device.bleMac });
@@ -521,15 +521,15 @@ export class Plug {
521
521
  }
522
522
  }
523
523
 
524
- async retry({ max, switchbot, fn }: { max: number; switchbot: any, fn: { (): any; (): Promise<any> } }): Promise<null> {
524
+ async retry({ max, fn }: { max: number; fn: { (): any; (): Promise<any> } }): Promise<null> {
525
525
  return fn().catch(async (err: any) => {
526
526
  if (max === 0) {
527
527
  throw err;
528
528
  }
529
529
  this.infoLog(err);
530
530
  this.infoLog('Retrying');
531
- await switchbot.wait(1000);
532
- return this.retry({ max: max - 1, switchbot, fn });
531
+ await sleep(1000);
532
+ return this.retry({ max: max - 1, fn });
533
533
  });
534
534
  }
535
535
 
@@ -8,6 +8,7 @@ import { SwitchBotPlatform } from '../platform';
8
8
  import { debounceTime, skipWhile, take, tap } from 'rxjs/operators';
9
9
  import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
10
10
  import { device, devicesConfig, deviceStatus, ad, serviceData, switchbot, HostDomain, DevicePath } from '../settings';
11
+ import { sleep } from '../utils';
11
12
 
12
13
  export class RobotVacuumCleaner {
13
14
  // Services
@@ -362,7 +363,6 @@ export class RobotVacuumCleaner {
362
363
  this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
363
364
  return await this.retry({
364
365
  max: await this.maxRetry(),
365
- switchbot,
366
366
  fn: () => {
367
367
  if (this.On) {
368
368
  return device_list[0].turnOn({ id: this.device.bleMac });
@@ -645,15 +645,15 @@ export class RobotVacuumCleaner {
645
645
  }
646
646
  }
647
647
 
648
- async retry({ max, switchbot, fn }: { max: number; switchbot: any, fn: { (): any; (): Promise<any> } }): Promise<null> {
648
+ async retry({ max, fn }: { max: number; fn: { (): any; (): Promise<any> } }): Promise<null> {
649
649
  return fn().catch(async (err: any) => {
650
650
  if (max === 0) {
651
651
  throw err;
652
652
  }
653
653
  this.infoLog(err);
654
654
  this.infoLog('Retrying');
655
- await switchbot.wait(1000);
656
- return this.retry({ max: max - 1, switchbot, fn });
655
+ await sleep(1000);
656
+ return this.retry({ max: max - 1, fn });
657
657
  });
658
658
  }
659
659
 
@@ -8,6 +8,7 @@ import { SwitchBotPlatform } from '../platform';
8
8
  import { debounceTime, skipWhile, take, tap } from 'rxjs/operators';
9
9
  import { Service, PlatformAccessory, CharacteristicValue, ControllerConstructor, Controller, ControllerServiceMap } from 'homebridge';
10
10
  import { device, devicesConfig, switchbot, hs2rgb, rgb2hs, deviceStatus, HostDomain, DevicePath, ad, serviceData, m2hs } from '../settings';
11
+ import { sleep } from '../utils';
11
12
 
12
13
  /**
13
14
  * Platform Accessory
@@ -467,7 +468,6 @@ export class StripLight {
467
468
  this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
468
469
  return await this.retry({
469
470
  max: await this.maxRetry(),
470
- switchbot,
471
471
  fn: () => {
472
472
  if (this.On) {
473
473
  return device_list[0].turnOn({ id: this.device.bleMac });
@@ -886,15 +886,15 @@ export class StripLight {
886
886
  }
887
887
  }
888
888
 
889
- async retry({ max, switchbot, fn }: { max: number; switchbot: any, fn: { (): any; (): Promise<any> } }): Promise<null> {
889
+ async retry({ max, fn }: { max: number; fn: { (): any; (): Promise<any> } }): Promise<null> {
890
890
  return fn().catch(async (err: any) => {
891
891
  if (max === 0) {
892
892
  throw err;
893
893
  }
894
894
  this.infoLog(err);
895
895
  this.infoLog('Retrying');
896
- await switchbot.wait(1000);
897
- return this.retry({ max: max - 1, switchbot, fn });
896
+ await sleep(1000);
897
+ return this.retry({ max: max - 1, fn });
898
898
  });
899
899
  }
900
900
 
package/src/utils.ts ADDED
@@ -0,0 +1,3 @@
1
+ export function sleep(ms: number): Promise<void> {
2
+ return new Promise(resolve => setTimeout(resolve, ms));
3
+ }