From 71dd305ba94e7eff519c21a64a5a0d565e03407a Mon Sep 17 00:00:00 2001 From: ChrisTerBeke <1134120+ChrisTerBeke@users.noreply.github.com> Date: Wed, 27 Nov 2024 01:33:08 +0100 Subject: [PATCH] Fixes for interval en timeout --- drivers/uponor/device.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/uponor/device.ts b/drivers/uponor/device.ts index 2c8c972..7a2a404 100644 --- a/drivers/uponor/device.ts +++ b/drivers/uponor/device.ts @@ -21,6 +21,10 @@ class UponorThermostatDevice extends Device { this._uninit() } + onDeleted(): void { + this.homey.clearInterval(this._syncInterval) + } + onDiscoveryResult(discoveryResult: DiscoveryResultMAC): boolean { return this.getData().id.includes(discoveryResult.id) } @@ -75,12 +79,12 @@ class UponorThermostatDevice extends Device { const address = this._getAddress() if (!address) return this.setUnavailable('No IP address configured') this._client = new UponorHTTPClient(address) - this._syncInterval = setInterval(this._sync.bind(this), POLL_INTERVAL_MS) - setTimeout(this._sync.bind(this), 2000) + this._syncInterval = this.homey.setInterval(this._sync.bind(this), POLL_INTERVAL_MS) + this.homey.setTimeout(this._sync.bind(this), 2000) } async _uninit(): Promise { - clearInterval(this._syncInterval as NodeJS.Timeout) + this.homey.clearInterval(this._syncInterval) this._syncInterval = undefined this._client = undefined }