From fd7aa9f9c10c7c4dece7b4b09350172a3b8d66cb Mon Sep 17 00:00:00 2001 From: jimtng <2554958+jimtng@users.noreply.github.com> Date: Tue, 24 Nov 2020 14:01:00 +1000 Subject: [PATCH] [fronius] Fix connection check with Gen24 inverters (#9108) Signed-off-by: Jimmy Tanagra --- .../fronius/internal/handler/FroniusBridgeHandler.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/handler/FroniusBridgeHandler.java b/bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/handler/FroniusBridgeHandler.java index 0528ec5acc6..c14006634f6 100644 --- a/bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/handler/FroniusBridgeHandler.java +++ b/bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/handler/FroniusBridgeHandler.java @@ -13,7 +13,6 @@ package org.openhab.binding.fronius.internal.handler; import java.io.IOException; -import java.net.InetAddress; import java.util.HashSet; import java.util.Set; import java.util.concurrent.ScheduledFuture; @@ -21,6 +20,7 @@ import java.util.concurrent.TimeUnit; import org.apache.commons.lang.StringUtils; import org.openhab.binding.fronius.internal.FroniusBridgeConfiguration; +import org.openhab.core.io.net.http.HttpUtil; import org.openhab.core.thing.Bridge; import org.openhab.core.thing.ChannelUID; import org.openhab.core.thing.ThingStatus; @@ -94,14 +94,11 @@ public class FroniusBridgeHandler extends BaseBridgeHandler { Runnable runnable = () -> { boolean online = false; try { - InetAddress inet; - inet = InetAddress.getByName(config.hostname); - if (inet.isReachable(5000)) { + if (HttpUtil.executeUrl("GET", "http://" + config.hostname, 5000) != null) { online = true; } } catch (IOException e) { logger.debug("Connection Error: {}", e.getMessage()); - return; } if (!online) {