-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
41 lines (33 loc) · 1.24 KB
/
index.js
File metadata and controls
41 lines (33 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"use strict";
try {
require("./store.json");
} catch (err) {
console.log(
"Could not find store.json. Generate one by running generate-store-json with your login details"
);
process.exit();
}
const GigyaApi = require("node-gigya-api");
const MyRenaultApi = require("node-my-renault-api");
const { loginToken, accountId, vin } = require("./store.json");
const run = async () => {
const gigyaApi = new GigyaApi(loginToken);
const myRenault = new MyRenaultApi(gigyaApi);
await myRenault.refreshTokens(accountId);
const myCar = myRenault.selectCar(vin);
const gets = {
batteryStatus: await myCar.fetchBatteryStatus(),
hvacStatus: await myCar.fetchHVACStatus(),
charges: await myCar.fetchCharges(),
dailyChargeHistory: await myCar.fetchDailyChargeHistory(),
monthlyChargeHistory: await myCar.fetchMonthlyChargeHistory(),
hvacSessions: await myCar.fetchHVACSessions(),
dailyHVACHistory: await myCar.fetchDailyHVACHistory(),
monthlyHVACHistory: await myCar.fetchMonthlyHVACHistory(),
cockpit: await myCar.fetchCockpit()
};
// const startPreconditioning = await myCar.startPreconditioning(18);
// const stopPreconditioning = await myCar.stopPreconditioning();
console.log(JSON.stringify(gets));
};
run();