Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Bre77 committed Jul 21, 2024
1 parent 7b0c1a7 commit 170a203
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"files.eol": "\n",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
"source.fixAll.eslint": false
},
"editor.rulers": [ 140 ],
"editor.rulers": [140],
"eslint.enable": true
}
}
2 changes: 1 addition & 1 deletion src/utils/wake.ts → src/utils/wait.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Returns a Promise that waits for the given number of milliseconds
* (via setTimeout), then resolves.
*/
export async function wait(ms: number = 0) {
export async function wait(ms: number = 1000) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
Expand Down
2 changes: 2 additions & 0 deletions src/vehicle-services/chargelimit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Characteristic, CharacteristicValue } from "homebridge";
import { debounce } from "../utils/debounce.js";
import { VehicleAccessory } from "../vehicle.js";
import { BaseService } from "./base.js";
import { wait } from "../utils/wait.js";

Check failure on line 5 in src/vehicle-services/chargelimit.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

'wait' is defined but never used

Check failure on line 5 in src/vehicle-services/chargelimit.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'wait' is defined but never used

export class ChargeLimitService extends BaseService {

Expand Down Expand Up @@ -30,6 +31,7 @@ export class ChargeLimitService extends BaseService {
value = Math.max(this.min, Math.min(this.max, value as number));
await this.parent.wakeUpAndWait()
.then(() => this.vehicle.set_charge_limit(value))
//.then(() => wait())
.then(() => characteristic.updateValue(value))
.catch((e) => this.log.error(`${this.name} vehicle set_charge_limit failed: ${e}`));
}
Expand Down
9 changes: 7 additions & 2 deletions src/vehicle-services/lock.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { wait } from "../utils/wait.js";

Check failure on line 1 in src/vehicle-services/lock.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

'wait' is defined but never used

Check failure on line 1 in src/vehicle-services/lock.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'wait' is defined but never used
import { VehicleAccessory } from "../vehicle.js";
import { BaseService } from "./base.js";

Expand All @@ -11,15 +12,19 @@ export class LockService extends BaseService {
const targetState = this.service
.getCharacteristic(this.parent.platform.Characteristic.LockTargetState)
.onSet(async (value) => {
console.log(value)

Check warning on line 15 in src/vehicle-services/lock.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Unexpected console statement

Check warning on line 15 in src/vehicle-services/lock.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Missing semicolon

Check warning on line 15 in src/vehicle-services/lock.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Unexpected console statement

Check warning on line 15 in src/vehicle-services/lock.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Missing semicolon
this.service.setCharacteristic(this.parent.platform.Characteristic.LockTargetState, value)

Check warning on line 16 in src/vehicle-services/lock.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Missing semicolon

Check warning on line 16 in src/vehicle-services/lock.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Missing semicolon
targetState.updateValue(value);
await this.parent.wakeUpAndWait().then(() =>
value ?
this.parent.vehicle.door_lock()
.then(() => currentState.updateValue(1))
//.then(() => wait())
.then(() => currentState.updateValue(value))
.catch((e) => this.log.error(`${this.name} vehicle door_lock failed: ${e}`))
:
this.parent.vehicle.door_unlock()
.then(() => currentState.updateValue(0))
//.then(() => wait())
.then(() => currentState.updateValue(value))
.catch((e) => this.log.error(`${this.name} vehicle door_unlock failed: ${e}`))
);
});
Expand Down

0 comments on commit 170a203

Please sign in to comment.