]> git.basschouten.com Git - openhab-addons.git/commitdiff
[hdpowerview] Remove unnecessary init checks and fix Thing status detail (#12331)
authorFabian Wolter <github@fabian-wolter.de>
Mon, 28 Feb 2022 21:53:33 +0000 (22:53 +0100)
committerGitHub <noreply@github.com>
Mon, 28 Feb 2022 21:53:33 +0000 (22:53 +0100)
* [hdpowerview] Remove unnecessary init checks and fix Thing status detail

Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
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/HDPowerViewRepeaterHandler.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 477ebdb734c021f75739894c7b5892e48b06395b..18014108b3e16c0605293566d1411f7c224881d6 100644 (file)
@@ -311,7 +311,7 @@ public class HDPowerViewHubHandler extends BaseBridgeHandler {
             // exceptions are logged in HDPowerViewWebTargets
         } catch (HubException e) {
             logger.warn("Error connecting to bridge: {}", e.getMessage());
-            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, e.getMessage());
+            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
         }
     }
 
index a3a0cf35fee7871c1f007f37462eef85172ab8fa..498a147ee7b091eff6cacbd225998fc8280fdf3c 100644 (file)
@@ -67,18 +67,9 @@ public class HDPowerViewRepeaterHandler extends AbstractHubbedThingHandler {
     public void initialize() {
         repeaterId = getConfigAs(HDPowerViewRepeaterConfiguration.class).id;
         logger.debug("Initializing repeater handler for repeater {}", repeaterId);
-        if (repeaterId <= 0) {
-            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
-                    "@text/offline.conf-error.invalid-id");
-            return;
-        }
         Bridge bridge = getBridge();
         if (bridge == null) {
-            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED);
-            return;
-        }
-        if (!(bridge.getHandler() instanceof HDPowerViewHubHandler)) {
-            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED,
+            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                     "@text/offline.conf-error.invalid-bridge-handler");
             return;
         }
index 5b0cb829a543ad80d8b666418e775e45c7f53ac1..2c072811c6451870a7d55d06e7862ff612ca3a80 100644 (file)
@@ -94,21 +94,13 @@ public class HDPowerViewShadeHandler extends AbstractHubbedThingHandler {
         isDisposing = false;
         shadeId = getConfigAs(HDPowerViewShadeConfiguration.class).id;
         logger.debug("Initializing shade handler for shade {}", shadeId);
-        if (shadeId <= 0) {
-            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
-                    "@text/offline.conf-error.invalid-id");
-            return;
-        }
         Bridge bridge = getBridge();
         if (bridge == null) {
-            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED);
-            return;
-        }
-        if (!(bridge.getHandler() instanceof HDPowerViewHubHandler)) {
-            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED,
+            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                     "@text/offline.conf-error.invalid-bridge-handler");
             return;
         }
+
         updateStatus(ThingStatus.UNKNOWN);
     }
 
index e72a760ba82085b77d1848363663a4723d73368e..7623d434610a810a8a108a66c3dae1a940f24bd7 100644 (file)
@@ -52,7 +52,6 @@ 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.invalid-id = Configuration 'id' not a valid integer
 offline.conf-error.invalid-bridge-handler = Invalid bridge handler
 offline.gone.shade-unknown-to-hub = Shade is unknown to Hub