]> git.basschouten.com Git - openhab-addons.git/commitdiff
[unifi] Fix thing configuration reload after changes (#11411)
authorjlaur <jacob-github@vindvejr.dk>
Fri, 22 Oct 2021 22:05:16 +0000 (00:05 +0200)
committerGitHub <noreply@github.com>
Fri, 22 Oct 2021 22:05:16 +0000 (00:05 +0200)
* Fix config reload after changes.

Fixes #11407

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
* Don't try to initialize client when bridge is offline.

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/handler/UniFiBaseThingHandler.java
bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/handler/UniFiClientThingHandler.java

index cf57ec332c67aceb20a49e3fd586ac9a4299754b..69b6f840464ce84f175b2686de3e5ce35c360d7b 100644 (file)
@@ -59,6 +59,7 @@ public abstract class UniFiBaseThingHandler<E, C> extends BaseThingHandler {
         }
         if (bridge.getStatus() == OFFLINE) {
             updateStatus(OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, "The UniFi Controller is currently offline.");
+            return;
         }
         // mgb: derive the config class from the generic type
         Class<?> clazz = (Class<?>) (((ParameterizedType) getClass().getGenericSuperclass())
index 139e031fb9d11f41866a861ef9351c215b6db840..9ceaf35ba20b85245d2a082fc8d29bb19519ed7b 100644 (file)
@@ -69,16 +69,14 @@ public class UniFiClientThingHandler extends UniFiBaseThingHandler<UniFiClient,
     @Override
     protected synchronized void initialize(UniFiClientThingConfig config) {
         // mgb: called when the config changes
-        if (thing.getStatus() == INITIALIZING) {
-            logger.debug("Initializing the UniFi Client Handler with config = {}", config);
-            if (!config.isValid()) {
-                updateStatus(OFFLINE, CONFIGURATION_ERROR,
-                        "You must define a MAC address, IP address, hostname or alias for this thing.");
-                return;
-            }
-            this.config = config;
-            updateStatus(ONLINE);
+        logger.debug("Initializing the UniFi Client Handler with config = {}", config);
+        if (!config.isValid()) {
+            updateStatus(OFFLINE, CONFIGURATION_ERROR,
+                    "You must define a MAC address, IP address, hostname or alias for this thing.");
+            return;
         }
+        this.config = config;
+        updateStatus(ONLINE);
     }
 
     private static boolean belongsToSite(UniFiClient client, String siteName) {