From 44aa427f90f0c0afca81893b23bc7eabcb43fcd5 Mon Sep 17 00:00:00 2001 From: Mark Herwege Date: Fri, 3 May 2024 15:49:23 +0200 Subject: [PATCH] re-add deprecated evolutionRate variant Signed-off-by: Mark Herwege --- .../extensions/PersistenceExtensions.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) 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 f29ffcf862b..8fd045c6722 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 @@ -1726,6 +1726,26 @@ private static void internalPersist(Item item, TimeSeries timeSeries, String ser return internalEvolutionRateBetween(item, null, timestamp); } + /** + * Gets the evolution rate of the state of a given {@link Item} between two points in time. + * The default {@link PersistenceService} is used. + * + * @param item the item to get the evolution rate value for + * @param begin the beginning point in time + * @param end the end point in time + * @return the evolution rate in percent (positive and negative) in the given interval, or null if + * there is no default persistence service available, the default persistence service is not a + * {@link QueryablePersistenceService}, or if there are no persisted state for the given item + * at the given interval, or if there is a state but it is zero (which would cause a + * divide-by-zero error) + */ + @Deprecated + public static @Nullable DecimalType evolutionRate(Item item, ZonedDateTime begin, ZonedDateTime end) { + LoggerFactory.getLogger(PersistenceExtensions.class).info( + "The evolutionRate method has been deprecated and will be removed in a future version, use evolutionRateBetween instead."); + return internalEvolutionRateBetween(item, begin, end); + } + /** * Gets the evolution rate of the state of a given {@link Item} between two points in time. * The default {@link PersistenceService} is used. @@ -1803,6 +1823,29 @@ private static void internalPersist(Item item, TimeSeries timeSeries, String ser return internalEvolutionRateBetween(item, null, timestamp, serviceId); } + /** + * Gets the evolution rate of the state of a given {@link Item} between two points in time. + * The {@link PersistenceService} identified by the serviceId is used. + * + * @param item the {@link Item} to get the evolution rate value for + * @param begin the beginning point in time + * @param end the end point in time + * @param serviceId the name of the {@link PersistenceService} to use + * @return the evolution rate in percent (positive and negative) in the given interval, or null if + * the persistence service given by serviceId is not available or is not a + * {@link QueryablePersistenceService}, or if there is no persisted state for the given + * item at the given begin and end using the persistence service + * given by serviceId, or if there is a state but it is zero (which would cause a + * divide-by-zero error) + */ + @Deprecated + public static @Nullable DecimalType evolutionRate(Item item, ZonedDateTime begin, ZonedDateTime end, + String serviceId) { + LoggerFactory.getLogger(PersistenceExtensions.class).info( + "The evolutionRate method has been deprecated and will be removed in a future version, use evolutionRateBetween instead."); + return internalEvolutionRateBetween(item, begin, end, serviceId); + } + /** * Gets the evolution rate of the state of a given {@link Item} between two points in time. * The {@link PersistenceService} identified by the serviceId is used.