From f0ce2fc9fed7f52082a0aad2adefa5989663b529 Mon Sep 17 00:00:00 2001 From: "gael@lhopital.org" Date: Fri, 3 Jan 2025 18:09:42 +0100 Subject: [PATCH] Completing Signed-off-by: gael@lhopital.org --- .../netatmo/internal/handler/ApiBridgeHandler.java | 11 +++++++---- .../handler/capability/RefreshCapability.java | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/ApiBridgeHandler.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/ApiBridgeHandler.java index 128adeaabdd..d268551b708 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/ApiBridgeHandler.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/ApiBridgeHandler.java @@ -295,11 +295,14 @@ public class ApiBridgeHandler extends BaseBridgeHandler { public synchronized T executeUri(URI uri, HttpMethod method, Class clazz, @Nullable String payload, @Nullable String contentType, int retryCount) throws NetatmoException { + if (connectJob.isPresent()) { + throw new NetatmoException("Connection pending, request will not be accepted in the meantime."); + } + + logger.debug("executeUri {} {} ", method.toString(), uri); + Request request = httpClient.newRequest(uri).method(method).timeout(TIMEOUT_S, TimeUnit.SECONDS); + try { - logger.debug("executeUri {} {} ", method.toString(), uri); - - Request request = httpClient.newRequest(uri).method(method).timeout(TIMEOUT_S, TimeUnit.SECONDS); - if (!authenticate(null, null)) { prepareReconnection(getConfiguration().reconnectInterval, "@text/status-bridge-offline", null, null); throw new NetatmoException("Not authenticated"); diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/RefreshCapability.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/RefreshCapability.java index de1d2ff4a46..adee890d330 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/RefreshCapability.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/RefreshCapability.java @@ -91,9 +91,10 @@ public class RefreshCapability extends Capability { && !ThingStatus.ONLINE.equals(accountHandler.getThing().getStatus())) { delay = accountHandler.getTimeBeforeReconnect(); delay = delay != null ? delay.plus(ASAP) : OFFLINE_DELAY; + logger.debug("Bridge is not ONLINE, will wait for him to come-back {}", thingUID, delay); } else { delay = OFFLINE_DELAY; - logger.debug("Thing '{}' is not ONLINE, special refresh interval {} used", thingUID, OFFLINE_DELAY); + logger.debug("Thing '{}' is not ONLINE, special refresh interval {} used", thingUID, delay); } } else {