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 10d3ea86723..d6512d02729 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 @@ -1245,7 +1245,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) {