From c7161fff2bca7e5e54ced53e7b3e0a9f7f6369d1 Mon Sep 17 00:00:00 2001 From: Chris ter Beke <1134120+ChrisTerBeke@users.noreply.github.com> Date: Thu, 25 Apr 2024 20:01:53 +0200 Subject: [PATCH] Fix edge case when setting override IP back to empty (#1) --- drivers/uponor/device.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/uponor/device.ts b/drivers/uponor/device.ts index 71d1b14..37764c8 100644 --- a/drivers/uponor/device.ts +++ b/drivers/uponor/device.ts @@ -1,3 +1,4 @@ +import { isIPv4 } from 'net' import { Device, DiscoveryResult } from 'homey' import { UponorHTTPClient, Mode } from '../../lib/UponorHTTPClient' @@ -58,9 +59,13 @@ class UponorThermostatDevice extends Device { } private async _updateAddress(newAddress: string): Promise { - const client = new UponorHTTPClient(newAddress) - const canConnect = await client.testConnection() - if (!canConnect) return false + if (newAddress.length > 0) { + const isValidIP = isIPv4(newAddress) + if (!isValidIP) return false + const client = new UponorHTTPClient(newAddress) + const canConnect = await client.testConnection() + if (!canConnect) return false + } this.setStoreValue('address', newAddress) this._init() return true