[qbus] - Update logo / Small code changes (#10514)

Signed-off-by: Koen Schockaert <ks@qbus.be>
This commit is contained in:
Koen Schockaert
2021-04-22 09:18:02 +02:00
committed by GitHub
parent a54f4be094
commit d3c137c73d
4 changed files with 42 additions and 33 deletions

View File

@@ -56,15 +56,15 @@ public class QbusBridgeHandler extends BaseBridgeHandler {
*/
@Override
public void initialize() {
Integer serverCheck = getServerCheck();
readConfig();
createCommunicationObject();
Integer serverCheck = getServerCheck();
if (serverCheck != null) {
this.setupRefreshTimer(serverCheck);
}
createCommunicationObject();
}
/**
@@ -176,6 +176,7 @@ public class QbusBridgeHandler extends BaseBridgeHandler {
}
refreshTimer = scheduler.scheduleWithFixedDelay(() -> {
logger.debug("Timer started");
QbusCommunication comm = getCommunication();
Integer serverCheck = getServerCheck();

View File

@@ -121,12 +121,26 @@ public final class QbusCommunication extends BaseThingHandler {
InetAddress addr = InetAddress.getByName(handler.getAddress());
Integer port = handler.getPort();
if (port != null) {
Socket socket = new Socket(addr, port);
if (port == null) {
handler.bridgeOffline(ThingStatusDetail.CONFIGURATION_ERROR, "Please set a correct port.");
return;
}
if (addr == null) {
handler.bridgeOffline(ThingStatusDetail.CONFIGURATION_ERROR, "Please set the hostname of the Qbus server.");
return;
}
Socket socket = null;
try {
socket = new Socket(addr, port);
qSocket = socket;
qOut = new PrintWriter(socket.getOutputStream(), true);
qIn = new BufferedReader(new InputStreamReader(socket.getInputStream()));
} else {
} catch (IOException e) {
String msg = e.getMessage();
handler.bridgeOffline(ThingStatusDetail.COMMUNICATION_ERROR, "No communication with Qbus Server. " + msg);
return;
}
@@ -338,7 +352,6 @@ public final class QbusCommunication extends BaseThingHandler {
logger.trace("Not acted on unsupported json {} : {}", qMessage, msg);
return;
}
QbusBridgeHandler handler = bridgeCallBack;
if (handler != null) {