From d5f6bd326cefef9b6b9b07e85a12678e1cdd6cca Mon Sep 17 00:00:00 2001 From: cedricboon Date: Sun, 27 Sep 2020 23:20:25 +0200 Subject: [PATCH] Fixed 3 bugs (#8584) Fixed 3 bugs: - Network bridge not listening on bus - Reconnection handler keeps reconnecting even after a successful reconnection - Minor typo in alarm wakeup time channels Signed-off-by: Cedric Boon --- .../internal/handler/VelbusBridgeHandler.java | 5 +++-- .../handler/VelbusNetworkBridgeHandler.java | 13 +++++++------ .../src/main/resources/OH-INF/thing/thing-types.xml | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/bundles/org.openhab.binding.velbus/src/main/java/org/openhab/binding/velbus/internal/handler/VelbusBridgeHandler.java b/bundles/org.openhab.binding.velbus/src/main/java/org/openhab/binding/velbus/internal/handler/VelbusBridgeHandler.java index b50e6fc04..b8c887967 100644 --- a/bundles/org.openhab.binding.velbus/src/main/java/org/openhab/binding/velbus/internal/handler/VelbusBridgeHandler.java +++ b/bundles/org.openhab.binding.velbus/src/main/java/org/openhab/binding/velbus/internal/handler/VelbusBridgeHandler.java @@ -253,8 +253,9 @@ public abstract class VelbusBridgeHandler extends BaseBridgeHandler { int reconnectionInterval = bridgeConfig.reconnectionInterval; if (reconnectionInterval > 0) { this.reconnectionHandler = scheduler.scheduleWithFixedDelay(() -> { - if (connect() && reconnectionHandler != null) { - reconnectionHandler.cancel(false); + final ScheduledFuture currentReconnectionHandler = this.reconnectionHandler; + if (connect() && currentReconnectionHandler != null) { + currentReconnectionHandler.cancel(false); } }, reconnectionInterval, reconnectionInterval, TimeUnit.SECONDS); } diff --git a/bundles/org.openhab.binding.velbus/src/main/java/org/openhab/binding/velbus/internal/handler/VelbusNetworkBridgeHandler.java b/bundles/org.openhab.binding.velbus/src/main/java/org/openhab/binding/velbus/internal/handler/VelbusNetworkBridgeHandler.java index dad98ca73..41db20536 100644 --- a/bundles/org.openhab.binding.velbus/src/main/java/org/openhab/binding/velbus/internal/handler/VelbusNetworkBridgeHandler.java +++ b/bundles/org.openhab.binding.velbus/src/main/java/org/openhab/binding/velbus/internal/handler/VelbusNetworkBridgeHandler.java @@ -63,6 +63,13 @@ public class VelbusNetworkBridgeHandler extends VelbusBridgeHandler { updateStatus(ThingStatus.ONLINE); logger.debug("Bridge online on network address {}:{}", networkBridgeConfig.address, networkBridgeConfig.port); + + // Start Velbus packet listener. This listener will act on all packets coming from + // IP-interface. + Thread thread = new Thread(this::readPackets, "OH-binding-" + this.thing.getUID()); + thread.setDaemon(true); + thread.start(); + return true; } catch (IOException ex) { onConnectionLost(); @@ -70,12 +77,6 @@ public class VelbusNetworkBridgeHandler extends VelbusBridgeHandler { networkBridgeConfig.port); } - // Start Velbus packet listener. This listener will act on all packets coming from - // IP-interface. - Thread thread = new Thread(this::readPackets, "OH-binding-" + this.thing.getUID()); - thread.setDaemon(true); - thread.start(); - return false; } diff --git a/bundles/org.openhab.binding.velbus/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.velbus/src/main/resources/OH-INF/thing/thing-types.xml index d5f1cd713..4b317cdb8 100644 --- a/bundles/org.openhab.binding.velbus/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.velbus/src/main/resources/OH-INF/thing/thing-types.xml @@ -1338,7 +1338,7 @@ - +