From ded23f4ac7c54bdb45b65b80f757fe2973e673cc Mon Sep 17 00:00:00 2001 From: Michael Weger Date: Mon, 14 Jul 2025 17:36:14 +0200 Subject: [PATCH] increased buffer to 3min fixed error with assignment to local instead of global variable Signed-off-by: Michael Weger --- bundles/org.openhab.binding.ondilo/README.md | 2 +- .../org/openhab/binding/ondilo/internal/OndiloBridge.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bundles/org.openhab.binding.ondilo/README.md b/bundles/org.openhab.binding.ondilo/README.md index 85d3001cd8797..4b5a033b49f4c 100644 --- a/bundles/org.openhab.binding.ondilo/README.md +++ b/bundles/org.openhab.binding.ondilo/README.md @@ -28,7 +28,7 @@ Each Ondilo ICO will appear as a new Thing in the inbox. Ondilo ICO takes measures every hour. Higher polling will not increase the update interval. -The binding automatically adjusts the polling schedule to match the expected time of the next measure, which is typically 1 hour (plus 1.5 minutes buffer) after the previous measure. +The binding automatically adjusts the polling schedule to match the expected time of the next measure, which is typically 1 hour (plus 3 minutes buffer) after the previous measure. The requests to the Ondilo Customer API are limited to the following per user quotas: diff --git a/bundles/org.openhab.binding.ondilo/src/main/java/org/openhab/binding/ondilo/internal/OndiloBridge.java b/bundles/org.openhab.binding.ondilo/src/main/java/org/openhab/binding/ondilo/internal/OndiloBridge.java index d1418bf8b73c6..53149d7796550 100644 --- a/bundles/org.openhab.binding.ondilo/src/main/java/org/openhab/binding/ondilo/internal/OndiloBridge.java +++ b/bundles/org.openhab.binding.ondilo/src/main/java/org/openhab/binding/ondilo/internal/OndiloBridge.java @@ -134,11 +134,11 @@ public synchronized void pollOndiloICOs() { private void adaptPollingToValueTime(Instant lastValueTime, int refreshInterval) { // Measures are taken every 60 minutes, so we should be able to - // retrieve next data directly 60 minutes + buffer of 90 seconds after the last measure. + // retrieve next data directly 60 minutes + buffer of 3 minutes after the last measure. // This can help to avoid polling too frequently and hitting API rate limits. - // If the last measure was taken at 12:00°°, we will poll again at 13:01³°. + // If the last measure was taken at 12:00, we will poll again at 13:03. // This allows for a buffer in case the measure is not available immediately. - Instant nextValueTime = lastValueTime.plusSeconds(3690); // 60 minutes + 1 minute + 30 seconds buffer + Instant nextValueTime = lastValueTime.plusSeconds(3780); // 60 minutes + 3 minutes Instant now = Instant.now(); Instant scheduledTime = now.plusSeconds(refreshInterval); if (nextValueTime.isBefore(scheduledTime)) { @@ -148,7 +148,7 @@ private void adaptPollingToValueTime(Instant lastValueTime, int refreshInterval) if (ondiloBridgePollingJob != null) { ondiloBridgePollingJob.cancel(true); } - ondiloBridgePollingJob = scheduler.scheduleWithFixedDelay(() -> pollOndiloICOs(), delay, + this.ondiloBridgePollingJob = scheduler.scheduleWithFixedDelay(() -> pollOndiloICOs(), delay, refreshInterval, TimeUnit.SECONDS); logger.trace("Rescheduled polling to {} (delay {} seconds)", nextValueTime, delay); }