Class PersistenceExtensions


  • public class PersistenceExtensions
    extends Object
    This class provides static methods that can be used in automation rules for using persistence services
    Author:
    Kai Kreuzer - Initial contribution, Thomas Eichstaedt-Engelen - Initial contribution, Chris Jackson - Initial contribution, Gaƫl L'hopital - Add deltaSince, lastUpdate, evolutionRate, Jan N. Klug - Added sumSince, John Cocula - Added sumSince, Jan N. Klug - Added interval methods and refactoring
    • Method Detail

      • persist

        public static void persist​(Item item,
                                   String serviceId)
        Persists the state of a given item through a PersistenceService identified by the serviceId.
        Parameters:
        item - the item to store
        serviceId - the name of the PersistenceService to use
      • persist

        public static void persist​(Item item)
        Persists the state of a given item through the default persistence service.
        Parameters:
        item - the item to store
      • historicState

        public static @Nullable HistoricItem historicState​(Item item,
                                                           ZonedDateTime timestamp)
        Retrieves the historic item for a given item at a certain point in time through the default persistence service.
        Parameters:
        item - the item for which to retrieve the historic item
        timestamp - the point in time for which the historic item should be retrieved
        Returns:
        the historic item at the given point in time, or null if no historic item could be found, the default persistence service is not available or does not refer to a QueryablePersistenceService
      • historicState

        public static @Nullable HistoricItem historicState​(Item item,
                                                           ZonedDateTime timestamp,
                                                           String serviceId)
        Retrieves the historic item for a given item at a certain point in time through a PersistenceService identified by the serviceId.
        Parameters:
        item - the item for which to retrieve the historic item
        timestamp - the point in time for which the historic item should be retrieved
        serviceId - the name of the PersistenceService to use
        Returns:
        the historic item at the given point in time, or null if no historic item could be found or if the provided serviceId does not refer to an available QueryablePersistenceService
      • lastUpdate

        public static @Nullable ZonedDateTime lastUpdate​(Item item)
        Query the last update time of a given item. The default persistence service is used.
        Parameters:
        item - the item for which the last update time is to be returned
        Returns:
        point in time of the last update to item, or null if there are no previously persisted updates or the default persistence service is not available or a QueryablePersistenceService
      • lastUpdate

        public static @Nullable ZonedDateTime lastUpdate​(Item item,
                                                         String serviceId)
        Query for the last update time of a given item.
        Parameters:
        item - the item for which the last update time is to be returned
        serviceId - the name of the PersistenceService to use
        Returns:
        last time item was updated, or null if there are no previously persisted updates or if persistence service given by serviceId does not refer to an available QueryablePersistenceService
      • previousState

        public static @Nullable HistoricItem previousState​(Item item)
        Returns the previous state of a given item.
        Parameters:
        item - the item to get the previous state value for
        Returns:
        the previous state or null if no previous state could be found, or if the default persistence service is not configured or does not refer to a QueryablePersistenceService
      • previousState

        public static @Nullable HistoricItem previousState​(Item item,
                                                           boolean skipEqual)
        Returns the previous state of a given item.
        Parameters:
        item - the item to get the previous state value for
        skipEqual - if true, skips equal state values and searches the first state not equal the current state
        Returns:
        the previous state or null if no previous state could be found, or if the default persistence service is not configured or does not refer to a QueryablePersistenceService
      • previousState

        public static @Nullable HistoricItem previousState​(Item item,
                                                           boolean skipEqual,
                                                           String serviceId)
        Returns the previous state of a given item. The PersistenceService identified by the serviceId is used.
        Parameters:
        item - the item to get the previous state value for
        skipEqual - if true, skips equal state values and searches the first state not equal the current state
        serviceId - the name of the PersistenceService to use
        Returns:
        the previous state or null if no previous state could be found, or if the given serviceId is not available or does not refer to a QueryablePersistenceService
      • changedSince

        public static boolean changedSince​(Item item,
                                           ZonedDateTime timestamp)
        Checks if the state of a given item has changed since a certain point in time. The default persistence service is used.
        Parameters:
        item - the item to check for state changes
        timestamp - the point in time to start the check
        Returns:
        true if item state has changed, false if it has not changed or if the default persistence service is not available or does not refer to a QueryablePersistenceService
      • changedBetween

        public static boolean changedBetween​(Item item,
                                             ZonedDateTime begin,
                                             ZonedDateTime end)
        Checks if the state of a given item has changed between two points in time. The default persistence service is used.
        Parameters:
        item - the item to check for state changes
        Returns:
        true if item state changed, false if either item has not been changed in the given interval or if the default persistence does not refer to a QueryablePersistenceService, or null if the default persistence service is not available
      • changedSince

        public static boolean changedSince​(Item item,
                                           ZonedDateTime timestamp,
                                           String serviceId)
        Checks if the state of a given item has changed since a certain point in time. The PersistenceService identified by the serviceId is used.
        Parameters:
        item - the item to check for state changes
        timestamp - the point in time to start the check
        serviceId - the name of the PersistenceService to use
        Returns:
        true if item state has changed, or false if it has not changed or if the provided serviceId does not refer to an available QueryablePersistenceService
      • changedBetween

        public static boolean changedBetween​(Item item,
                                             ZonedDateTime begin,
                                             ZonedDateTime end,
                                             String serviceId)
        Checks if the state of a given item changed between two points in time. The PersistenceService identified by the serviceId is used.
        Parameters:
        item - the item to check for state changes
        begin - the point in time to start the check
        end - the point in time to stop the check
        serviceId - the name of the PersistenceService to use
        Returns:
        true if item state changed or false if either the item has not changed in the given interval or if the given serviceId does not refer to a QueryablePersistenceService
      • updatedSince

        public static boolean updatedSince​(Item item,
                                           ZonedDateTime timestamp)
        Checks if the state of a given item has been updated since a certain point in time. The default persistence service is used.
        Parameters:
        item - the item to check for state updates
        timestamp - the point in time to start the check
        Returns:
        true if item state was updated, false if either item has not been updated since timestamp or if the default persistence does not refer to a QueryablePersistenceService, or null if the default persistence service is not available
      • updatedBetween

        public static boolean updatedBetween​(Item item,
                                             ZonedDateTime begin,
                                             ZonedDateTime end)
        Checks if the state of a given item has been updated between two points in time. The default persistence service is used.
        Parameters:
        item - the item to check for state updates
        begin - the point in time to start the check
        end - the point in time to stop the check
        Returns:
        true if item state was updated, false if either item has not been updated in the given interval or if the default persistence does not refer to a QueryablePersistenceService, or null if the default persistence service is not available
      • updatedSince

        public static boolean updatedSince​(Item item,
                                           ZonedDateTime timestamp,
                                           String serviceId)
        Checks if the state of a given item has been updated since a certain point in time. The PersistenceService identified by the serviceId is used.
        Parameters:
        item - the item to check for state changes
        timestamp - the point in time to start the check
        serviceId - the name of the PersistenceService to use
        Returns:
        true if item state was updated or false if either the item has not been updated since timestamp or if the given serviceId does not refer to a QueryablePersistenceService
      • updatedBetween

        public static boolean updatedBetween​(Item item,
                                             ZonedDateTime begin,
                                             ZonedDateTime end,
                                             String serviceId)
        Checks if the state of a given item has been updated between two points in time. The PersistenceService identified by the serviceId is used.
        Parameters:
        item - the item to check for state changes
        begin - the point in time to start the check
        end - the point in time to stop the check
        serviceId - the name of the PersistenceService to use
        Returns:
        true if item state was updated or false if either the item has not been updated in the given interval or if the given serviceId does not refer to a QueryablePersistenceService
      • maximumSince

        public static @Nullable HistoricItem maximumSince​(Item item,
                                                          ZonedDateTime timestamp)
        Gets the historic item with the maximum value of the state of a given item since a certain point in time. The default persistence service is used.
        Parameters:
        item - the item to get the maximum state value for
        timestamp - the point in time to start the check
        Returns:
        a historic item with the maximum state value since the given point in time, or a HistoricItem constructed from the item if the default persistence service does not refer to a QueryablePersistenceService
      • maximumBetween

        public static @Nullable HistoricItem maximumBetween​(Item item,
                                                            ZonedDateTime begin,
                                                            ZonedDateTime end)
        Gets the historic item with the maximum value of the state of a given item since a certain point in time. The default persistence service is used.
        Parameters:
        item - the item to get the maximum state value for
        begin - the point in time to start the check
        end - the point in time to stop the check
        Returns:
        a HistoricItem with the maximum state value since the given point in time, or null if no states found or if the default persistence service does not refer to an available QueryablePersistenceService
      • maximumSince

        public static @Nullable HistoricItem maximumSince​(Item item,
                                                          ZonedDateTime timestamp,
                                                          String serviceId)
        Gets the historic item with the maximum value of the state of a given item since a certain point in time. The PersistenceService identified by the serviceId is used.
        Parameters:
        item - the item to get the maximum state value for
        timestamp - the point in time to start the check
        serviceId - the name of the PersistenceService to use
        Returns:
        a HistoricItem with the maximum state value since the given point in time, or a HistoricItem constructed from the item's state if item's state is the maximum value or if the given serviceId does not refer to an available QueryablePersistenceService
      • maximumBetween

        public static @Nullable HistoricItem maximumBetween​(Item item,
                                                            ZonedDateTime begin,
                                                            ZonedDateTime end,
                                                            String serviceId)
        Gets the historic item with the maximum value of the state of a given item since a certain point in time. The PersistenceService identified by the serviceId is used.
        Parameters:
        item - the item to get the maximum state value for
        begin - the point in time to start the check
        end - the point in time to stop the check
        serviceId - the name of the PersistenceService to use
        Returns:
        a HistoricItem with the maximum state value since the given point in time, or null no states found or if the given serviceId does not refer to an available QueryablePersistenceService
      • minimumSince

        public static @Nullable HistoricItem minimumSince​(Item item,
                                                          ZonedDateTime timestamp)
        Gets the historic item with the minimum value of the state of a given item since a certain point in time. The default persistence service is used.
        Parameters:
        item - the item to get the minimum state value for
        timestamp - the point in time from which to search for the minimum state value
        Returns:
        the historic item with the minimum state value since the given point in time or a HistoricItem constructed from the item's state if item's state is the minimum value or if the default persistence service does not refer to an available QueryablePersistenceService
      • minimumBetween

        public static @Nullable HistoricItem minimumBetween​(Item item,
                                                            ZonedDateTime begin,
                                                            ZonedDateTime end)
        Gets the historic item with the minimum value of the state of a given item between two certain points in time. The default persistence service is used.
        Parameters:
        item - the item to get the minimum state value for
        begin - the beginning point in time
        end - the end point in time to
        Returns:
        the historic item with the minimum state value between the given points in time, or null if not state was found or if the default persistence service does not refer to an available QueryablePersistenceService
      • minimumSince

        public static @Nullable HistoricItem minimumSince​(Item item,
                                                          ZonedDateTime timestamp,
                                                          String serviceId)
        Gets the historic item with the minimum value of the state of a given item since a certain point in time. The PersistenceService identified by the serviceId is used.
        Parameters:
        item - the item to get the minimum state value for
        timestamp - the point in time from which to search for the minimum state value
        serviceId - the name of the PersistenceService to use
        Returns:
        the historic item with the minimum state value since the given point in time, or a HistoricItem constructed from the item's state if item's state is the minimum value or if the given serviceId does not refer to an available QueryablePersistenceService.
      • minimumBetween

        public static @Nullable HistoricItem minimumBetween​(Item item,
                                                            ZonedDateTime begin,
                                                            ZonedDateTime end,
                                                            String serviceId)
        Gets the historic item with the minimum value of the state of a given item between two certain points in time. The PersistenceService identified by the serviceId is used.
        Parameters:
        item - the item to get the minimum state value for
        begin - the beginning point in time
        end - the end point in time to
        serviceId - the name of the PersistenceService to use
        Returns:
        the historic item with the minimum state value between the given points in time, or null if not state was found or if the given serviceId does not refer to an available QueryablePersistenceService
      • varianceSince

        public static @Nullable DecimalType varianceSince​(Item item,
                                                          ZonedDateTime timestamp)
        Gets the variance of the state of the given Item since a certain point in time. The default PersistenceService is used.
        Parameters:
        item - the Item to get the variance for
        timestamp - the point in time from which to compute the variance
        Returns:
        the variance between now and then, or null if there is no default persistence service available, or it is not a QueryablePersistenceService, or if there is no persisted state for the given item at the given timestamp
      • varianceBetween

        public static @Nullable DecimalType varianceBetween​(Item item,
                                                            ZonedDateTime begin,
                                                            ZonedDateTime end)
        Gets the variance of the state of the given Item between two certain point in time. The default PersistenceService is used.
        Parameters:
        item - the Item to get the variance for
        begin - the point in time from which to compute the variance
        end - the end time for the computation
        Returns:
        the variance between both points of time, or null if there is no default persistence service available, or it is not a QueryablePersistenceService, or if there is no persisted state for the given item at the given timestamp
      • varianceSince

        public static @Nullable DecimalType varianceSince​(Item item,
                                                          ZonedDateTime timestamp,
                                                          String serviceId)
        Gets the variance of the state of the given Item since a certain point in time. The PersistenceService identified by the serviceId is used.
        Parameters:
        item - the Item to get the variance for
        timestamp - the point in time from which to compute the variance
        serviceId - the name of the PersistenceService to use
        Returns:
        the variance between now and then, or null if the persistence service given by serviceId is not available, or it is not a QueryablePersistenceService, or if there is no persisted state for the given item at the given timestamp
      • varianceBetween

        public static @Nullable DecimalType varianceBetween​(Item item,
                                                            ZonedDateTime begin,
                                                            ZonedDateTime end,
                                                            String serviceId)
        Gets the variance of the state of the given Item between two points in time. The PersistenceService identified by the serviceId is used.
        Parameters:
        item - the Item to get the variance for
        begin - the point in time from which to compute
        end - the end time for the computation
        serviceId - the name of the PersistenceService to use
        Returns:
        the variance between the given points in time, or null if the persistence service given by serviceId is not available, or it is not a QueryablePersistenceService, or if there is no persisted state for the given item at the given timestamp
      • deviationSince

        public static @Nullable DecimalType deviationSince​(Item item,
                                                           ZonedDateTime timestamp)
        Gets the standard deviation of the state of the given Item since a certain point in time. The default PersistenceService is used. Note: If you need variance and standard deviation at the same time do not query both as it is a costly operation. Get the variance only, it is the squared deviation.
        Parameters:
        item - the Item to get the standard deviation for
        timestamp - the point in time from which to compute the standard deviation
        Returns:
        the standard deviation between now and then, or null if there is no default persistence service available, or it is not a QueryablePersistenceService, or if there is no persisted state for the given item at the given timestamp
      • deviationBetween

        public static @Nullable DecimalType deviationBetween​(Item item,
                                                             ZonedDateTime begin,
                                                             ZonedDateTime end)
        Gets the standard deviation of the state of the given Item between two points in time. The default PersistenceService is used. Note: If you need variance and standard deviation at the same time do not query both as it is a costly operation. Get the variance only, it is the squared deviation.
        Parameters:
        item - the Item to get the standard deviation for
        begin - the point in time from which to compute
        end - the end time for the computation
        Returns:
        the standard deviation between now and then, or null if there is no default persistence service available, or it is not a QueryablePersistenceService, or if there is no persisted state for the given item in the given interval
      • deviationSince

        public static @Nullable DecimalType deviationSince​(Item item,
                                                           ZonedDateTime timestamp,
                                                           String serviceId)
        Gets the standard deviation of the state of the given Item since a certain point in time. The PersistenceService identified by the serviceId is used. Note: If you need variance and standard deviation at the same time do not query both as it is a costly operation. Get the variance only, it is the squared deviation.
        Parameters:
        item - the Item to get the standard deviation for
        timestamp - the point in time from which to compute the standard deviation
        serviceId - the name of the PersistenceService to use
        Returns:
        the standard deviation between now and then, or null if the persistence service given by serviceId it is not available or is not a QueryablePersistenceService, or if there is no persisted state for the given item at the given timestamp
      • deviationBetween

        public static @Nullable DecimalType deviationBetween​(Item item,
                                                             ZonedDateTime begin,
                                                             ZonedDateTime end,
                                                             String serviceId)
        Gets the standard deviation of the state of the given Item between two points in time. The PersistenceService identified by the serviceId is used. Note: If you need variance and standard deviation at the same time do not query both as it is a costly operation. Get the variance only, it is the squared deviation.
        Parameters:
        item - the Item to get the standard deviation for
        begin - the point in time from which to compute
        end - the end time for the computation
        serviceId - the name of the PersistenceService to use
        Returns:
        the standard deviation between now and then, or null if the persistence service given by serviceId it is not available or is not a QueryablePersistenceService, or if there is no persisted state for the given item in the given interval
      • averageSince

        public static @Nullable DecimalType averageSince​(Item item,
                                                         ZonedDateTime timestamp)
        Gets the average value of the state of a given Item since a certain point in time. The default PersistenceService is used.
        Parameters:
        item - the Item to get the average value for
        timestamp - the point in time from which to search for the average value
        Returns:
        the average value since timestamp or null if no previous states could be found or if the default persistence service does not refer to an available QueryablePersistenceService. The current state is included in the calculation.
      • averageBetween

        public static @Nullable DecimalType averageBetween​(Item item,
                                                           ZonedDateTime begin,
                                                           ZonedDateTime end)
        Gets the average value of the state of a given Item between two certain points in time. The default PersistenceService is used.
        Parameters:
        item - the Item to get the average value for
        begin - the point in time from which to start the summation
        end - the point in time to which to start the summation
        Returns:
        the average value since timestamp or null if no previous states could be found or if the default persistence service does not refer to an available QueryablePersistenceService.
      • averageSince

        public static @Nullable DecimalType averageSince​(Item item,
                                                         ZonedDateTime timestamp,
                                                         String serviceId)
        Gets the average value of the state of a given Item since a certain point in time. The PersistenceService identified by the serviceId is used.
        Parameters:
        item - the Item to get the average value for
        timestamp - the point in time from which to search for the average value
        serviceId - the name of the PersistenceService to use
        Returns:
        the average value since timestamp, or null if no previous states could be found or if the persistence service given by serviceId does not refer to an available QueryablePersistenceService. The current state is included in the calculation.
      • averageBetween

        public static @Nullable DecimalType averageBetween​(Item item,
                                                           ZonedDateTime begin,
                                                           ZonedDateTime end,
                                                           String serviceId)
        Gets the average value of the state of a given Item between two certain points in time. The PersistenceService identified by the serviceId is used.
        Parameters:
        item - the Item to get the average value for
        begin - the point in time from which to start the summation
        end - the point in time to which to start the summation
        serviceId - the name of the PersistenceService to use
        Returns:
        the average value since timestamp, or null if no previous states could be found or if the persistence service given by serviceId does not refer to an available QueryablePersistenceService
      • sumSince

        public static DecimalType sumSince​(Item item,
                                           ZonedDateTime timestamp)
        Gets the sum of the state of a given item since a certain point in time. The default persistence service is used.
        Parameters:
        item - the item for which we will sum its persisted state values since timestamp
        timestamp - the point in time from which to start the summation
        Returns:
        the sum of the state values since timestamp, or DecimalType.ZERO if no historic states could be found or if the default persistence service does not refer to a QueryablePersistenceService
      • sumBetween

        public static DecimalType sumBetween​(Item item,
                                             ZonedDateTime begin,
                                             ZonedDateTime end)
        Gets the sum of the state of a given item between two certain points in time. The default persistence service is used.
        Parameters:
        item - the item for which we will sum its persisted state values between begin and end
        begin - the point in time from which to start the summation
        end - the point in time to which to start the summation
        Returns:
        the sum of the state values between the given points in time, or DecimalType.ZERO if no historic states could be found or if the default persistence service does not refer to a QueryablePersistenceService
      • sumSince

        public static DecimalType sumSince​(Item item,
                                           ZonedDateTime timestamp,
                                           String serviceId)
        Gets the sum of the state of a given item since a certain point in time. The PersistenceService identified by the serviceId is used.
        Parameters:
        item - the item for which we will sum its persisted state values since timestamp
        timestamp - the point in time from which to start the summation
        serviceId - the name of the PersistenceService to use
        Returns:
        the sum of the state values since the given point in time, or DecimalType.ZERO if no historic states could be found for the item or if serviceId does not refer to a QueryablePersistenceService
      • sumBetween

        public static DecimalType sumBetween​(Item item,
                                             ZonedDateTime begin,
                                             ZonedDateTime end,
                                             String serviceId)
        Gets the sum of the state of a given item between two certain points in time. The PersistenceService identified by the serviceId is used.
        Parameters:
        item - the item for which we will sum its persisted state values between begin and end
        begin - the point in time from which to start the summation
        end - the point in time to which to start the summation
        serviceId - the name of the PersistenceService to use
        Returns:
        the sum of the state values between the given points in time, or DecimalType.ZERO if no historic states could be found for the item or if serviceId does not refer to a QueryablePersistenceService
      • deltaSince

        public static @Nullable DecimalType deltaSince​(Item item,
                                                       ZonedDateTime timestamp)
        Gets the difference value of the state of a given item since a certain point in time. The default persistence service is used.
        Parameters:
        item - the item to get the average state value for
        timestamp - the point in time from which to compute the delta
        Returns:
        the difference between now and then, or null if there is no default persistence service available, the default persistence service is not a QueryablePersistenceService, or if there is no persisted state for the given item at the given timestamp available in the default persistence service
      • deltaBetween

        public static @Nullable DecimalType deltaBetween​(Item item,
                                                         ZonedDateTime begin,
                                                         ZonedDateTime end)
        Gets the difference value of the state of a given item between two certain point in time. The default persistence service is used.
        Parameters:
        item - the item to get the delta for
        begin - the beginning point in time
        end - the end point in time
        Returns:
        the difference between end and begin, or null if the default persistence service does not refer to an available QueryablePersistenceService, or if there is no persisted state for the given item for the given points in time
      • deltaSince

        public static @Nullable DecimalType deltaSince​(Item item,
                                                       ZonedDateTime timestamp,
                                                       String serviceId)
        Gets the difference value of the state of a given item since a certain point in time. The PersistenceService identified by the serviceId is used.
        Parameters:
        item - the item to get the delta for
        timestamp - the point in time from which to compute the delta
        serviceId - the name of the PersistenceService to use
        Returns:
        the difference between now and then, or null if the given serviceId does not refer to an available QueryablePersistenceService, or if there is no persisted state for the given item at the given timestamp using the persistence service named serviceId
      • deltaBetween

        public static @Nullable DecimalType deltaBetween​(Item item,
                                                         ZonedDateTime begin,
                                                         ZonedDateTime end,
                                                         String serviceId)
        Gets the difference value of the state of a given item between two certain point in time. The PersistenceService identified by the serviceId is used.
        Parameters:
        item - the item to get the delta for
        begin - the beginning point in time
        end - the end point in time
        serviceId - the name of the PersistenceService to use
        Returns:
        the difference between end and begin, or null if the given serviceId does not refer to an available QueryablePersistenceService, or if there is no persisted state for the given item at the given points in time
      • evolutionRate

        public static DecimalType evolutionRate​(Item item,
                                                ZonedDateTime timestamp)
        Gets the evolution rate of the state of a given Item since a certain point in time. The default PersistenceService is used.
        Parameters:
        item - the item to get the evolution rate value for
        timestamp - the point in time from which to compute the evolution rate
        Returns:
        the evolution rate in percent (positive and negative) between now and then, or null if there is no default persistence service available, the default persistence service is not a QueryablePersistenceService, or if there is no persisted state for the given item at the given timestamp, or if there is a state but it is zero (which would cause a divide-by-zero error)
      • evolutionRate

        public static DecimalType evolutionRate​(Item item,
                                                ZonedDateTime begin,
                                                ZonedDateTime end)
        Gets the evolution rate of the state of a given Item between two points in time. The default PersistenceService is used.
        Parameters:
        item - the item to get the evolution rate value for
        begin - the beginning point in time
        end - the end point in time
        Returns:
        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 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)
      • evolutionRate

        public static @Nullable DecimalType evolutionRate​(Item item,
                                                          ZonedDateTime timestamp,
                                                          String serviceId)
        Gets the evolution rate of the state of a given Item since a certain point in time. The PersistenceService identified by the serviceId is used.
        Parameters:
        item - the Item to get the evolution rate value for
        timestamp - the point in time from which to compute the evolution rate
        serviceId - the name of the PersistenceService to use
        Returns:
        the evolution rate in percent (positive and negative) between now and then, or null if the persistence service given by serviceId is not available or is not a QueryablePersistenceService, or if there is no persisted state for the given item at the given timestamp 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)
      • evolutionRate

        public static @Nullable DecimalType evolutionRate​(Item item,
                                                          ZonedDateTime begin,
                                                          ZonedDateTime end,
                                                          String serviceId)
        Gets the evolution rate of the state of a given Item between two points in time. The PersistenceService identified by the serviceId is used.
        Parameters:
        item - the Item to get the evolution rate value for
        begin - the beginning point in time
        end - the end point in time
        serviceId - the name of the PersistenceService to use
        Returns:
        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 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)