Skip to content

Commit

Permalink
[ihc] Improved command handling when controller is not ready (openhab…
Browse files Browse the repository at this point in the history
…#10895)

* [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 <pauli.anttila@gmail.com>
Signed-off-by: dw-8 <davy.wong.on+github@gmail.com>
  • Loading branch information
paulianttila authored and dw-8 committed Jul 25, 2021
1 parent cbc1eff commit 2a683ed
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,21 @@ 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.debug("Controller is not ONLINE, aborting resource value update for channel '{}'!", channelUID);
return;
}

switch (channelUID.getId()) {
case CHANNEL_CONTROLLER_STATE:
if (command.equals(RefreshType.REFRESH)) {
Expand Down

0 comments on commit 2a683ed

Please sign in to comment.