From 43aee76642d4448501db15f165a007389a047580 Mon Sep 17 00:00:00 2001 From: Mark Herwege Date: Tue, 14 Dec 2021 12:40:19 +0100 Subject: [PATCH] Bridge status changed handling Signed-off-by: Mark Herwege --- .../handler/NikoHomeControlActionHandler.java | 13 +++++++++++++ .../handler/NikoHomeControlEnergyMeterHandler.java | 13 +++++++++++++ .../handler/NikoHomeControlThermostatHandler.java | 13 +++++++++++++ 3 files changed, 39 insertions(+) diff --git a/bundles/org.openhab.binding.nikohomecontrol/src/main/java/org/openhab/binding/nikohomecontrol/internal/handler/NikoHomeControlActionHandler.java b/bundles/org.openhab.binding.nikohomecontrol/src/main/java/org/openhab/binding/nikohomecontrol/internal/handler/NikoHomeControlActionHandler.java index 54d7d138d2bee..ef5fbbff418e3 100644 --- a/bundles/org.openhab.binding.nikohomecontrol/src/main/java/org/openhab/binding/nikohomecontrol/internal/handler/NikoHomeControlActionHandler.java +++ b/bundles/org.openhab.binding.nikohomecontrol/src/main/java/org/openhab/binding/nikohomecontrol/internal/handler/NikoHomeControlActionHandler.java @@ -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; @@ -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); + } + } } diff --git a/bundles/org.openhab.binding.nikohomecontrol/src/main/java/org/openhab/binding/nikohomecontrol/internal/handler/NikoHomeControlEnergyMeterHandler.java b/bundles/org.openhab.binding.nikohomecontrol/src/main/java/org/openhab/binding/nikohomecontrol/internal/handler/NikoHomeControlEnergyMeterHandler.java index 73ebf79faf559..f2da120d1a48e 100644 --- a/bundles/org.openhab.binding.nikohomecontrol/src/main/java/org/openhab/binding/nikohomecontrol/internal/handler/NikoHomeControlEnergyMeterHandler.java +++ b/bundles/org.openhab.binding.nikohomecontrol/src/main/java/org/openhab/binding/nikohomecontrol/internal/handler/NikoHomeControlEnergyMeterHandler.java @@ -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; @@ -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); + } + } } diff --git a/bundles/org.openhab.binding.nikohomecontrol/src/main/java/org/openhab/binding/nikohomecontrol/internal/handler/NikoHomeControlThermostatHandler.java b/bundles/org.openhab.binding.nikohomecontrol/src/main/java/org/openhab/binding/nikohomecontrol/internal/handler/NikoHomeControlThermostatHandler.java index 8e0ef3ea9678c..6861742d00e89 100644 --- a/bundles/org.openhab.binding.nikohomecontrol/src/main/java/org/openhab/binding/nikohomecontrol/internal/handler/NikoHomeControlThermostatHandler.java +++ b/bundles/org.openhab.binding.nikohomecontrol/src/main/java/org/openhab/binding/nikohomecontrol/internal/handler/NikoHomeControlThermostatHandler.java @@ -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; @@ -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); + } + } }