Skip to content

Commit

Permalink
automatic restart
Browse files Browse the repository at this point in the history
Fixes #170
  • Loading branch information
afuerhoff committed Sep 6, 2024
1 parent 7f2d987 commit f621970
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 36 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ TKK= Temperature inverter
### **WORK IN PROGRESS**
* (afuerhoff) adapter checker changes
* (afuerhoff) dependencies updated
* (afuerhoff) automatic restart [#170](https://github.com/afuerhoff/ioBroker.solarviewdatareader/issues/170)

### 1.1.1 (2024-06-28)
* (afuerhoff) change to typescript
Expand Down
13 changes: 3 additions & 10 deletions build/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions build/main.js.map

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
"@iobroker/adapter-dev": "^1.3.0",
"@iobroker/testing": "^4.1.3",
"@tsconfig/node18": "^18.2.4",
"@types/chai": "^4.3.17",
"@types/chai": "^4.3.19",
"@types/chai-as-promised": "^7.1.8",
"@types/mocha": "^10.0.7",
"@types/node": "^20.14.14",
"@types/node": "^20.16.3",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"chai": "^4.5.0",
Expand Down
14 changes: 4 additions & 10 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,6 @@ class Solarviewdatareader extends utils.Adapter {

conn.on('data', async (data) => {
chkCnt = 0;
clearTimeout(jobSchedule);
jobSchedule = setTimeout(() => {
this.getData(port, ip_address);
}, this.config.intervalVal * 1000 - this.pTimeoutcnt);
await this.processData(data);
});

Expand All @@ -301,10 +297,6 @@ class Solarviewdatareader extends utils.Adapter {
chkCnt = 0;
}
chkCnt++;
clearTimeout(jobSchedule);
jobSchedule = setTimeout(() => {
this.getData(port, ip_address);
}, 10000);
});

conn.on('error', (err) => {
Expand All @@ -319,9 +311,11 @@ class Solarviewdatareader extends utils.Adapter {
}

//First start of getData
jobSchedule = setTimeout(async () => {
this.getData(port, ip_address);

jobSchedule = setInterval(async () => {
this.getData(port, ip_address);
}, 1000);
}, this.config.intervalVal * 1000);
}

async getData(port: number, ip_address: string): Promise<void> {
Expand Down

0 comments on commit f621970

Please sign in to comment.