From 8ce150e5dd8a8faa9b59dc6f14ffb5f8e886af92 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sat, 30 Oct 2021 08:50:43 +0200 Subject: [PATCH] [miio] force start cloudconnector after credentials are updated (#11459) Signed-off-by: Marcel Verpaalen --- .../openhab/binding/miio/internal/MiIoHandlerFactory.java | 2 +- .../binding/miio/internal/cloud/CloudConnector.java | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/MiIoHandlerFactory.java b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/MiIoHandlerFactory.java index 523efc2565904..afb8073b11228 100644 --- a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/MiIoHandlerFactory.java +++ b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/MiIoHandlerFactory.java @@ -82,7 +82,7 @@ public MiIoHandlerFactory(@Reference HttpClientFactory httpClientFactory, cloudConnector.setCredentials(username, password, country); try { if (!scheduler.isShutdown()) { - scheduledTask = scheduler.submit(() -> cloudConnector.isConnected()); + scheduledTask = scheduler.submit(() -> cloudConnector.isConnected(true)); } else { logger.debug("Unexpected: ScheduledExecutorService is shutdown."); } diff --git a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/cloud/CloudConnector.java b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/cloud/CloudConnector.java index 626b7515c2ba5..137c65774a1a6 100644 --- a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/cloud/CloudConnector.java +++ b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/cloud/CloudConnector.java @@ -104,10 +104,17 @@ public void dispose() { } public boolean isConnected() { + return isConnected(false); + } + + public boolean isConnected(boolean force) { final MiCloudConnector cl = cloudConnector; if (cl != null && cl.hasLoginToken()) { return true; } + if (force) { + logonCache.invalidateValue(); + } final @Nullable Boolean c = logonCache.getValue(); if (c != null && c.booleanValue()) { return true;