[teslajs] fix wrong Vehicle interface (#42724)

* [teslajs] fix wrong Vehicle interface

* [teslajs] Fix async functions parameters
This commit is contained in:
Felipe Castillo
2020-03-02 09:31:42 -08:00
committed by GitHub
parent 2c2ad2b5f4
commit d2b8167133
2 changed files with 24 additions and 22 deletions

View File

@@ -4,9 +4,9 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export interface Vehicle {
response: object;
id: string;
vehicleID: number;
[key: string]: string | number | boolean | null;
}
export interface TokenResponse {
response: object;
@@ -67,7 +67,7 @@ export function logoutAsync(authToken: string): Promise<void>;
export function vehicle(options: optionsType, callback: nodeBack): Vehicle;
export function vehicleAsync(options: optionsType): Promise<Vehicle>;
export function vehicles(options: optionsType, callback: nodeBack): void;
export function vehiclesAsync(options: optionsType): Promise<object[]>;
export function vehiclesAsync(options: optionsType): Promise<Array<{[key: string]: string | number | boolean | null}>>;
export function get_command(options: optionsType, command: string, callback: nodeBack): void;
export function get_commandAsync(options: optionsType, command: string): Promise<any>;
export function post_command(options: optionsType, command: string, body: object, callback: nodeBack): void;
@@ -107,7 +107,7 @@ export function scheduleSoftwareUpdateAsync(options: optionsType): Promise<Resul
export function cancelSoftwareUpdate(options: optionsType, callback: any): any;
export function cancelSoftwareUpdateAsync(options: optionsType): Promise<Result>;
export function navigationRequest(options: optionsType, subject: string, text: string, locale: string, callback: any): any;
export function navigationRequestAsync(options: optionsType): Promise<Result>;
export function navigationRequestAsync(options: optionsType, subject: string, text: string, locale: string): Promise<Result>;
export function mediaTogglePlayback(options: optionsType, callback: any): any;
export function mediaTogglePlaybackAsync(options: optionsType): Promise<Result>;
export function mediaPlayNext(options: optionsType, callback: any): any;
@@ -123,25 +123,25 @@ export function mediaVolumeUpAsync(options: optionsType): Promise<Result>;
export function mediaVolumeDown(options: optionsType, callback: any): any;
export function mediaVolumeDownAsync(options: optionsType): Promise<Result>;
export function speedLimitActivate(options: optionsType, pin: number, callback: any): any;
export function speedLimitActivateAsync(options: optionsType): Promise<Result>;
export function speedLimitActivateAsync(options: optionsType, pin: number): Promise<Result>;
export function speedLimitDeactivate(options: optionsType, pin: number, callback: any): any;
export function speedLimitDeactivateAsync(options: optionsType): Promise<Result>;
export function speedLimitDeactivateAsync(options: optionsType, pin: number): Promise<Result>;
export function speedLimitClearPin(options: optionsType, pin: number, callback: any): any;
export function speedLimitClearPinAsync(options: optionsType): Promise<Result>;
export function speedLimitClearPinAsync(options: optionsType, pin: number): Promise<Result>;
export function speedLimitSetLimit(options: optionsType, limit: number, callback: any): any;
export function speedLimitSetLimitAsync(options: optionsType): Promise<Result>;
export function speedLimitSetLimitAsync(options: optionsType, limit: number): Promise<Result>;
export function setSentryMode(options: optionsType, onoff: boolean, callback: any): any;
export function setSentryModeAsync(options: optionsType): Promise<Result>;
export function setSentryModeAsync(options: optionsType, onoff: boolean): Promise<Result>;
export function seatHeater(options: optionsType, heater: number, level: number, callback: any): any;
export function seatHeaterAsync(options: optionsType): Promise<Result>;
export function seatHeaterAsync(options: optionsType, heater: number, level: number): Promise<Result>;
export function steeringHeater(options: optionsType, level: number, callback: any): any;
export function steeringHeaterAsync(options: optionsType): Promise<Result>;
export function steeringHeaterAsync(options: optionsType, level: number): Promise<Result>;
export function maxDefrost(options: optionsType, onoff: boolean, callback: any): any;
export function maxDefrostAsync(options: optionsType): Promise<Result>;
export function maxDefrostAsync(options: optionsType, onoff: boolean): Promise<Result>;
export function windowControl(options: optionsType, command: string, callback: any): any;
export function windowControlAsync(options: optionsType): Promise<Result>;
export function windowControlAsync(options: optionsType, command: string): Promise<Result>;
export function setChargeLimit(options: optionsType, amt: any, callback: nodeBack): void;
export function setChargeLimitAsync(options: optionsType): Promise<Result>;
export function setChargeLimitAsync(options: optionsType, amt: any): Promise<Result>;
export function chargeStandard(options: optionsType, callback: nodeBack): void;
export function chargeStandardAsync(options: optionsType): Promise<Result>;
export function chargeMaxRange(options: optionsType, callback: nodeBack): void;
@@ -155,24 +155,24 @@ export function climateStartAsync(options: optionsType): Promise<Result>;
export function climateStop(options: optionsType, callback: nodeBack): void;
export function climateStopAsync(options: optionsType): Promise<Result>;
export function sunRoofControl(options: optionsType, state: string, callback: nodeBack): void;
export function sunRoofControlAsync(options: optionsType): Promise<Result>;
export function sunRoofControlAsync(options: optionsType, state: string): Promise<Result>;
export function sunRoofMove(options: optionsType, percent: any, callback: nodeBack): void;
export function sunRoofMoveAsync(options: optionsType): Promise<Result>;
export function sunRoofMoveAsync(options: optionsType, percent: any): Promise<Result>;
export function setTemps(options: optionsType, driver: number, pass: number, callback: nodeBack): void;
export function setTempsAsync(options: optionsType): Promise<Result>;
export function setTempsAsync(options: optionsType, driver: number, pass: number): Promise<Result>;
export function remoteStart(options: optionsType, password: string, callback: nodeBack): void;
export function remoteStartAsync(options: optionsType): Promise<Result>;
export function remoteStartAsync(options: optionsType, password: string): Promise<Result>;
export function openTrunk(options: optionsType, which: string, callback: nodeBack): void;
export function openTrunkAsync(options: optionsType): Promise<Result>;
export function openTrunkAsync(options: optionsType, which: string): Promise<Result>;
export function wakeUp(options: optionsType, callback: nodeBack): void;
export function wakeUpAsync(options: optionsType): Promise<object>;
export function setValetMode(options: optionsType, onoff: boolean, pin: any, callback: nodeBack): void;
export function setValetModeAsync(options: optionsType): Promise<Result>;
export function setValetModeAsync(options: optionsType, onoff: boolean, pin: any): Promise<Result>;
export function resetValetPin(options: optionsType, callback: nodeBack): void;
export function resetValetPinAsync(options: optionsType): Promise<Result>;
export function calendar(options: optionsType, entry: any, callback: nodeBack): void;
export function calendarAsync(options: optionsType): Promise<Result>;
export function calendarAsync(options: optionsType, entry: any): Promise<Result>;
export function makeCalendarEntry(eventName: string, location: string, startTime: number, endTime: number, accountName: string, phoneName: string): object;
export function homelink(options: optionsType, lat: number, long: number, token: any, callback: nodeBack): void;
export function homelinkAsync(options: optionsType): Promise<Result>;
export function homelink(options: optionsType, lat: number, long: number, token: string, callback: nodeBack): void;
export function homelinkAsync(options: optionsType, lat: number, long: number, token: string): Promise<Result>;
export function startStreaming(options: any, callback: nodeBack, onDataCb: nodeBack): any;

View File

@@ -6,8 +6,10 @@ async function main() {
tjs.login('username', 'password', (err, result) => {
const token = result.authToken;
});
const vehicle = await tjs.vehicleAsync(options);
const vehicleData = await tjs.vehicleDataAsync(options);
const chargeState = await tjs.chargeStateAsync(options);
await tjs.homelinkAsync(options, 36.98765432109876, -77.12345678901234, 'token');
}
main();