[easee] Fix binding not working after Easee cloud API has been unavailable (#13469)

* fix #13463

Signed-off-by: Alexander Friese <af944580@googlemail.com>
This commit is contained in:
alexf2015 2022-10-02 18:28:33 +02:00 committed by GitHub
parent c9decdbe49
commit e9848e27e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -222,7 +222,7 @@ public class WebInterface implements AtomicReferenceTrait {
private synchronized void refreshAccessToken() {
Instant now = Instant.now();
if (now.isAfter(tokenExpiry.minus(WEB_REQUEST_TOKEN_EXPIRY_BUFFER_MINUTES, ChronoUnit.MINUTES))
if (now.plus(WEB_REQUEST_TOKEN_EXPIRY_BUFFER_MINUTES, ChronoUnit.MINUTES).isAfter(tokenExpiry)
|| now.isAfter(tokenRefreshDate.plus(WEB_REQUEST_TOKEN_MAX_AGE_MINUTES, ChronoUnit.MINUTES))) {
logger.debug("access token needs to be refreshed, last refresh: {}, expiry: {}",
Utils.formatDate(tokenRefreshDate), Utils.formatDate(tokenExpiry));