From 7cd41a7c151fff19613cba5aa3566c37635431da Mon Sep 17 00:00:00 2001 From: clinique Date: Tue, 21 Jun 2022 13:22:34 +0200 Subject: [PATCH] Handling CHANGE message Signed-off-by: clinique --- .../internal/{xml => handler}/It4WifiConnector.java | 5 ++--- .../binding/mynice/internal/handler/It4WifiHandler.java | 8 +++++--- 2 files changed, 7 insertions(+), 6 deletions(-) rename bundles/org.openhab.binding.mynice/src/main/java/org/openhab/binding/mynice/internal/{xml => handler}/It4WifiConnector.java (97%) diff --git a/bundles/org.openhab.binding.mynice/src/main/java/org/openhab/binding/mynice/internal/xml/It4WifiConnector.java b/bundles/org.openhab.binding.mynice/src/main/java/org/openhab/binding/mynice/internal/handler/It4WifiConnector.java similarity index 97% rename from bundles/org.openhab.binding.mynice/src/main/java/org/openhab/binding/mynice/internal/xml/It4WifiConnector.java rename to bundles/org.openhab.binding.mynice/src/main/java/org/openhab/binding/mynice/internal/handler/It4WifiConnector.java index be930af956c2b..2aa2b60fab20f 100644 --- a/bundles/org.openhab.binding.mynice/src/main/java/org/openhab/binding/mynice/internal/xml/It4WifiConnector.java +++ b/bundles/org.openhab.binding.mynice/src/main/java/org/openhab/binding/mynice/internal/handler/It4WifiConnector.java @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.mynice.internal.xml; +package org.openhab.binding.mynice.internal.handler; import java.io.IOException; import java.io.InputStreamReader; @@ -29,7 +29,6 @@ import javax.net.ssl.TrustManager; import org.eclipse.jdt.annotation.NonNullByDefault; -import org.openhab.binding.mynice.internal.handler.It4WifiHandler; import org.openhab.binding.mynice.internal.xml.dto.CommandType; import org.openhab.core.io.net.http.TrustAllTrustManager; import org.slf4j.Logger; @@ -59,7 +58,7 @@ public class It4WifiConnector extends Thread { private Optional> keepAlive = Optional.empty(); public It4WifiConnector(String hostname, It4WifiHandler handler, ScheduledExecutorService scheduler) { - super(); + super(It4WifiConnector.class.getName()); this.hostname = hostname; this.handler = handler; this.scheduler = scheduler; diff --git a/bundles/org.openhab.binding.mynice/src/main/java/org/openhab/binding/mynice/internal/handler/It4WifiHandler.java b/bundles/org.openhab.binding.mynice/src/main/java/org/openhab/binding/mynice/internal/handler/It4WifiHandler.java index 44ff0e6b28c16..4df9f0bab6180 100644 --- a/bundles/org.openhab.binding.mynice/src/main/java/org/openhab/binding/mynice/internal/handler/It4WifiHandler.java +++ b/bundles/org.openhab.binding.mynice/src/main/java/org/openhab/binding/mynice/internal/handler/It4WifiHandler.java @@ -25,7 +25,6 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.binding.mynice.internal.config.It4WifiConfiguration; import org.openhab.binding.mynice.internal.discovery.MyNiceDiscoveryService; -import org.openhab.binding.mynice.internal.xml.It4WifiConnector; import org.openhab.binding.mynice.internal.xml.MyNiceXStream; import org.openhab.binding.mynice.internal.xml.RequestBuilder; import org.openhab.binding.mynice.internal.xml.dto.CommandType; @@ -91,7 +90,7 @@ public void initialize() { connector = new It4WifiConnector(config.hostname, this, scheduler); connected = false; if (config.username.isBlank()) { - updateStatus(ThingStatus.ONLINE, ThingStatusDetail.CONFIGURATION_PENDING, + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_PENDING, "Please define a username for this thing"); } else { reqBuilder = new RequestBuilder(config.macAddress, config.username); @@ -132,7 +131,7 @@ private void handleResponse(Response response) { sendCommand(CommandType.CONNECT); return; case wait: - updateStatus(ThingStatus.ONLINE, ThingStatusDetail.CONFIGURATION_PENDING, + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_PENDING, "Please validate the user on the MyNice application"); scheduler.schedule(() -> handShaked(), 15, TimeUnit.SECONDS); return; @@ -161,6 +160,9 @@ private void handleResponse(Response response) { case STATUS: notifyListeners(response.getDevices()); break; + case CHANGE: + logger.debug("Change command accepted"); + break; default: logger.info("Unhandled response type : {}", response.type); }