From e9848e27e875468c2a57f200f21a9dfa0568e65f Mon Sep 17 00:00:00 2001 From: alexf2015 Date: Sun, 2 Oct 2022 18:28:33 +0200 Subject: [PATCH] [easee] Fix binding not working after Easee cloud API has been unavailable (#13469) * fix #13463 Signed-off-by: Alexander Friese --- .../openhab/binding/easee/internal/connector/WebInterface.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.easee/src/main/java/org/openhab/binding/easee/internal/connector/WebInterface.java b/bundles/org.openhab.binding.easee/src/main/java/org/openhab/binding/easee/internal/connector/WebInterface.java index 49a54660f..42d132903 100644 --- a/bundles/org.openhab.binding.easee/src/main/java/org/openhab/binding/easee/internal/connector/WebInterface.java +++ b/bundles/org.openhab.binding.easee/src/main/java/org/openhab/binding/easee/internal/connector/WebInterface.java @@ -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));