]> git.basschouten.com Git - openhab-addons.git/commitdiff
[haywardomnilogic] Fix bridge thing status upon re-establishing server comms (#10371)
authorMatt <mmyers75@icloud.com>
Fri, 2 Apr 2021 20:24:31 +0000 (16:24 -0400)
committerGitHub <noreply@github.com>
Fri, 2 Apr 2021 20:24:31 +0000 (22:24 +0200)
* Update HaywardBridgeHandler to set thingstatus online upon succesful getTelemetryData

Signed-off-by: matchews <mmyers75@icloud.com>
* updated default endpoint url

Signed-off-by: matchews <mmyers75@icloud.com>
* Bug fixes.  Prevent bridge status toggling if a single request fails.  Don't evaluate xml if http response if != 200

Signed-off-by: matchews <mmyers75@icloud.com>
bundles/org.openhab.binding.haywardomnilogic/src/main/java/org/openhab/binding/haywardomnilogic/internal/handler/HaywardBridgeHandler.java
bundles/org.openhab.binding.haywardomnilogic/src/main/resources/OH-INF/thing/bridge.xml

index ebaba9f9e3c7912fb5e3fed4a886ad6ddbc2071f..8e3d1d9919ad6dd48cce75ebcf8f8a74cb407af1 100644 (file)
@@ -101,7 +101,6 @@ public class HaywardBridgeHandler extends BaseBridgeHandler {
 
     @Override
     public void initialize() {
-        updateStatus(ThingStatus.UNKNOWN);
         initializeFuture = scheduler.schedule(this::scheduledInitialize, 1, TimeUnit.SECONDS);
         return;
     }
@@ -143,7 +142,10 @@ public class HaywardBridgeHandler extends BaseBridgeHandler {
                 return;
             }
 
-            updateStatus(ThingStatus.ONLINE);
+            if (this.thing.getStatus() != ThingStatus.ONLINE) {
+                updateStatus(ThingStatus.ONLINE);
+            }
+
             logger.debug("Succesfully opened connection to Hayward's server: {} Username:{}", config.endpointUrl,
                     config.username);
 
@@ -350,6 +352,7 @@ public class HaywardBridgeHandler extends BaseBridgeHandler {
                     commFailureCount++;
                     return;
                 }
+                updateStatus(ThingStatus.ONLINE);
             } catch (HaywardException e) {
                 logger.debug("Hayward Connection thing: Exception during poll: {}", e.getMessage());
             } catch (InterruptedException e) {
@@ -424,15 +427,15 @@ public class HaywardBridgeHandler extends BaseBridgeHandler {
             int status = httpResponse.getStatus();
             String xmlResponse = httpResponse.getContentAsString();
 
-            List<String> statusMessages = evaluateXPath("/Response/Parameters//Parameter[@name='StatusMessage']/text()",
-                    xmlResponse);
-            if (!(statusMessages.isEmpty())) {
-                statusMessage = statusMessages.get(0);
-            } else {
-                statusMessage = httpResponse.getReason();
-            }
-
             if (status == 200) {
+                List<String> statusMessages = evaluateXPath(
+                        "/Response/Parameters//Parameter[@name='StatusMessage']/text()", xmlResponse);
+                if (!(statusMessages.isEmpty())) {
+                    statusMessage = statusMessages.get(0);
+                } else {
+                    statusMessage = httpResponse.getReason();
+                }
+
                 if (logger.isTraceEnabled()) {
                     logger.trace("Hayward Connection thing:  {} Hayward http command: {}", getCallingMethod(),
                             urlParameters);
@@ -444,7 +447,8 @@ public class HaywardBridgeHandler extends BaseBridgeHandler {
                 if (logger.isDebugEnabled()) {
                     logger.debug("Hayward Connection thing:  {} Hayward http command: {}", getCallingMethod(),
                             urlParameters);
-                    logger.debug("Hayward Connection thing:  {} Hayward http response: {}", getCallingMethod(), status);
+                    logger.debug("Hayward Connection thing:  {} Hayward http response: {} {}", getCallingMethod(),
+                            status, xmlResponse);
                 }
                 return "";
             }
index 1b5c8f9534bfd86d9f64264807d6df2a09c1ad85..51d0a90868fcf808cd0334b4319967b998a60ec6 100644 (file)
@@ -13,7 +13,7 @@
                        <parameter name="endpointUrl" type="text" required="true">
                                <context>url</context>
                                <label>Endpoint URL</label>
-                               <default>https://app1.haywardomnilogic.com/HAAPI/HomeAutomation/API.ashx</default>
+                               <default>https://www.haywardomnilogic.com/HAAPI/HomeAutomation/API.ashx</default>
                                <description>The URL of the Hayward API Server</description>
                        </parameter>
                        <parameter name="username" type="text" required="true">