]> git.basschouten.com Git - openhab-addons.git/commitdiff
[netatmo] Ensure expiresAt is usable (#17553)
authorGaël L'hopital <gael@lhopital.org>
Sun, 13 Oct 2024 09:50:27 +0000 (11:50 +0200)
committerGitHub <noreply@github.com>
Sun, 13 Oct 2024 09:50:27 +0000 (11:50 +0200)
* Ensure expiresAt is usable

Signed-off-by: Gaël L'hopital <gael@lhopital.org>
bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/api/dto/HomeEvent.java

index 58b3607a0c455026beb14c40a7dd4eb895629046..0ec894b7569093adae61f8b43130205d5c016a13 100644 (file)
@@ -37,10 +37,15 @@ public class HomeEvent extends Event {
     public class NAEventsDataResponse extends ApiResponse<BodyResponse<Home>> {
     }
 
-    private record Snapshot(String url, ZonedDateTime expiresAt) {
-        // If the snapshot is expired we consider it as not available, so do not provide the url
+    private record Snapshot(@Nullable String url, @Nullable ZonedDateTime expiresAt) {
         public @Nullable String url() {
-            return expiresAt.isAfter(ZonedDateTime.now().withZoneSameInstant(expiresAt.getZone())) ? url : null;
+            ZonedDateTime expires = expiresAt;
+            // If no expiration data provided, lets consider it is available
+            if (expires == null) {
+                return url;
+            }
+            // If the snapshot is expired we consider it as not available, so do not provide the url
+            return expires.isAfter(ZonedDateTime.now().withZoneSameInstant(expires.getZone())) ? url : null;
         }
     }