]> git.basschouten.com Git - openhab-addons.git/commitdiff
[somfytahoma] Fixed bug causing Gateway and Actiongroups get never ONLINE (#10355)
authorOndrej Pecta <opecta@gmail.com>
Sun, 28 Mar 2021 16:52:33 +0000 (18:52 +0200)
committerGitHub <noreply@github.com>
Sun, 28 Mar 2021 16:52:33 +0000 (18:52 +0200)
Signed-off-by: Ondrej Pecta <opecta@gmail.com>
bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaActionGroupHandler.java
bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaBaseThingHandler.java
bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaGatewayHandler.java

index 3b31eae33d865f0b23b7358185b2b325b8c3557a..75b18ee753782bd15481fb845d1f80a64fb564a1 100644 (file)
@@ -15,9 +15,12 @@ package org.openhab.binding.somfytahoma.internal.handler;
 import static org.openhab.binding.somfytahoma.internal.SomfyTahomaBindingConstants.EXECUTE_ACTION;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.thing.ChannelUID;
 import org.openhab.core.thing.Thing;
+import org.openhab.core.thing.ThingStatus;
+import org.openhab.core.thing.ThingStatusDetail;
 import org.openhab.core.types.Command;
 
 /**
@@ -34,8 +37,16 @@ public class SomfyTahomaActionGroupHandler extends SomfyTahomaBaseThingHandler {
     }
 
     @Override
-    protected boolean isAlwaysOnline() {
-        return true;
+    public void initializeThing(@Nullable ThingStatus bridgeStatus) {
+        if (bridgeStatus != null) {
+            if (bridgeStatus == ThingStatus.ONLINE) {
+                updateStatus(ThingStatus.ONLINE);
+            } else {
+                updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
+            }
+        } else {
+            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED);
+        }
     }
 
     @Override
index 9861a59c7256d92357820ad242ac665041e19d27..003df0d7ab468802821911078def4d4d6746733b 100644 (file)
@@ -146,10 +146,6 @@ public abstract class SomfyTahomaBaseThingHandler extends BaseThingHandler {
         return logger;
     }
 
-    protected boolean isAlwaysOnline() {
-        return false;
-    }
-
     protected @Nullable SomfyTahomaBridgeHandler getBridgeHandler() {
         Bridge localBridge = this.getBridge();
         return localBridge != null ? (SomfyTahomaBridgeHandler) localBridge.getHandler() : null;
@@ -167,7 +163,7 @@ public abstract class SomfyTahomaBaseThingHandler extends BaseThingHandler {
     }
 
     private void setUnavailable() {
-        if (ThingStatus.OFFLINE != thing.getStatus() && !isAlwaysOnline()) {
+        if (ThingStatus.OFFLINE != thing.getStatus()) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, UNAVAILABLE);
         }
     }
index 302631f849ba57562e40e1c16ea9613d5c9ffd01..9bab4cebe99032582b08633c3f593ea0caf4e051 100644 (file)
  */
 package org.openhab.binding.somfytahoma.internal.handler;
 
+import static org.openhab.binding.somfytahoma.internal.SomfyTahomaBindingConstants.STATUS;
 import static org.openhab.core.thing.Thing.PROPERTY_FIRMWARE_VERSION;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.somfytahoma.internal.model.SomfyTahomaStatus;
 import org.openhab.core.library.types.StringType;
 import org.openhab.core.thing.Channel;
 import org.openhab.core.thing.Thing;
 import org.openhab.core.thing.ThingStatus;
+import org.openhab.core.thing.ThingStatusDetail;
 
 /**
  * The {@link SomfyTahomaGatewayHandler} is responsible for handling commands,
@@ -34,6 +37,19 @@ public class SomfyTahomaGatewayHandler extends SomfyTahomaBaseThingHandler {
         super(thing);
     }
 
+    @Override
+    public void initializeThing(@Nullable ThingStatus bridgeStatus) {
+        if (bridgeStatus != null) {
+            if (bridgeStatus == ThingStatus.ONLINE) {
+                refresh(STATUS);
+            } else {
+                updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
+            }
+        } else {
+            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED);
+        }
+    }
+
     @Override
     public void refresh(String channel) {
         String id = getGateWayId();