@switchbot/homebridge-switchbot 2.4.0-beta.6 → 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.
- package/dist/device/bot.d.ts +1 -2
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +4 -4
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +1 -2
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +4 -4
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +1 -2
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +4 -4
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/curtain.d.ts +1 -2
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +4 -4
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/plug.d.ts +1 -2
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +4 -4
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +1 -2
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +4 -4
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/striplight.d.ts +1 -2
- package/dist/device/striplight.d.ts.map +1 -1
- package/dist/device/striplight.js +4 -4
- package/dist/device/striplight.js.map +1 -1
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +8 -0
- package/dist/utils.js.map +1 -0
- package/homebridge-ui/public/index.html +1 -1
- package/package.json +1 -1
- package/src/device/bot.ts +4 -4
- package/src/device/ceilinglight.ts +4 -4
- package/src/device/colorbulb.ts +4 -4
- package/src/device/curtain.ts +4 -4
- package/src/device/plug.ts +4 -4
- package/src/device/robotvacuumcleaner.ts +4 -4
- package/src/device/striplight.ts +4 -4
- package/src/utils.ts +3 -0
package/src/device/plug.ts
CHANGED
|
@@ -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,
|
|
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
|
|
532
|
-
return this.retry({ max: max - 1,
|
|
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,
|
|
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
|
|
656
|
-
return this.retry({ max: max - 1,
|
|
655
|
+
await sleep(1000);
|
|
656
|
+
return this.retry({ max: max - 1, fn });
|
|
657
657
|
});
|
|
658
658
|
}
|
|
659
659
|
|
package/src/device/striplight.ts
CHANGED
|
@@ -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,
|
|
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
|
|
897
|
-
return this.retry({ max: max - 1,
|
|
896
|
+
await sleep(1000);
|
|
897
|
+
return this.retry({ max: max - 1, fn });
|
|
898
898
|
});
|
|
899
899
|
}
|
|
900
900
|
|
package/src/utils.ts
ADDED