Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unneeded async #699

Merged
merged 2 commits into from
Mar 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homebridge-ui/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
style="width: 50%" />
</p>
<div id="pageIntro" style="display: none">
<p class="lead text-center">Thank you for installing<strong> homebridge-switchbot</strong></p>
<p class="lead text-center">Thank you for installing <strong>homebridge-switchbot</strong></p>
<p class="lead text-center">Before continuing:</p>
<ol>
<li class="mb-3">
Expand Down
10 changes: 4 additions & 6 deletions src/device/blindtilt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ export class BlindTilt {
.then(async (device_list: any) => {
this.infoLog(`${this.accessory.displayName} Target Position: ${this.TargetPosition}`);
return await this.retry({
max: await this.maxRetry(),
max: this.maxRetry(),
fn: async () => {
return await device_list[0].runToPos(100 - Number(this.TargetPosition), adjustedMode);
},
Expand Down Expand Up @@ -651,14 +651,12 @@ export class BlindTilt {
});
}

async maxRetry(): Promise<number> {
let maxRetry: number;
maxRetry(): number {
if (this.device.maxRetry) {
maxRetry = this.device.maxRetry;
return this.device.maxRetry;
} else {
maxRetry = 5;
return 5;
}
return maxRetry;
}

async openAPIpushChanges(): Promise<void> {
Expand Down
10 changes: 4 additions & 6 deletions src/device/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ export class Bot {
.then(async (device_list: any) => {
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
return await this.retry({
max: await this.maxRetry(),
max: this.maxRetry(),
fn: async () => {
if (this.On) {
return await device_list[0].turnOn({ id: this.device.bleMac });
Expand Down Expand Up @@ -1184,14 +1184,12 @@ export class Bot {
});
}

async maxRetry(): Promise<number> {
let maxRetry: number;
maxRetry(): number {
if (this.device.maxRetry) {
maxRetry = this.device.maxRetry;
return this.device.maxRetry;
} else {
maxRetry = 5;
return 5;
}
return maxRetry;
}

async PressOrSwitch(device: device & devicesConfig): Promise<void> {
Expand Down
10 changes: 4 additions & 6 deletions src/device/ceilinglight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ export class CeilingLight {
.then(async (device_list: any) => {
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
return await this.retry({
max: await this.maxRetry(),
max: this.maxRetry(),
fn: async () => {
if (this.On) {
return await device_list[0].turnOn({ id: this.device.bleMac });
Expand Down Expand Up @@ -977,14 +977,12 @@ export class CeilingLight {
});
}

async maxRetry(): Promise<number> {
let maxRetry: number;
maxRetry(): number {
if (this.device.maxRetry) {
maxRetry = this.device.maxRetry;
return this.device.maxRetry;
} else {
maxRetry = 5;
return 5;
}
return maxRetry;
}

minStep(device: device & devicesConfig): number {
Expand Down
10 changes: 4 additions & 6 deletions src/device/colorbulb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ export class ColorBulb {
.then(async (device_list: any) => {
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
return await this.retry({
max: await this.maxRetry(),
max: this.maxRetry(),
fn: async () => {
if (this.On) {
return await device_list[0].turnOn({ id: this.device.bleMac });
Expand Down Expand Up @@ -1134,14 +1134,12 @@ export class ColorBulb {
});
}

async maxRetry(): Promise<number> {
let maxRetry: number;
maxRetry(): number {
if (this.device.maxRetry) {
maxRetry = this.device.maxRetry;
return this.device.maxRetry;
} else {
maxRetry = 5;
return 5;
}
return maxRetry;
}

minStep(device: device & devicesConfig): number {
Expand Down
10 changes: 4 additions & 6 deletions src/device/curtain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ export class Curtain {
this.debugLog(`${this.accessory.displayName} Mode: ${this.Mode}`);
if (switchbot !== false) {
await this.retry({
max: await this.maxRetry(),
max: this.maxRetry(),
fn: () => {
return switchbot
.discover({ model: 'c', quick: true, id: this.device.bleMac })
Expand Down Expand Up @@ -613,14 +613,12 @@ export class Curtain {
});
}

async maxRetry(): Promise<number> {
let maxRetry: number;
maxRetry(): number {
if (this.device.maxRetry) {
maxRetry = this.device.maxRetry;
return this.device.maxRetry;
} else {
maxRetry = 5;
return 5;
}
return maxRetry;
}

async openAPIpushChanges(): Promise<void> {
Expand Down
10 changes: 4 additions & 6 deletions src/device/motion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export class Motion {
})
.then(async () => {
return await this.retry({
max: await this.maxRetry(),
max: this.maxRetry(),
fn: async () => {
// Set an event hander
this.scanning = true;
Expand Down Expand Up @@ -467,14 +467,12 @@ export class Motion {
});
}

async maxRetry(): Promise<number> {
let maxRetry: number;
maxRetry(): number {
if (this.device.maxRetry) {
maxRetry = this.device.maxRetry;
return this.device.maxRetry;
} else {
maxRetry = 5;
return 5;
}
return maxRetry;
}

minLux(): number {
Expand Down
10 changes: 4 additions & 6 deletions src/device/plug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ export class Plug {
.then(async (device_list: any) => {
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
return await this.retry({
max: await this.maxRetry(),
max: this.maxRetry(),
fn: async () => {
if (this.On) {
return await device_list[0].turnOn({ id: this.device.bleMac });
Expand Down Expand Up @@ -533,14 +533,12 @@ export class Plug {
});
}

async maxRetry(): Promise<number> {
let maxRetry: number;
maxRetry(): number {
if (this.device.maxRetry) {
maxRetry = this.device.maxRetry;
return this.device.maxRetry;
} else {
maxRetry = 5;
return 5;
}
return maxRetry;
}

model(device: device & devicesConfig): string {
Expand Down
10 changes: 4 additions & 6 deletions src/device/robotvacuumcleaner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ export class RobotVacuumCleaner {
.then(async (device_list: any) => {
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
return await this.retry({
max: await this.maxRetry(),
max: this.maxRetry(),
fn: async () => {
if (this.On) {
return await device_list[0].turnOn({ id: this.device.bleMac });
Expand Down Expand Up @@ -657,14 +657,12 @@ export class RobotVacuumCleaner {
});
}

async maxRetry(): Promise<number> {
let maxRetry: number;
maxRetry(): number {
if (this.device.maxRetry) {
maxRetry = this.device.maxRetry;
return this.device.maxRetry;
} else {
maxRetry = 5;
return 5;
}
return maxRetry;
}

model(device: device & devicesConfig): string {
Expand Down
10 changes: 4 additions & 6 deletions src/device/striplight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ export class StripLight {
.then(async (device_list: any) => {
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
return await this.retry({
max: await this.maxRetry(),
max: this.maxRetry(),
fn: async () => {
if (this.On) {
return await device_list[0].turnOn({ id: this.device.bleMac });
Expand Down Expand Up @@ -898,14 +898,12 @@ export class StripLight {
});
}

async maxRetry(): Promise<number> {
let maxRetry: number;
maxRetry(): number {
if (this.device.maxRetry) {
maxRetry = this.device.maxRetry;
return this.device.maxRetry;
} else {
maxRetry = 5;
return 5;
}
return maxRetry;
}

minStep(device: device & devicesConfig): number {
Expand Down