]> git.basschouten.com Git - openhab-addons.git/commitdiff
Fix initialization of shade handler. (#11707)
authorjlaur <jacob-github@vindvejr.dk>
Sun, 5 Dec 2021 16:48:37 +0000 (17:48 +0100)
committerGitHub <noreply@github.com>
Sun, 5 Dec 2021 16:48:37 +0000 (17:48 +0100)
Fixes #11702

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewHubHandler.java
bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewShadeHandler.java
bundles/org.openhab.binding.hdpowerview/src/main/resources/OH-INF/i18n/hdpowerview.properties

index 35f1696932efade9800d5e59009fd15de3e78288..2eda6b8b23598d2926dcb5bbf1692c3830050d4e 100644 (file)
@@ -135,7 +135,7 @@ public class HDPowerViewHubHandler extends BaseBridgeHandler {
 
         if (host == null || host.isEmpty()) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
-                    "@text/offline.conf-error-no-host-address");
+                    "@text/offline.conf-error.no-host-address");
             return;
         }
 
index 42514597bafbf3694ae4acf711f265f045b32344..038b4f71a370a3722f8823e5c5960303eeb233ea 100644 (file)
@@ -39,6 +39,7 @@ import org.openhab.core.library.types.QuantityType;
 import org.openhab.core.library.types.StopMoveType;
 import org.openhab.core.library.types.UpDownType;
 import org.openhab.core.library.unit.Units;
+import org.openhab.core.thing.Bridge;
 import org.openhab.core.thing.ChannelUID;
 import org.openhab.core.thing.Thing;
 import org.openhab.core.thing.ThingStatus;
@@ -80,14 +81,25 @@ public class HDPowerViewShadeHandler extends AbstractHubbedThingHandler {
             getShadeId();
         } catch (NumberFormatException e) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
-                    "Configuration 'id' not a valid integer");
+                    "@text/offline.conf-error.invalid-id");
             return;
         }
-        if (getBridgeHandler() == null) {
-            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Hub not configured");
+        Bridge bridge = getBridge();
+        if (bridge == null) {
+            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED);
             return;
         }
-        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR);
+        if (!(bridge.getHandler() instanceof HDPowerViewHubHandler)) {
+            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED,
+                    "@text/offline.conf-error.invalid-bridge-handler");
+            return;
+        }
+        ThingStatus bridgeStatus = bridge.getStatus();
+        if (bridgeStatus == ThingStatus.ONLINE) {
+            updateStatus(ThingStatus.ONLINE);
+        } else {
+            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
+        }
     }
 
     @Override
index 34875ac80c5927f2110b86c3326817d4381b5df3..9e8e94cd181794a88249d3da6e573fdfb4d74bbf 100644 (file)
@@ -36,7 +36,9 @@ channel-type.hdpowerview.shade-vane.description = The opening of the slats in th
 
 # thing status descriptions
 
-offline.conf-error-no-host-address = Host address must be set
+offline.conf-error.no-host-address = Host address must be set
+offline.conf-error.invalid-id = Configuration 'id' not a valid integer
+offline.conf-error.invalid-bridge-handler = Invalid bridge handler
 
 # dynamic channels