iobroker.renault 0.0.15 → 0.0.17

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.
Files changed (3) hide show
  1. package/io-package.json +4 -1
  2. package/main.js +35 -9
  3. package/package.json +11 -11
package/io-package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "renault",
4
- "version": "0.0.15",
4
+ "version": "0.0.17",
5
5
  "news": {
6
+ "0.0.17": {
7
+ "en": "update apikey"
8
+ },
6
9
  "0.0.15": {
7
10
  "en": "fix charge start and reduce error logs"
8
11
  },
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,26 @@ class Renault extends utils.Adapter {
48
47
  this.session = {};
49
48
  //DE API Key
50
49
  this.apiKey = "3_7PLksOyBRkHv126x5WhHb-5pqC1qFR8pQjxSeLB6nhAnPERTUlwnYoznHSxwX668";
51
- this.apiKeyUpdate = "VAX7XYKGfa92yMvXculCkEFyfZbuM7Ss";
50
+ this.apiKeyUpdate = "YjkKtHmGfaceeuExUDKGxrLZGGvtVS0J";
51
+ try {
52
+ await this.requestClient({
53
+ method: "get",
54
+ url: "https://raw.githubusercontent.com/hacf-fr/renault-api/main/src/renault_api/const.py",
55
+ })
56
+
57
+ .then((res) => {
58
+ this.log.debug(JSON.stringify(res.data));
59
+
60
+ if (res.data.split('KAMEREON_APIKEY = "')[2] && res.data.split('KAMEREON_APIKEY = "')[2].split('"')[0]) {
61
+ this.apiKeyUpdate = res.data.split('KAMEREON_APIKEY = "')[2].split('"')[0];
62
+ }
63
+ })
64
+ .catch((error) => {
65
+ this.log.debug(error);
66
+ });
67
+ } catch (error) {
68
+ this.log.debug(error);
69
+ }
52
70
  if (this.config.apiKeyUpdate) {
53
71
  this.apiKeyUpdate = this.config.apiKeyUpdate;
54
72
  }
@@ -157,6 +175,7 @@ class Renault extends utils.Adapter {
157
175
  this.log.error("Filtered accounts: " + filteredAccounts);
158
176
  return;
159
177
  }
178
+
160
179
  this.account = filteredAccounts[0];
161
180
  })
162
181
  .catch((error) => {
@@ -235,7 +254,7 @@ class Renault extends utils.Adapter {
235
254
  common: {
236
255
  name: remote.name || "",
237
256
  type: remote.type || "boolean",
238
- role: remote.role || "boolean",
257
+ role: remote.role || "button",
239
258
  write: true,
240
259
  read: true,
241
260
  },
@@ -253,6 +272,10 @@ class Renault extends utils.Adapter {
253
272
  }
254
273
 
255
274
  async updateDevices() {
275
+ if (!this.account.accountId) {
276
+ this.log.error("No accountId found");
277
+ return;
278
+ }
256
279
  const curDate = new Date().toISOString().split("T")[0];
257
280
 
258
281
  const statusArray = [
@@ -423,7 +446,7 @@ class Renault extends utils.Adapter {
423
446
  if (error.response.status === 401) {
424
447
  error.response && this.log.debug(JSON.stringify(error.response.data));
425
448
  this.log.info(element.path + " receive 401 error. Refresh Token in 60 seconds");
426
- clearTimeout(this.refreshTokenTimeout);
449
+ this.refreshTokenTimeout && clearTimeout(this.refreshTokenTimeout);
427
450
  this.refreshTokenTimeout = setTimeout(() => {
428
451
  this.refreshToken();
429
452
  }, 1000 * 60);
@@ -439,6 +462,9 @@ class Renault extends utils.Adapter {
439
462
  error.response.status === 502 ||
440
463
  error.response.status === 400
441
464
  ) {
465
+ if (!this.ignoreState[vin]) {
466
+ this.ignoreState[vin] = [];
467
+ }
442
468
  this.ignoreState[vin].push(element.path);
443
469
  this.log.info("Feature not found for " + vin + ". Ignore " + element.path + " for updates.");
444
470
  this.log.debug(error);
@@ -521,9 +547,9 @@ class Renault extends utils.Adapter {
521
547
  try {
522
548
  this.setState("info.connection", false, true);
523
549
  clearTimeout(this.refreshTimeout);
524
- clearTimeout(this.reLoginTimeout);
525
- clearTimeout(this.refreshTokenTimeout);
526
- clearInterval(this.updateInterval);
550
+ this.reLoginTimeout && clearTimeout(this.reLoginTimeout);
551
+ this.refreshTokenTimeout && clearTimeout(this.refreshTokenTimeout);
552
+ this.updateInterval && clearInterval(this.updateInterval);
527
553
  clearInterval(this.refreshTokenInterval);
528
554
  callback();
529
555
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.renault",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
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.7",
28
- "axios": "^0.27.2",
27
+ "@iobroker/adapter-core": "^2.6.8",
28
+ "axios": "^1.3.6",
29
29
  "json-bigint": "^1.0.0",
30
- "qs": "^6.11.0"
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": "^9.1.1",
37
- "@types/node": "^18.11.9",
36
+ "@types/mocha": "^10.0.1",
37
+ "@types/node": "^18.15.12",
38
38
  "@types/proxyquire": "^1.3.28",
39
- "@types/sinon": "^10.0.13",
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.27.0",
44
- "mocha": "^10.1.0",
43
+ "eslint": "^8.38.0",
44
+ "mocha": "^10.2.0",
45
45
  "proxyquire": "^2.1.3",
46
- "sinon": "^14.0.2",
46
+ "sinon": "^15.0.3",
47
47
  "sinon-chai": "^3.7.0",
48
- "typescript": "^4.9.3"
48
+ "typescript": "^5.0.4"
49
49
  },
50
50
  "main": "main.js",
51
51
  "files": [