From 6ecbfd5c59f5ae41412bebb7e0bb557b57bc799d Mon Sep 17 00:00:00 2001 From: ka-vaNu Date: Thu, 26 Dec 2024 15:57:50 +0100 Subject: [PATCH] add clearInterval for every device --- main.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/main.js b/main.js index f9ed9c2..a57ce1a 100644 --- a/main.js +++ b/main.js @@ -76,7 +76,7 @@ class Blebox extends utils.Adapter { tools.getBleboxData(device, 'deviceState'); tools.getBleboxData(device, 'shutterExtendedState'); if (device.polling > 0) { - setInterval(() => { + device.intervall = setInterval(() => { tools .getBleboxData(device, 'deviceUptime') .then(data => this.log.info('deviceUptime:', data)) @@ -95,7 +95,7 @@ class Blebox extends utils.Adapter { tools.getBleboxData(device, 'deviceNetwork'); tools.getBleboxData(device, 'tvliftExtendedState'); if (device.polling > 0) { - setInterval(() => { + device.intervall = setInterval(() => { tools .getBleboxData(device, 'deviceUptime') .then(data => this.log.info('deviceUptime:', data)) @@ -109,7 +109,7 @@ class Blebox extends utils.Adapter { tools.getBleboxData(device, 'settingsState'); tools.getBleboxData(device, 'deviceState'); if (device.polling > 0) { - setInterval(() => { + device.intervall = setInterval(() => { tools .getBleboxData(device, 'deviceUptime') .then(data => this.log.info('deviceUptime:', data)) @@ -128,7 +128,7 @@ class Blebox extends utils.Adapter { tools.getBleboxData(device, 'deviceState'); tools.getBleboxData(device, 'switchExtendedState'); if (device.polling > 0) { - setInterval(() => { + device.intervall = setInterval(() => { tools .getBleboxData(device, 'deviceUptime') .then(data => this.log.info('deviceUptime:', data)) @@ -146,7 +146,7 @@ class Blebox extends utils.Adapter { tools.getBleboxData(device, 'deviceState'); tools.getBleboxData(device, 'tempsensorExtendedState'); if (device.polling > 0) { - setInterval(() => { + device.intervall = setInterval(() => { tools .getBleboxData(device, 'deviceUptime') .then(data => this.log.info('deviceUptime:', data)) @@ -163,7 +163,7 @@ class Blebox extends utils.Adapter { tools.getBleboxData(device, 'deviceState'); tools.getBleboxData(device, 'multisensorExtendedState'); if (device.polling > 0) { - setInterval(() => { + device.intervall = setInterval(() => { tools .getBleboxData(device, 'deviceUptime') .then(data => this.log.info('deviceUptime:', data)) @@ -181,7 +181,7 @@ class Blebox extends utils.Adapter { tools.getBleboxData(device, 'saunaboxExtendedState'); this.subscribeStates(`${device.dev_name}.command.*`); if (device.polling > 0) { - setInterval(() => { + device.intervall = setInterval(() => { tools .getBleboxData(device, 'deviceUptime') .then(data => this.log.info('deviceUptime:', data)) @@ -207,6 +207,11 @@ class Blebox extends utils.Adapter { */ onUnload(callback) { this.log.info('Shutting down...'); + for (const device of this.config.devices) { + if (device.polling > 0) { + clearInterval(device.intervall); + } + } try { schedule.gracefulShutdown(); this.log.info('All Jobs shutted down...'); @@ -389,7 +394,7 @@ class Blebox extends utils.Adapter { await tools.setIobStates(response); tools.getBleboxData(device, 'shutterExtendedState'); // eslint-disable-next-line - shutterboxRefreshJob = schedule.scheduleJob( + shutterboxRefreshJob = schedule.scheduleJob( { start: new Date(Date.now() + 1000), end: new Date(Date.now() + 20000), @@ -435,7 +440,7 @@ class Blebox extends utils.Adapter { await tools.setIobStates(response); tools.getBleboxData(device, 'tvliftExtendedState'); // eslint-disable-next-line - tvliftRefreshJob = schedule.scheduleJob( + tvliftRefreshJob = schedule.scheduleJob( { start: new Date(Date.now() + 1000), end: new Date(Date.now() + 45000), @@ -470,7 +475,7 @@ class Blebox extends utils.Adapter { await tools.setIobStates(response); tools.getBleboxData(device, 'switchState'); // eslint-disable-next-line - switchboxRefreshJob = schedule.scheduleJob( + switchboxRefreshJob = schedule.scheduleJob( { start: new Date(Date.now() + 1000), end: new Date(Date.now() + 1000 * state.val + 1000), @@ -550,7 +555,7 @@ class Blebox extends utils.Adapter { await tools.setIobStates(response); tools.getBleboxData(device, 'gateExtendedState'); // eslint-disable-next-line - gateboxRefreshJob = schedule.scheduleJob( + gateboxRefreshJob = schedule.scheduleJob( { start: new Date(Date.now() + 1000), end: new Date(Date.now() + 45000),