From c7cb60189fb528e587b700b1ccb24df950e61c84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=B8rge=20Grunicke?= Date: Tue, 8 Aug 2023 21:55:15 +0200 Subject: [PATCH] remove static search intervals, make configurable --- src/main.ts | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/main.ts b/src/main.ts index 2b8798f..68bb9fc 100644 --- a/src/main.ts +++ b/src/main.ts @@ -76,14 +76,7 @@ class GoveeLocal extends utils.Adapter { this.setState('info.connection', { val: true, ack: true }); this.log.info('UDP listening on ' + server.address().address + ':' + server.address().port); - if (this.config.searchInterval == undefined) { - this.config.searchInterval = 10000; - } - if (this.config.deviceStatusRefreshInterval == undefined) { - this.config.deviceStatusRefreshInterval = 1000; - } - - const result = this.setInterval(this.sendScan.bind(this), this.config.searchInterval); + const result = this.setInterval(this.sendScan.bind(this), this.config.searchInterval * 1000); if (result !== void 0) { searchInterval = result; } @@ -129,13 +122,12 @@ class GoveeLocal extends utils.Adapter { if (!(messageObject.msg.data.device in intervals)) { const result = this.setInterval( () => this.requestDeviceStatus(messageObject.msg.data.ip), - this.config.deviceStatusRefreshInterval, + this.config.deviceStatusRefreshInterval * 1000, ); if (result !== void 0) { intervals[messageObject.msg.data.device] = result; } } - // this.requestDeviceStatus(remote.address); break; case 'devStatus': const devices = await this.getStatesAsync(this.name + '.' + this.instance + '.*.deviceInfo.ip');