iobroker.renault 0.0.6 → 0.0.7

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 +2 -2
  2. package/main.js +25 -18
  3. package/package.json +1 -1
package/io-package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "renault",
4
- "version": "0.0.6",
4
+ "version": "0.0.7",
5
5
  "news": {
6
- "0.0.6": {
6
+ "0.0.7": {
7
7
  "en": "initial release",
8
8
  "de": "Erstveröffentlichung",
9
9
  "ru": "Начальная версия",
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
  /**
@@ -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");
@@ -327,8 +328,8 @@ class Renault extends utils.Adapter {
327
328
  "accept-language": "de-de",
328
329
  "x-gigya-id_token": this.session.id_token,
329
330
  };
330
- this.deviceArray.forEach(async (vin) => {
331
- statusArray.forEach(async (element) => {
331
+ for (const vin of this.deviceArray) {
332
+ for (const element of statusArray) {
332
333
  if (this.ignoreState.includes(element.path)) {
333
334
  return;
334
335
  }
@@ -366,27 +367,30 @@ class Renault extends utils.Adapter {
366
367
 
367
368
  return;
368
369
  }
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;
370
+ if (this.firstUpdate) {
371
+ if (
372
+ error.response.status === 403 ||
373
+ error.response.status === 404 ||
374
+ error.response.status === 500 ||
375
+ error.response.status === 501 ||
376
+ error.response.status === 502 ||
377
+ error.response.status === 400
378
+ ) {
379
+ this.ignoreState.push(element.path);
380
+ this.log.info("Feature not found. Ignore " + element.path + " for updates.");
381
+ this.log.info(error);
382
+ error.response && this.log.info(JSON.stringify(error.response.data));
383
+ return;
384
+ }
382
385
  }
383
386
  }
384
387
  this.log.error(url);
385
388
  this.log.error(error);
386
389
  error.response && this.log.error(JSON.stringify(error.response.data));
387
390
  });
388
- });
389
- });
391
+ }
392
+ }
393
+ this.firstUpdate = false;
390
394
  }
391
395
  async refreshToken() {
392
396
  if (!this.session_data) {
@@ -432,6 +436,9 @@ class Renault extends utils.Adapter {
432
436
  return new Promise((resolve) => setTimeout(resolve, ms));
433
437
  }
434
438
  toCamelCase(string) {
439
+ if (!string) {
440
+ return;
441
+ }
435
442
  const camelC = string.replace(/-([a-z])/g, function (g) {
436
443
  return g[1].toUpperCase();
437
444
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.renault",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Adapter for Renault and Renault",
5
5
  "author": {
6
6
  "name": "TA2k",