mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 07:02:02 +01:00
Working on jlaur proposal
Signed-off-by: gael@lhopital.org <gael@lhopital.org>
This commit is contained in:
parent
705feffd54
commit
0ffc18a7f6
@ -20,6 +20,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayDeque;
|
||||
@ -161,6 +162,7 @@ public class ApiBridgeHandler extends BaseBridgeHandler {
|
||||
}
|
||||
|
||||
logger.debug("Connected to Netatmo API.");
|
||||
freeConnectJob();
|
||||
|
||||
ApiHandlerConfiguration configuration = getConfiguration();
|
||||
if (!configuration.webHookUrl.isBlank()
|
||||
@ -452,4 +454,8 @@ public class ApiBridgeHandler extends BaseBridgeHandler {
|
||||
public Optional<WebhookServlet> getWebHookServlet() {
|
||||
return webHookServlet;
|
||||
}
|
||||
|
||||
public @Nullable Duration getTimeBeforeReconnect() {
|
||||
return connectJob.map(job -> Duration.ofSeconds(job.getDelay(TimeUnit.SECONDS))).orElse(null);
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.netatmo.internal.api.dto.NAObject;
|
||||
import org.openhab.binding.netatmo.internal.handler.ApiBridgeHandler;
|
||||
import org.openhab.binding.netatmo.internal.handler.CommonInterface;
|
||||
import org.openhab.core.thing.ThingStatus;
|
||||
import org.slf4j.Logger;
|
||||
@ -86,8 +87,15 @@ public class RefreshCapability extends Capability {
|
||||
Duration delay;
|
||||
handler.proceedWithUpdate();
|
||||
if (!ThingStatus.ONLINE.equals(handler.getThing().getStatus())) {
|
||||
delay = OFFLINE_DELAY;
|
||||
logger.debug("Thing '{}' is not ONLINE, using special refresh interval", thingUID);
|
||||
if (handler.getAccountHandler() instanceof ApiBridgeHandler accountHandler
|
||||
&& !ThingStatus.ONLINE.equals(accountHandler.getThing().getStatus())) {
|
||||
delay = accountHandler.getTimeBeforeReconnect();
|
||||
delay = delay != null ? delay.plus(ASAP) : OFFLINE_DELAY;
|
||||
} else {
|
||||
delay = OFFLINE_DELAY;
|
||||
logger.debug("Thing '{}' is not ONLINE, special refresh interval {} used", thingUID, OFFLINE_DELAY);
|
||||
}
|
||||
|
||||
} else {
|
||||
delay = calcDelay();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user