Skip to content

Commit

Permalink
improve skipping
Browse files Browse the repository at this point in the history
  • Loading branch information
TA2k committed Nov 22, 2024
1 parent a1daac8 commit a8f295e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ Feel free to follow the discussions in the german [iobroker forum](https://forum
Placeholder for the next version (at the beginning of the line):
### **WORK IN PROGRESS**
-->
### 0.1.8 (2024-11-22)

### 0.1.9 (2024-11-22)

- battery status v2 moved to to batter-statusv2 object folder

Expand Down
4 changes: 2 additions & 2 deletions io-package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"common": {
"name": "nissan",
"version": "0.1.8",
"version": "0.1.9",
"news": {
"0.1.8": {
"0.1.9": {
"en": "battery status v2 moved to to batter-statusv2 object folder",
"de": "batteriestatus v2 in den objektordner batter-statusv2 verschoben",
"ru": "статус батареи v2 перенесен в папку объекта batter-statusv2",
Expand Down
11 changes: 6 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class Nissan extends utils.Adapter {
//bolliy --
this.isConnected = false;
this.isReady = false; //object path already created
this.useLegacyBattery = false;
this.skipArray = [];

//bolliy ++
}

Expand Down Expand Up @@ -531,7 +532,7 @@ class Nissan extends utils.Adapter {

for (const element of statusArray) {
const url = element.url.replace('$vin', vin).replace('$gen', this.canGen[vin]).replace('$user', this.userId);
if (this.useLegacyBattery && element.path === 'battery-statusv2') {
if (this.skipArray.includes(vin + '.' + element.path)) {
continue;
}
await this.requestClient({
Expand Down Expand Up @@ -565,9 +566,9 @@ class Nissan extends utils.Adapter {
if (error.response && error.response.status === 502) {
return;
}
if (error.response && error.response.status === 501 && element.path === 'battery-statusv2') {
this.log.info('Battery status v2 not available disabled until restart');
this.useLegacyBattery = true;
if (error.response && (error.response.status === 501 || error.response.status === 403)) {
this.log.info(`Skip ${element.path} for ${vin} code: ${error.response && error.response.status} until next restart`);
this.skipArray.push(vin + '.' + element.path);
return;
}
if (error.response && error.response.status === 401 && element.path === 'cockpit') {
Expand Down

0 comments on commit a8f295e

Please sign in to comment.