Skip to content

Commit

Permalink
add clearInterval for every device
Browse files Browse the repository at this point in the history
  • Loading branch information
ka-vaNu committed Dec 26, 2024
1 parent ca955e6 commit 6ecbfd5
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
Expand All @@ -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))
Expand All @@ -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))
Expand All @@ -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))
Expand All @@ -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))
Expand All @@ -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))
Expand All @@ -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...');
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 6ecbfd5

Please sign in to comment.