iobroker.renault 0.0.15 → 0.0.16
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/io-package.json +4 -1
- package/main.js +34 -9
- package/package.json +11 -11
package/io-package.json
CHANGED
package/main.js
CHANGED
|
@@ -7,10 +7,9 @@
|
|
|
7
7
|
// The adapter-core module gives you access to the core ioBroker functions
|
|
8
8
|
// you need to create an adapter
|
|
9
9
|
const utils = require("@iobroker/adapter-core");
|
|
10
|
-
const axios = require("axios");
|
|
10
|
+
const axios = require("axios").default;
|
|
11
11
|
const qs = require("qs");
|
|
12
12
|
const Json2iob = require("./lib/json2iob");
|
|
13
|
-
const descriptions = require("./lib/descriptions");
|
|
14
13
|
|
|
15
14
|
class Renault extends utils.Adapter {
|
|
16
15
|
/**
|
|
@@ -28,6 +27,7 @@ class Renault extends utils.Adapter {
|
|
|
28
27
|
this.json2iob = new Json2iob(this);
|
|
29
28
|
this.ignoreState = {};
|
|
30
29
|
this.firstUpdate = true;
|
|
30
|
+
this.requestClient = axios.create();
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
@@ -40,7 +40,6 @@ class Renault extends utils.Adapter {
|
|
|
40
40
|
this.log.info("Set interval to minimum 0.5");
|
|
41
41
|
this.config.interval = 0.5;
|
|
42
42
|
}
|
|
43
|
-
this.requestClient = axios.create();
|
|
44
43
|
this.updateInterval = null;
|
|
45
44
|
this.reLoginTimeout = null;
|
|
46
45
|
this.refreshTokenTimeout = null;
|
|
@@ -48,7 +47,25 @@ class Renault extends utils.Adapter {
|
|
|
48
47
|
this.session = {};
|
|
49
48
|
//DE API Key
|
|
50
49
|
this.apiKey = "3_7PLksOyBRkHv126x5WhHb-5pqC1qFR8pQjxSeLB6nhAnPERTUlwnYoznHSxwX668";
|
|
51
|
-
this.apiKeyUpdate = "
|
|
50
|
+
this.apiKeyUpdate = "YjkKtHmGfaceeuExUDKGxrLZGGvtVS0J";
|
|
51
|
+
await this.requestClient({
|
|
52
|
+
method: "get",
|
|
53
|
+
url: "https://raw.githubusercontent.com/db-EV/ZoePHP/main/src/api-keys.php",
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
.then((res) => {
|
|
57
|
+
this.log.debug(JSON.stringify(res.data));
|
|
58
|
+
const data = res.data;
|
|
59
|
+
//find kamereon_api via regex
|
|
60
|
+
const regex = /\$kamereon_api\s*=\s*['"]([^'"]+)['"]/;
|
|
61
|
+
const match = data.match(regex);
|
|
62
|
+
if (match && match[1]) {
|
|
63
|
+
this.apiKeyUpdate = match[1];
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
.catch((error) => {
|
|
67
|
+
this.log.debug(error);
|
|
68
|
+
});
|
|
52
69
|
if (this.config.apiKeyUpdate) {
|
|
53
70
|
this.apiKeyUpdate = this.config.apiKeyUpdate;
|
|
54
71
|
}
|
|
@@ -157,6 +174,7 @@ class Renault extends utils.Adapter {
|
|
|
157
174
|
this.log.error("Filtered accounts: " + filteredAccounts);
|
|
158
175
|
return;
|
|
159
176
|
}
|
|
177
|
+
|
|
160
178
|
this.account = filteredAccounts[0];
|
|
161
179
|
})
|
|
162
180
|
.catch((error) => {
|
|
@@ -235,7 +253,7 @@ class Renault extends utils.Adapter {
|
|
|
235
253
|
common: {
|
|
236
254
|
name: remote.name || "",
|
|
237
255
|
type: remote.type || "boolean",
|
|
238
|
-
role: remote.role || "
|
|
256
|
+
role: remote.role || "button",
|
|
239
257
|
write: true,
|
|
240
258
|
read: true,
|
|
241
259
|
},
|
|
@@ -253,6 +271,10 @@ class Renault extends utils.Adapter {
|
|
|
253
271
|
}
|
|
254
272
|
|
|
255
273
|
async updateDevices() {
|
|
274
|
+
if (!this.account.accountId) {
|
|
275
|
+
this.log.error("No accountId found");
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
256
278
|
const curDate = new Date().toISOString().split("T")[0];
|
|
257
279
|
|
|
258
280
|
const statusArray = [
|
|
@@ -423,7 +445,7 @@ class Renault extends utils.Adapter {
|
|
|
423
445
|
if (error.response.status === 401) {
|
|
424
446
|
error.response && this.log.debug(JSON.stringify(error.response.data));
|
|
425
447
|
this.log.info(element.path + " receive 401 error. Refresh Token in 60 seconds");
|
|
426
|
-
clearTimeout(this.refreshTokenTimeout);
|
|
448
|
+
this.refreshTokenTimeout && clearTimeout(this.refreshTokenTimeout);
|
|
427
449
|
this.refreshTokenTimeout = setTimeout(() => {
|
|
428
450
|
this.refreshToken();
|
|
429
451
|
}, 1000 * 60);
|
|
@@ -439,6 +461,9 @@ class Renault extends utils.Adapter {
|
|
|
439
461
|
error.response.status === 502 ||
|
|
440
462
|
error.response.status === 400
|
|
441
463
|
) {
|
|
464
|
+
if (!this.ignoreState[vin]) {
|
|
465
|
+
this.ignoreState[vin] = [];
|
|
466
|
+
}
|
|
442
467
|
this.ignoreState[vin].push(element.path);
|
|
443
468
|
this.log.info("Feature not found for " + vin + ". Ignore " + element.path + " for updates.");
|
|
444
469
|
this.log.debug(error);
|
|
@@ -521,9 +546,9 @@ class Renault extends utils.Adapter {
|
|
|
521
546
|
try {
|
|
522
547
|
this.setState("info.connection", false, true);
|
|
523
548
|
clearTimeout(this.refreshTimeout);
|
|
524
|
-
clearTimeout(this.reLoginTimeout);
|
|
525
|
-
clearTimeout(this.refreshTokenTimeout);
|
|
526
|
-
clearInterval(this.updateInterval);
|
|
549
|
+
this.reLoginTimeout && clearTimeout(this.reLoginTimeout);
|
|
550
|
+
this.refreshTokenTimeout && clearTimeout(this.refreshTokenTimeout);
|
|
551
|
+
this.updateInterval && clearInterval(this.updateInterval);
|
|
527
552
|
clearInterval(this.refreshTokenInterval);
|
|
528
553
|
callback();
|
|
529
554
|
} catch (e) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iobroker.renault",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "Adapter for Renault and Renault",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "TA2k",
|
|
@@ -24,28 +24,28 @@
|
|
|
24
24
|
"url": "https://github.com/TA2k/ioBroker.renault"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@iobroker/adapter-core": "^2.6.
|
|
28
|
-
"axios": "^
|
|
27
|
+
"@iobroker/adapter-core": "^2.6.8",
|
|
28
|
+
"axios": "^1.3.6",
|
|
29
29
|
"json-bigint": "^1.0.0",
|
|
30
|
-
"qs": "^6.11.
|
|
30
|
+
"qs": "^6.11.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@iobroker/testing": "^4.1.0",
|
|
34
34
|
"@types/chai": "^4.3.4",
|
|
35
35
|
"@types/chai-as-promised": "^7.1.5",
|
|
36
|
-
"@types/mocha": "^
|
|
37
|
-
"@types/node": "^18.
|
|
36
|
+
"@types/mocha": "^10.0.1",
|
|
37
|
+
"@types/node": "^18.15.12",
|
|
38
38
|
"@types/proxyquire": "^1.3.28",
|
|
39
|
-
"@types/sinon": "^10.0.
|
|
39
|
+
"@types/sinon": "^10.0.14",
|
|
40
40
|
"@types/sinon-chai": "^3.2.9",
|
|
41
41
|
"chai": "^4.3.7",
|
|
42
42
|
"chai-as-promised": "^7.1.1",
|
|
43
|
-
"eslint": "^8.
|
|
44
|
-
"mocha": "^10.
|
|
43
|
+
"eslint": "^8.38.0",
|
|
44
|
+
"mocha": "^10.2.0",
|
|
45
45
|
"proxyquire": "^2.1.3",
|
|
46
|
-
"sinon": "^
|
|
46
|
+
"sinon": "^15.0.3",
|
|
47
47
|
"sinon-chai": "^3.7.0",
|
|
48
|
-
"typescript": "^
|
|
48
|
+
"typescript": "^5.0.4"
|
|
49
49
|
},
|
|
50
50
|
"main": "main.js",
|
|
51
51
|
"files": [
|