Skip to content

Commit

Permalink
Bridge status changed handling
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Herwege <[email protected]>
  • Loading branch information
mherwege committed May 28, 2022
1 parent a3b9422 commit 43aee76
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
import org.openhab.core.thing.ThingStatusDetail;
import org.openhab.core.thing.ThingStatusInfo;
import org.openhab.core.thing.binding.BaseThingHandler;
import org.openhab.core.types.Command;
import org.slf4j.Logger;
Expand Down Expand Up @@ -357,4 +358,16 @@ private void restartCommunication(NikoHomeControlCommunication nhcComm) {
Bridge nhcBridge = getBridge();
return nhcBridge != null ? (NikoHomeControlBridgeHandler) nhcBridge.getHandler() : null;
}

@Override
public void bridgeStatusChanged(ThingStatusInfo statusInfo) {
ThingStatus status = statusInfo.getStatus();
if (ThingStatus.ONLINE.equals(status)) {
updateStatus(ThingStatus.ONLINE);
} else if (ThingStatus.OFFLINE.equals(status)) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
} else {
updateStatus(ThingStatus.UNKNOWN);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
import org.openhab.core.thing.ThingStatusDetail;
import org.openhab.core.thing.ThingStatusInfo;
import org.openhab.core.thing.binding.BaseThingHandler;
import org.openhab.core.types.Command;
import org.openhab.core.types.UnDefType;
Expand Down Expand Up @@ -236,4 +237,16 @@ private void restartCommunication(NikoHomeControlCommunication nhcComm) {
Bridge nhcBridge = getBridge();
return nhcBridge != null ? (NikoHomeControlBridgeHandler) nhcBridge.getHandler() : null;
}

@Override
public void bridgeStatusChanged(ThingStatusInfo statusInfo) {
ThingStatus status = statusInfo.getStatus();
if (ThingStatus.ONLINE.equals(status)) {
updateStatus(ThingStatus.ONLINE);
} else if (ThingStatus.OFFLINE.equals(status)) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
} else {
updateStatus(ThingStatus.UNKNOWN);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
import org.openhab.core.thing.ThingStatusDetail;
import org.openhab.core.thing.ThingStatusInfo;
import org.openhab.core.thing.binding.BaseThingHandler;
import org.openhab.core.types.Command;
import org.slf4j.Logger;
Expand Down Expand Up @@ -317,4 +318,16 @@ private void restartCommunication(NikoHomeControlCommunication nhcComm) {
Bridge nhcBridge = getBridge();
return nhcBridge != null ? (NikoHomeControlBridgeHandler) nhcBridge.getHandler() : null;
}

@Override
public void bridgeStatusChanged(ThingStatusInfo statusInfo) {
ThingStatus status = statusInfo.getStatus();
if (ThingStatus.ONLINE.equals(status)) {
updateStatus(ThingStatus.ONLINE);
} else if (ThingStatus.OFFLINE.equals(status)) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
} else {
updateStatus(ThingStatus.UNKNOWN);
}
}
}

0 comments on commit 43aee76

Please sign in to comment.