[miio] force start cloudconnector after credentials are updated (#11459)

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
This commit is contained in:
Marcel 2021-10-30 08:50:43 +02:00 committed by GitHub
parent 264e19dbfc
commit ad54da1638
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -82,7 +82,7 @@ public class MiIoHandlerFactory extends BaseThingHandlerFactory {
cloudConnector.setCredentials(username, password, country); cloudConnector.setCredentials(username, password, country);
try { try {
if (!scheduler.isShutdown()) { if (!scheduler.isShutdown()) {
scheduledTask = scheduler.submit(() -> cloudConnector.isConnected()); scheduledTask = scheduler.submit(() -> cloudConnector.isConnected(true));
} else { } else {
logger.debug("Unexpected: ScheduledExecutorService is shutdown."); logger.debug("Unexpected: ScheduledExecutorService is shutdown.");
} }

View File

@ -104,10 +104,17 @@ public class CloudConnector {
} }
public boolean isConnected() { public boolean isConnected() {
return isConnected(false);
}
public boolean isConnected(boolean force) {
final MiCloudConnector cl = cloudConnector; final MiCloudConnector cl = cloudConnector;
if (cl != null && cl.hasLoginToken()) { if (cl != null && cl.hasLoginToken()) {
return true; return true;
} }
if (force) {
logonCache.invalidateValue();
}
final @Nullable Boolean c = logonCache.getValue(); final @Nullable Boolean c = logonCache.getValue();
if (c != null && c.booleanValue()) { if (c != null && c.booleanValue()) {
return true; return true;