[haywardomnilogic] Fix bridge thing status upon re-establishing server comms (#10371)

* 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>
This commit is contained in:
Matt 2021-04-02 16:24:31 -04:00 committed by GitHub
parent f8f0d8972b
commit 089ee3227a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 12 deletions

View 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 "";
}

View 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">