]> git.basschouten.com Git - openhab-addons.git/commitdiff
[deconz] retry full state request if initial request failed (#8704)
authorJ-N-K <J-N-K@users.noreply.github.com>
Sat, 10 Oct 2020 20:56:22 +0000 (22:56 +0200)
committerGitHub <noreply@github.com>
Sat, 10 Oct 2020 20:56:22 +0000 (22:56 +0200)
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/DeconzBridgeHandler.java

index b855761ef9d6b319675e987d4918d6a7a7d80bc8..28497b70d06383fdaf9c3e0ed3bc9e1bf898b907 100644 (file)
@@ -71,7 +71,7 @@ public class ThingDiscoveryService extends AbstractDiscoveryService implements D
     protected void startScan() {
         final DeconzBridgeHandler handler = this.handler;
         if (handler != null) {
-            handler.requestFullState();
+            handler.requestFullState(false);
         }
     }
 
index 71fdf633c62a6b0902a23fc0c5f8463da66e8959..b24be497ae1e441665b7938327599f20e6e084b0 100644 (file)
@@ -135,7 +135,7 @@ public class DeconzBridgeHandler extends BaseBridgeHandler implements WebSocketC
             configuration.put(CONFIG_APIKEY, config.apikey);
             updateConfiguration(configuration);
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_PENDING, "Waiting for configuration");
-            requestFullState();
+            requestFullState(true);
         } else {
             throw new IllegalStateException("Unknown status code for authorisation request");
         }
@@ -161,7 +161,7 @@ public class DeconzBridgeHandler extends BaseBridgeHandler implements WebSocketC
      * Perform a request to the REST API for retrieving the full bridge state with all sensors and switches
      * and configuration.
      */
-    public void requestFullState() {
+    public void requestFullState(boolean isInitialRequest) {
         if (config.apikey == null) {
             return;
         }
@@ -182,6 +182,10 @@ public class DeconzBridgeHandler extends BaseBridgeHandler implements WebSocketC
             }
         }).thenAccept(fullState -> {
             if (fullState == null) {
+                if (isInitialRequest) {
+                    scheduledFuture = scheduler.schedule(() -> requestFullState(true), POLL_FREQUENCY_SEC,
+                            TimeUnit.SECONDS);
+                }
                 return;
             }
             if (fullState.config.name.isEmpty()) {
@@ -260,7 +264,7 @@ public class DeconzBridgeHandler extends BaseBridgeHandler implements WebSocketC
         if (config.apikey == null) {
             requestApiKey();
         } else {
-            requestFullState();
+            requestFullState(true);
         }
     }