Skip to content

Commit

Permalink
corr intervall
Browse files Browse the repository at this point in the history
  • Loading branch information
arteck authored Oct 26, 2023
1 parent f15225f commit 9f1f385
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ const client = new Client({
});
const MAX_POWER_VALUE = 10 * 1000; // max value for power consumption: 10 kW

let requestTimeout = null;

let interval = 0;
let _requestInterval = null;

class hs100Controll extends utils.Adapter {

Expand Down Expand Up @@ -56,7 +55,7 @@ class hs100Controll extends utils.Adapter {
*/
onUnload(callback) {
try {
if (requestTimeout) clearTimeout(requestTimeout);
if (_requestInterval) clearInterval(_requestInterval);

this.log.info('cleaned everything up...');
this.setState('info.connection', false, true);
Expand Down Expand Up @@ -163,7 +162,9 @@ class hs100Controll extends utils.Adapter {
this.updateDevice(devices[i]);
}
}
requestTimeout = setTimeout(async () => {

if (!_requestInterval) {
_requestInterval= setInterval(async () => {
this.getInfos();
}, interval);
} catch (err) {
Expand Down

0 comments on commit 9f1f385

Please sign in to comment.