From 6f09e7e90844166bc6b1ceade594c9983a0fc553 Mon Sep 17 00:00:00 2001 From: Arne Seime Date: Tue, 26 Nov 2024 22:23:31 +0100 Subject: [PATCH] Added some random delays to avoid cloudfront rate limiting --- .../handler/PanasonicComfortCloudAccountHandler.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/no/seime/openhab/binding/panasoniccomfortcloud/internal/handler/PanasonicComfortCloudAccountHandler.java b/src/main/java/no/seime/openhab/binding/panasoniccomfortcloud/internal/handler/PanasonicComfortCloudAccountHandler.java index b1bb880..e91eb0d 100644 --- a/src/main/java/no/seime/openhab/binding/panasoniccomfortcloud/internal/handler/PanasonicComfortCloudAccountHandler.java +++ b/src/main/java/no/seime/openhab/binding/panasoniccomfortcloud/internal/handler/PanasonicComfortCloudAccountHandler.java @@ -17,6 +17,7 @@ import java.util.Random; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import org.apache.commons.lang3.StringUtils; @@ -151,14 +152,14 @@ public synchronized void doPoll(boolean triggerDeviceUpdate) { updateStatus(ThingStatus.ONLINE); if (triggerDeviceUpdate) { - AtomicLong delayIncrementer = new AtomicLong(1000); + AtomicInteger delayIncrementer = new AtomicInteger(1000); try { getThing().getThings().stream() .filter(e -> e.isEnabled() && (e.getStatus() == ThingStatus.ONLINE || e.getStatus() == ThingStatus.OFFLINE)) .forEach(e -> { - long delay = delayIncrementer.addAndGet(random.nextLong(3000l)); + int delay = delayIncrementer.addAndGet(random.nextInt(3000)); try { scheduler.schedule(() -> ((PanasonicComfortCloudBaseThingHandler) e.getHandler()) .loadFromServer(), delay, TimeUnit.MILLISECONDS);