From ab4c4b698c006e1113aeff0fdb15f4767fc96abb Mon Sep 17 00:00:00 2001 From: Chris ter Beke <1134120+ChrisTerBeke@users.noreply.github.com> Date: Tue, 2 Jul 2024 13:40:46 +0200 Subject: [PATCH] Do not create client twice when address changes --- drivers/uponor/device.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/uponor/device.ts b/drivers/uponor/device.ts index 6b4c620..8c846e6 100644 --- a/drivers/uponor/device.ts +++ b/drivers/uponor/device.ts @@ -53,22 +53,14 @@ class UponorThermostatDevice extends Device { private async _updateAddress(newAddress: string, persist = false): Promise { if (newAddress && newAddress.length > 0) { - const isValidIP = isIPv4(newAddress) - if (!isValidIP) return false - const client = new UponorHTTPClient(newAddress) - try { - const canConnect = await client.testConnection() - if (!canConnect) return false - } catch (error) { - return false - } + if (!isIPv4(newAddress)) return false } if (persist) { - this.setStoreValue('address', newAddress) + await this.setStoreValue('address', newAddress) } - this._init() + await this._init() return true }