mirror of
https://github.com/danieldemus/openhab-addons
synced 2026-07-29 12:34:21 +02:00
Use cache for event update requests (#20287)
Signed-off-by: gael@lhopital.org <gael@lhopital.org>
This commit is contained in:
+1
-1
@@ -32,7 +32,7 @@ import org.openhab.binding.netatmo.internal.servlet.WebhookServlet;
|
||||
*
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class HomeSecurityThingCapability extends Capability {
|
||||
public abstract class HomeSecurityThingCapability extends Capability {
|
||||
protected final NetatmoDescriptionProvider descriptionProvider;
|
||||
protected final EventChannelHelper eventHelper;
|
||||
|
||||
|
||||
+5
-5
@@ -12,6 +12,7 @@
|
||||
*/
|
||||
package org.openhab.binding.netatmo.internal.handler.capability;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
@@ -49,9 +50,8 @@ import org.slf4j.LoggerFactory;
|
||||
*
|
||||
*/
|
||||
@NonNullByDefault
|
||||
class SecurityCapability extends RestCapability<SecurityApi> {
|
||||
private static final ZonedDateTime ZDT_REFERENCE = ZonedDateTime.ofInstant(Instant.ofEpochMilli(0),
|
||||
ZoneId.systemDefault());
|
||||
class SecurityCapability extends CacheCapability<SecurityApi> {
|
||||
private static final ZonedDateTime ZDT_REFERENCE = Instant.ofEpochMilli(0).atZone(ZoneId.systemDefault());
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(SecurityCapability.class);
|
||||
private final Map<String, HomeEvent> eventBuffer = new HashMap<>();
|
||||
@@ -62,7 +62,7 @@ class SecurityCapability extends RestCapability<SecurityApi> {
|
||||
private String securityId = "";
|
||||
|
||||
SecurityCapability(CommonInterface handler) {
|
||||
super(handler, SecurityApi.class);
|
||||
super(handler, Duration.ofSeconds(2), SecurityApi.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -120,7 +120,7 @@ class SecurityCapability extends RestCapability<SecurityApi> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<NAObject> updateReadings(SecurityApi api) {
|
||||
protected List<NAObject> getFreshData(SecurityApi api) {
|
||||
List<NAObject> result = new ArrayList<>();
|
||||
try {
|
||||
api.getHomeEvents(securityId, freshestEventTime).stream().forEach(event -> {
|
||||
|
||||
Reference in New Issue
Block a user