iobroker.renault 0.0.6 → 0.0.9

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/README.md CHANGED
@@ -12,13 +12,12 @@
12
12
 
13
13
  **Tests:** ![Test and Release](https://github.com/TA2k/ioBroker.renault/workflows/Test%20and%20Release/badge.svg)
14
14
 
15
- ## renault adapter for ioBroker
16
-
17
- Adapter for Renault and Renault
15
+ ## renault/dacia adapter for ioBroker
18
16
 
17
+ Adapter for Renault and Dacia
19
18
  ## Loginablauf
20
19
 
21
- Die myRenault Mail und Passwort eingeben.
20
+ Die myRenault/myDacia Mail und Passwort eingeben.
22
21
 
23
22
  ## Steuern
24
23
 
@@ -29,7 +28,7 @@ renault.0.vin.remote auf true setzen steuert den jeweiligen Befehl
29
28
 
30
29
  ## Changelog
31
30
 
32
- ### 0.0.6
31
+ ### 0.0.7
33
32
 
34
33
  * (TA2k) initial release
35
34
 
package/io-package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "renault",
4
- "version": "0.0.6",
4
+ "version": "0.0.9",
5
5
  "news": {
6
- "0.0.6": {
6
+ "0.0.9": {
7
+ "en": "update apikey"
8
+ },
9
+ "0.0.8": {
7
10
  "en": "initial release",
8
11
  "de": "Erstveröffentlichung",
9
12
  "ru": "Начальная версия",
@@ -69,7 +72,7 @@
69
72
  },
70
73
  "dependencies": [
71
74
  {
72
- "js-controller": ">=3.0.0"
75
+ "js-controller": ">=3.2.0"
73
76
  }
74
77
  ],
75
78
  "globalDependencies": [
package/main.js CHANGED
@@ -27,6 +27,7 @@ class Renault extends utils.Adapter {
27
27
  this.deviceArray = [];
28
28
  this.json2iob = new Json2iob(this);
29
29
  this.ignoreState = [];
30
+ this.firstUpdate = true;
30
31
  }
31
32
 
32
33
  /**
@@ -134,7 +135,7 @@ class Renault extends utils.Adapter {
134
135
  "Content-Type": "application/json",
135
136
  Accept: "*/*",
136
137
  "User-Agent": "MYRenault/39 CFNetwork/1312 Darwin/21.0.0",
137
- apiKey: "Ae9FDWugRxZQAGm3Sxgk7uJn6Q4CGEA2",
138
+ apiKey: "VAX7XYKGfa92yMvXculCkEFyfZbuM7Ss",
138
139
  "Accept-Language": "de-de",
139
140
  "x-gigya-id_token": this.session.id_token,
140
141
  },
@@ -142,7 +143,7 @@ class Renault extends utils.Adapter {
142
143
  .then((res) => {
143
144
  this.log.debug(JSON.stringify(res.data));
144
145
  const filteredAccounts = res.data.currentUser.accounts.filter(function (el) {
145
- return el.accountType === "MYRENAULT" && el.accountStatus === "ACTIVE";
146
+ return (el.accountType === "MYRENAULT" || el.accountType === "MYDACIA") && el.accountStatus === "ACTIVE";
146
147
  });
147
148
  if (filteredAccounts.length === 0) {
148
149
  this.log.error("No Account found");
@@ -153,6 +154,7 @@ class Renault extends utils.Adapter {
153
154
  this.account = filteredAccounts[0];
154
155
  })
155
156
  .catch((error) => {
157
+ this.log.error("Error while getting account");
156
158
  this.log.error(error);
157
159
  if (error.response) {
158
160
  this.log.error(JSON.stringify(error.response.data));
@@ -164,7 +166,7 @@ class Renault extends utils.Adapter {
164
166
  method: "get",
165
167
  url: "https://api-wired-prod-1-euw1.wrd-aws.com/commerce/v1/accounts/" + this.account.accountId + "/vehicles?country=" + this.country + "&oms=false",
166
168
  headers: {
167
- apikey: "Ae9FDWugRxZQAGm3Sxgk7uJn6Q4CGEA2",
169
+ apikey: "VAX7XYKGfa92yMvXculCkEFyfZbuM7Ss",
168
170
  "content-type": "application/json",
169
171
  accept: "*/*",
170
172
  "user-agent": "MYRenault/39 CFNetwork/1312 Darwin/21.0.0",
@@ -227,6 +229,7 @@ class Renault extends utils.Adapter {
227
229
  }
228
230
  })
229
231
  .catch((error) => {
232
+ this.log.error("Error while getting vehicle list");
230
233
  this.log.error(error);
231
234
  error.response && this.log.error(JSON.stringify(error.response.data));
232
235
  });
@@ -327,8 +330,8 @@ class Renault extends utils.Adapter {
327
330
  "accept-language": "de-de",
328
331
  "x-gigya-id_token": this.session.id_token,
329
332
  };
330
- this.deviceArray.forEach(async (vin) => {
331
- statusArray.forEach(async (element) => {
333
+ for (const vin of this.deviceArray) {
334
+ for (const element of statusArray) {
332
335
  if (this.ignoreState.includes(element.path)) {
333
336
  return;
334
337
  }
@@ -366,27 +369,30 @@ class Renault extends utils.Adapter {
366
369
 
367
370
  return;
368
371
  }
369
- if (
370
- error.response.status === 403 ||
371
- error.response.status === 404 ||
372
- error.response.status === 500 ||
373
- error.response.status === 501 ||
374
- error.response.status === 502 ||
375
- error.response.status === 400
376
- ) {
377
- this.ignoreState.push(element.path);
378
- this.log.info("Feature not found. Ignore " + element.path + " for updates.");
379
- this.log.info(error);
380
- error.response && this.log.info(JSON.stringify(error.response.data));
381
- return;
372
+ if (this.firstUpdate) {
373
+ if (
374
+ error.response.status === 403 ||
375
+ error.response.status === 404 ||
376
+ error.response.status === 500 ||
377
+ error.response.status === 501 ||
378
+ error.response.status === 502 ||
379
+ error.response.status === 400
380
+ ) {
381
+ this.ignoreState.push(element.path);
382
+ this.log.info("Feature not found. Ignore " + element.path + " for updates.");
383
+ this.log.info(error);
384
+ error.response && this.log.info(JSON.stringify(error.response.data));
385
+ return;
386
+ }
382
387
  }
383
388
  }
384
389
  this.log.error(url);
385
390
  this.log.error(error);
386
391
  error.response && this.log.error(JSON.stringify(error.response.data));
387
392
  });
388
- });
389
- });
393
+ }
394
+ }
395
+ this.firstUpdate = false;
390
396
  }
391
397
  async refreshToken() {
392
398
  if (!this.session_data) {
@@ -432,6 +438,9 @@ class Renault extends utils.Adapter {
432
438
  return new Promise((resolve) => setTimeout(resolve, ms));
433
439
  }
434
440
  toCamelCase(string) {
441
+ if (!string) {
442
+ return;
443
+ }
435
444
  const camelC = string.replace(/-([a-z])/g, function (g) {
436
445
  return g[1].toUpperCase();
437
446
  });
@@ -468,6 +477,10 @@ class Renault extends utils.Adapter {
468
477
  if (path === "hvac-temperature") {
469
478
  return;
470
479
  }
480
+ if (!this.account) {
481
+ this.log.error("No account found");
482
+ return;
483
+ }
471
484
  const command = path.split("/")[1];
472
485
  const data = { data: { type: this.toCamelCase(command), attributes: { action: state.val ? "start" : "cancel" } } };
473
486
  if (command === "hvac-start") {
package/package.json CHANGED
@@ -1,73 +1,75 @@
1
1
  {
2
- "name": "iobroker.renault",
3
- "version": "0.0.6",
4
- "description": "Adapter for Renault and Renault",
5
- "author": {
6
- "name": "TA2k",
7
- "email": "tombox2020@gmail.com"
8
- },
9
- "contributors": [
10
- {
11
- "name": "fungus75"
12
- }
13
- ],
14
- "homepage": "https://github.com/TA2k/ioBroker.renault",
15
- "license": "MIT",
16
- "keywords": [
17
- "renault",
18
- "Renault"
19
- ],
20
- "repository": {
21
- "type": "git",
22
- "url": "https://github.com/TA2k/ioBroker.renault"
23
- },
24
- "dependencies": {
25
- "@iobroker/adapter-core": "^2.5.1",
26
- "axios": "^0.24.0",
27
- "json-bigint": "^1.0.0",
28
- "qs": "^6.10.1"
29
- },
30
- "devDependencies": {
31
- "@iobroker/testing": "^2.5.2",
32
- "@types/chai": "^4.2.22",
33
- "@types/chai-as-promised": "^7.1.4",
34
- "@types/gulp": "^4.0.9",
35
- "@types/mocha": "^9.0.0",
36
- "@types/node": "^14.17.19",
37
- "@types/proxyquire": "^1.3.28",
38
- "@types/sinon": "^10.0.4",
39
- "@types/sinon-chai": "^3.2.5",
40
- "chai": "^4.3.4",
41
- "chai-as-promised": "^7.1.1",
42
- "eslint": "^7.32.0",
43
- "gulp": "^4.0.2",
44
- "mocha": "^9.1.2",
45
- "proxyquire": "^2.1.3",
46
- "sinon": "^11.1.2",
47
- "sinon-chai": "^3.7.0",
48
- "typescript": "~4.4.3"
49
- },
50
- "main": "main.js",
51
- "files": [
52
- "admin{,/!(src)/**}/!(tsconfig|tsconfig.*).json",
53
- "admin{,/!(src)/**}/*.{html,css,png,svg,jpg,js}",
54
- "lib/",
55
- "www/",
56
- "io-package.json",
57
- "LICENSE",
58
- "main.js"
59
- ],
60
- "scripts": {
61
- "test:js": "mocha --config test/mocharc.custom.json \"{!(node_modules|test)/**/*.test.js,*.test.js,test/**/test!(PackageFiles|Startup).js}\"",
62
- "test:package": "mocha test/package --exit",
63
- "test:unit": "mocha test/unit --exit",
64
- "test:integration": "mocha test/integration --exit",
65
- "test": "npm run test:js && npm run test:package",
66
- "check": "tsc --noEmit -p tsconfig.check.json",
67
- "lint": "eslint"
68
- },
69
- "bugs": {
70
- "url": "https://github.com/TA2k/ioBroker.renault/issues"
71
- },
72
- "readmeFilename": "README.md"
2
+ "name": "iobroker.renault",
3
+ "version": "0.0.9",
4
+ "description": "Adapter for Renault and Renault",
5
+ "author": {
6
+ "name": "TA2k",
7
+ "email": "tombox2020@gmail.com"
8
+ },
9
+ "contributors": [
10
+ {
11
+ "name": "fungus75"
12
+ }
13
+ ],
14
+ "homepage": "https://github.com/TA2k/ioBroker.renault",
15
+ "license": "MIT",
16
+ "keywords": [
17
+ "renault",
18
+ "Renault",
19
+ "dacia",
20
+ "Dacia"
21
+ ],
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/TA2k/ioBroker.renault"
25
+ },
26
+ "dependencies": {
27
+ "@iobroker/adapter-core": "^2.5.1",
28
+ "axios": "^0.24.0",
29
+ "json-bigint": "^1.0.0",
30
+ "qs": "^6.10.1"
31
+ },
32
+ "devDependencies": {
33
+ "@iobroker/testing": "^2.5.2",
34
+ "@types/chai": "^4.2.22",
35
+ "@types/chai-as-promised": "^7.1.4",
36
+ "@types/gulp": "^4.0.9",
37
+ "@types/mocha": "^9.0.0",
38
+ "@types/node": "^14.17.19",
39
+ "@types/proxyquire": "^1.3.28",
40
+ "@types/sinon": "^10.0.4",
41
+ "@types/sinon-chai": "^3.2.5",
42
+ "chai": "^4.3.4",
43
+ "chai-as-promised": "^7.1.1",
44
+ "eslint": "^7.32.0",
45
+ "gulp": "^4.0.2",
46
+ "mocha": "^9.1.2",
47
+ "proxyquire": "^2.1.3",
48
+ "sinon": "^11.1.2",
49
+ "sinon-chai": "^3.7.0",
50
+ "typescript": "~4.4.3"
51
+ },
52
+ "main": "main.js",
53
+ "files": [
54
+ "admin{,/!(src)/**}/!(tsconfig|tsconfig.*).json",
55
+ "admin{,/!(src)/**}/*.{html,css,png,svg,jpg,js}",
56
+ "lib/",
57
+ "www/",
58
+ "io-package.json",
59
+ "LICENSE",
60
+ "main.js"
61
+ ],
62
+ "scripts": {
63
+ "test:js": "mocha --config test/mocharc.custom.json \"{!(node_modules|test)/**/*.test.js,*.test.js,test/**/test!(PackageFiles|Startup).js}\"",
64
+ "test:package": "mocha test/package --exit",
65
+ "test:unit": "mocha test/unit --exit",
66
+ "test:integration": "mocha test/integration --exit",
67
+ "test": "npm run test:js && npm run test:package",
68
+ "check": "tsc --noEmit -p tsconfig.check.json",
69
+ "lint": "eslint"
70
+ },
71
+ "bugs": {
72
+ "url": "https://github.com/TA2k/ioBroker.renault/issues"
73
+ },
74
+ "readmeFilename": "README.md"
73
75
  }