diff --git a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/extensions/PersistenceExtensions.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/extensions/PersistenceExtensions.java index 478587314f4..a1d536c1d47 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/extensions/PersistenceExtensions.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/extensions/PersistenceExtensions.java @@ -1230,7 +1230,62 @@ public static long countStateChangesBetween(Item item, ZonedDateTime begin, @Nul return null; } - private static Iterable getAllStatesBetween(Item item, ZonedDateTime begin, + /** + * Retrieves the historic items for a given item since a certain point in time. + * The default persistence service is used. + * + * @param item the item for which to retrieve the historic item + * @param timestamp the point in time from which to retrieve the states + * @return the historic items since the given point in time, or null if no historic items could be + * found. + */ + public static Iterable getAllStatesSince(Item item, ZonedDateTime timestamp) { + return getAllStatesBetween(item, timestamp, null); + } + + /** + * Retrieves the historic items for a given item since a certain point in time + * through a {@link PersistenceService} identified by the serviceId. + * + * @param item the item for which to retrieve the historic item + * @param timestamp the point in time from which to retrieve the states + * @param serviceId the name of the {@link PersistenceService} to use + * @return the historic items since the given point in time, or null if no historic items could be + * found or if the provided serviceId does not refer to an available + * {@link QueryablePersistenceService} + */ + public static Iterable getAllStatesSince(Item item, ZonedDateTime timestamp, String serviceId) { + return getAllStatesBetween(item, timestamp, null, serviceId); + } + + /** + * Retrieves the historic items for a given item beetween two certain points in time. + * The default persistence service is used. + * + * @param item the item for which to retrieve the historic item + * @param begin the point in time from which to retrieve the states + * @param end the point in time to which to retrieve the states + * @return the historic items between the given points in time, or null if no historic items could be + * found. + */ + public static Iterable getAllStatesBetween(Item item, ZonedDateTime begin, + @Nullable ZonedDateTime end) { + return getAllStatesBetween(item, begin, end, getDefaultServiceId()); + } + + /** + * Retrieves the historic items for a given item beetween two certain points in time + * through a {@link PersistenceService} identified by the serviceId. + * + * @param item the item for which to retrieve the historic item + * @param begin the point in time from which to retrieve the states + * @param end the point in time to which to retrieve the states + * @param serviceId the name of the {@link PersistenceService} to use + * @return the historic items between the given points in time, or null if no historic items could be + * found or if the provided serviceId does not refer to an available + * {@link QueryablePersistenceService} + */ + public static Iterable getAllStatesBetween(Item item, ZonedDateTime begin, @Nullable ZonedDateTime end, String serviceId) { PersistenceService service = getService(serviceId); if (service instanceof QueryablePersistenceService qService) {