From 1509c15c86d725cc7f558565313f1cf3957aaa5f Mon Sep 17 00:00:00 2001 From: Pauli Anttila Date: Mon, 21 Jun 2021 21:05:59 +0300 Subject: [PATCH 1/3] [ihc] Improved command handling when controller is not ready When connection from binding to IHC controller is open, but controller is in programming state, things state is offline with special status to indicate that binding can't send or receive any resource updates at the moment. Things status check during command sending will prevent unnecessary resource updates which will eventually fail and binding then tries to restart the connection. Signed-off-by: Pauli Anttila --- .../org/openhab/binding/ihc/internal/handler/IhcHandler.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bundles/org.openhab.binding.ihc/src/main/java/org/openhab/binding/ihc/internal/handler/IhcHandler.java b/bundles/org.openhab.binding.ihc/src/main/java/org/openhab/binding/ihc/internal/handler/IhcHandler.java index 9c7d36ea1e30b..645fc8103c073 100644 --- a/bundles/org.openhab.binding.ihc/src/main/java/org/openhab/binding/ihc/internal/handler/IhcHandler.java +++ b/bundles/org.openhab.binding.ihc/src/main/java/org/openhab/binding/ihc/internal/handler/IhcHandler.java @@ -212,6 +212,11 @@ public void handleCommand(ChannelUID channelUID, Command command) { return; } + if (thing.getStatus() != ThingStatus.ONLINE) { + logger.warn("Controller is not ONLINE state, abort resource value update for channel '{}'!", channelUID); + return; + } + switch (channelUID.getId()) { case CHANNEL_CONTROLLER_STATE: if (command.equals(RefreshType.REFRESH)) { From 47548f18ee7c8d39eac31ddcceaef6bdb1465b41 Mon Sep 17 00:00:00 2001 From: Pauli Anttila Date: Tue, 22 Jun 2021 17:07:20 +0300 Subject: [PATCH 2/3] Logging improvements Signed-off-by: Pauli Anttila --- .../openhab/binding/ihc/internal/handler/IhcHandler.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.binding.ihc/src/main/java/org/openhab/binding/ihc/internal/handler/IhcHandler.java b/bundles/org.openhab.binding.ihc/src/main/java/org/openhab/binding/ihc/internal/handler/IhcHandler.java index 645fc8103c073..43a02cb95091e 100644 --- a/bundles/org.openhab.binding.ihc/src/main/java/org/openhab/binding/ihc/internal/handler/IhcHandler.java +++ b/bundles/org.openhab.binding.ihc/src/main/java/org/openhab/binding/ihc/internal/handler/IhcHandler.java @@ -202,18 +202,19 @@ public void handleCommand(ChannelUID channelUID, Command command) { logger.debug("Received channel: {}, command: {}", channelUID, command); if (ihc == null) { - logger.warn("Connection is not initialized, abort resource value update for channel '{}'!", channelUID); + logger.debug("Connection is not initialized, aborting resource value update for channel '{}'!", channelUID); return; } if (ihc.getConnectionState() != ConnectionState.CONNECTED) { - logger.warn("Connection to controller is not open, abort resource value update for channel '{}'!", + logger.debug("Connection to controller is not open, aborting resource value update for channel '{}'!", channelUID); return; } if (thing.getStatus() != ThingStatus.ONLINE) { - logger.warn("Controller is not ONLINE state, abort resource value update for channel '{}'!", channelUID); + logger.debug("Controller is not ONLINE, aborting resource value update for channel '{}'!", + channelUID); return; } From 8ee3a1b87202f7e166f6297e25568e5352ce6033 Mon Sep 17 00:00:00 2001 From: Pauli Anttila Date: Fri, 25 Jun 2021 09:53:10 +0300 Subject: [PATCH 3/3] Fixed format violation Signed-off-by: Pauli Anttila --- .../org/openhab/binding/ihc/internal/handler/IhcHandler.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bundles/org.openhab.binding.ihc/src/main/java/org/openhab/binding/ihc/internal/handler/IhcHandler.java b/bundles/org.openhab.binding.ihc/src/main/java/org/openhab/binding/ihc/internal/handler/IhcHandler.java index 43a02cb95091e..8590338583c23 100644 --- a/bundles/org.openhab.binding.ihc/src/main/java/org/openhab/binding/ihc/internal/handler/IhcHandler.java +++ b/bundles/org.openhab.binding.ihc/src/main/java/org/openhab/binding/ihc/internal/handler/IhcHandler.java @@ -213,8 +213,7 @@ public void handleCommand(ChannelUID channelUID, Command command) { } if (thing.getStatus() != ThingStatus.ONLINE) { - logger.debug("Controller is not ONLINE, aborting resource value update for channel '{}'!", - channelUID); + logger.debug("Controller is not ONLINE, aborting resource value update for channel '{}'!", channelUID); return; }