]> git.basschouten.com Git - openhab-addons.git/commitdiff
[fronius] Fix connection check with Gen24 inverters (#9108)
authorjimtng <2554958+jimtng@users.noreply.github.com>
Tue, 24 Nov 2020 04:01:00 +0000 (14:01 +1000)
committerGitHub <noreply@github.com>
Tue, 24 Nov 2020 04:01:00 +0000 (20:01 -0800)
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/handler/FroniusBridgeHandler.java

index 0528ec5acc66e42a02dba77e3880b35d4ce2517a..c14006634f6b67e9d82fd2abe599b665956ef121 100644 (file)
@@ -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) {