Class PersistenceExtensions
java.lang.Object
org.openhab.core.persistence.extensions.PersistenceExtensions
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
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable DecimalTypeaverageBetween(Item item, ZonedDateTime begin, ZonedDateTime end) Gets the average value of the state of a givenItembetween two certain points in time.static @Nullable DecimalTypeaverageBetween(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Gets the average value of the state of a givenItembetween two certain points in time.static @Nullable DecimalTypeaverageSince(Item item, ZonedDateTime timestamp) Gets the average value of the state of a givenItemsince a certain point in time.static @Nullable DecimalTypeaverageSince(Item item, ZonedDateTime timestamp, String serviceId) Gets the average value of the state of a givenItemsince a certain point in time.static booleanchangedBetween(Item item, ZonedDateTime begin, ZonedDateTime end) Checks if the state of a givenitemhas changed between two points in time.static booleanchangedBetween(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Checks if the state of a givenitemchanged between two points in time.static booleanchangedSince(Item item, ZonedDateTime timestamp) Checks if the state of a givenitemhas changed since a certain point in time.static booleanchangedSince(Item item, ZonedDateTime timestamp, String serviceId) Checks if the state of a givenitemhas changed since a certain point in time.static longcountBetween(Item item, ZonedDateTime begin, @Nullable ZonedDateTime end) Gets the number of available historic data points of a givenItembetween two points in time.static longcountBetween(Item item, ZonedDateTime begin, @Nullable ZonedDateTime end, String serviceId) Gets the number of available historic data points of a givenItembetween two points in time.static longcountSince(Item item, ZonedDateTime begin) Gets the number of available historic data points of a givenItemfrom a point in time until now.static longcountSince(Item item, ZonedDateTime begin, String serviceId) Gets the number of available historic data points of a givenItemfrom a point in time until now.static longcountStateChangesBetween(Item item, ZonedDateTime begin, @Nullable ZonedDateTime end) Gets the number of changes in historic data points of a givenItembetween two points in time.static longcountStateChangesBetween(Item item, ZonedDateTime begin, @Nullable ZonedDateTime end, String serviceId) Gets the number of changes in historic data points of a givenItembetween two points in time.static longcountStateChangesSince(Item item, ZonedDateTime begin) Gets the number of changes in historic data points of a givenItemfrom a point in time until now.static longcountStateChangesSince(Item item, ZonedDateTime begin, String serviceId) Gets the number of changes in historic data points of a givenItemfrom a point in time until now.static @Nullable DecimalTypedeltaBetween(Item item, ZonedDateTime begin, ZonedDateTime end) Gets the difference value of the state of a givenitembetween two certain point in time.static @Nullable DecimalTypedeltaBetween(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Gets the difference value of the state of a givenitembetween two certain point in time.static @Nullable DecimalTypedeltaSince(Item item, ZonedDateTime timestamp) Gets the difference value of the state of a givenitemsince a certain point in time.static @Nullable DecimalTypedeltaSince(Item item, ZonedDateTime timestamp, String serviceId) Gets the difference value of the state of a givenitemsince a certain point in time.static @Nullable DecimalTypedeviationBetween(Item item, ZonedDateTime begin, ZonedDateTime end) Gets the standard deviation of the state of the givenItembetween two points in time.static @Nullable DecimalTypedeviationBetween(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Gets the standard deviation of the state of the givenItembetween two points in time.static @Nullable DecimalTypedeviationSince(Item item, ZonedDateTime timestamp) Gets the standard deviation of the state of the givenItemsince a certain point in time.static @Nullable DecimalTypedeviationSince(Item item, ZonedDateTime timestamp, String serviceId) Gets the standard deviation of the state of the givenItemsince a certain point in time.static DecimalTypeevolutionRate(Item item, ZonedDateTime timestamp) Gets the evolution rate of the state of a givenItemsince a certain point in time.static @Nullable DecimalTypeevolutionRate(Item item, ZonedDateTime timestamp, String serviceId) Gets the evolution rate of the state of a givenItemsince a certain point in time.static DecimalTypeevolutionRate(Item item, ZonedDateTime begin, ZonedDateTime end) Gets the evolution rate of the state of a givenItembetween two points in time.static @Nullable DecimalTypeevolutionRate(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Gets the evolution rate of the state of a givenItembetween two points in time.static Iterable<HistoricItem>getAllStatesBetween(Item item, ZonedDateTime begin, @Nullable ZonedDateTime end) Retrieves the historic items for a givenitembeetween two certain points in time.static Iterable<HistoricItem>getAllStatesBetween(Item item, ZonedDateTime begin, @Nullable ZonedDateTime end, String serviceId) Retrieves the historic items for a givenitembeetween two certain points in time through aPersistenceServiceidentified by theserviceId.static Iterable<HistoricItem>getAllStatesSince(Item item, ZonedDateTime timestamp) Retrieves the historic items for a givenitemsince a certain point in time.static Iterable<HistoricItem>getAllStatesSince(Item item, ZonedDateTime timestamp, String serviceId) Retrieves the historic items for a givenitemsince a certain point in time through aPersistenceServiceidentified by theserviceId.static @Nullable HistoricItemhistoricState(Item item, ZonedDateTime timestamp) Retrieves the historic item for a givenitemat a certain point in time through the default persistence service.static @Nullable HistoricItemhistoricState(Item item, ZonedDateTime timestamp, String serviceId) Retrieves the historic item for a givenitemat a certain point in time through aPersistenceServiceidentified by theserviceId.static @Nullable ZonedDateTimelastUpdate(Item item) Query the last update time of a givenitem.static @Nullable ZonedDateTimelastUpdate(Item item, String serviceId) Query for the last update time of a givenitem.static @Nullable HistoricItemmaximumBetween(Item item, ZonedDateTime begin, ZonedDateTime end) Gets the historic item with the maximum value of the state of a givenitemsince a certain point in time.static @Nullable HistoricItemmaximumBetween(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Gets the historic item with the maximum value of the state of a givenitemsince a certain point in time.static @Nullable HistoricItemmaximumSince(Item item, ZonedDateTime timestamp) Gets the historic item with the maximum value of the state of a givenitemsince a certain point in time.static @Nullable HistoricItemmaximumSince(Item item, ZonedDateTime timestamp, String serviceId) Gets the historic item with the maximum value of the state of a givenitemsince a certain point in time.static @Nullable HistoricItemminimumBetween(Item item, ZonedDateTime begin, ZonedDateTime end) Gets the historic item with the minimum value of the state of a givenitembetween two certain points in time.static @Nullable HistoricItemminimumBetween(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Gets the historic item with the minimum value of the state of a givenitembetween two certain points in time.static @Nullable HistoricItemminimumSince(Item item, ZonedDateTime timestamp) Gets the historic item with the minimum value of the state of a givenitemsince a certain point in time.static @Nullable HistoricItemminimumSince(Item item, ZonedDateTime timestamp, String serviceId) Gets the historic item with the minimum value of the state of a givenitemsince a certain point in time.static voidPersists the state of a givenitemthrough the default persistence service.static voidstatic @Nullable HistoricItempreviousState(Item item) Returns the previous state of a givenitem.static @Nullable HistoricItempreviousState(Item item, boolean skipEqual) Returns the previous state of a givenitem.static @Nullable HistoricItempreviousState(Item item, boolean skipEqual, String serviceId) Returns the previous state of a givenitem.static DecimalTypesumBetween(Item item, ZonedDateTime begin, ZonedDateTime end) Gets the sum of the state of a givenitembetween two certain points in time.static DecimalTypesumBetween(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Gets the sum of the state of a givenitembetween two certain points in time.static DecimalTypesumSince(Item item, ZonedDateTime timestamp) Gets the sum of the state of a givenitemsince a certain point in time.static DecimalTypesumSince(Item item, ZonedDateTime timestamp, String serviceId) Gets the sum of the state of a givenitemsince a certain point in time.static booleanupdatedBetween(Item item, ZonedDateTime begin, ZonedDateTime end) Checks if the state of a givenitemhas been updated between two points in time.static booleanupdatedBetween(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Checks if the state of a givenitemhas been updated between two points in time.static booleanupdatedSince(Item item, ZonedDateTime timestamp) Checks if the state of a givenitemhas been updated since a certain point in time.static booleanupdatedSince(Item item, ZonedDateTime timestamp, String serviceId) Checks if the state of a givenitemhas been updated since a certain point in time.static @Nullable DecimalTypevarianceBetween(Item item, ZonedDateTime begin, ZonedDateTime end) Gets the variance of the state of the givenItembetween two certain point in time.static @Nullable DecimalTypevarianceBetween(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Gets the variance of the state of the givenItembetween two points in time.static @Nullable DecimalTypevarianceSince(Item item, ZonedDateTime timestamp) Gets the variance of the state of the givenItemsince a certain point in time.static @Nullable DecimalTypevarianceSince(Item item, ZonedDateTime timestamp, String serviceId) Gets the variance of the state of the givenItemsince a certain point in time.
-
Constructor Details
-
PersistenceExtensions
-
-
Method Details
-
persist
- Parameters:
item- the item to storeserviceId- the name of thePersistenceServiceto use
-
persist
Persists the state of a givenitemthrough the default persistence service.- Parameters:
item- the item to store
-
historicState
Retrieves the historic item for a givenitemat a certain point in time through the default persistence service.- Parameters:
item- the item for which to retrieve the historic itemtimestamp- the point in time for which the historic item should be retrieved- Returns:
- the historic item at the given point in time, or
nullif no historic item could be found, the default persistence service is not available or does not refer to aQueryablePersistenceService
-
historicState
public static @Nullable HistoricItem historicState(Item item, ZonedDateTime timestamp, String serviceId) Retrieves the historic item for a givenitemat a certain point in time through aPersistenceServiceidentified by theserviceId.- Parameters:
item- the item for which to retrieve the historic itemtimestamp- the point in time for which the historic item should be retrievedserviceId- the name of thePersistenceServiceto use- Returns:
- the historic item at the given point in time, or
nullif no historic item could be found or if the providedserviceIddoes not refer to an availableQueryablePersistenceService
-
lastUpdate
Query the last update time of a givenitem. 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, ornullif there are no previously persisted updates or the default persistence service is not available or aQueryablePersistenceService
-
lastUpdate
Query for the last update time of a givenitem.- Parameters:
item- the item for which the last update time is to be returnedserviceId- the name of thePersistenceServiceto use- Returns:
- last time
itemwas updated, ornullif there are no previously persisted updates or if persistence service given byserviceIddoes not refer to an availableQueryablePersistenceService
-
previousState
Returns the previous state of a givenitem.- Parameters:
item- the item to get the previous state value for- Returns:
- the previous state or
nullif no previous state could be found, or if the default persistence service is not configured or does not refer to aQueryablePersistenceService
-
previousState
Returns the previous state of a givenitem.- Parameters:
item- the item to get the previous state value forskipEqual- if true, skips equal state values and searches the first state not equal the current state- Returns:
- the previous state or
nullif no previous state could be found, or if the default persistence service is not configured or does not refer to aQueryablePersistenceService
-
previousState
Returns the previous state of a givenitem. ThePersistenceServiceidentified by theserviceIdis used.- Parameters:
item- the item to get the previous state value forskipEqual- iftrue, skips equal state values and searches the first state not equal the current stateserviceId- the name of thePersistenceServiceto use- Returns:
- the previous state or
nullif no previous state could be found, or if the givenserviceIdis not available or does not refer to aQueryablePersistenceService
-
changedSince
Checks if the state of a givenitemhas changed since a certain point in time. The default persistence service is used.- Parameters:
item- the item to check for state changestimestamp- the point in time to start the check- Returns:
trueif item state has changed,falseif it has not changed or if the default persistence service is not available or does not refer to aQueryablePersistenceService
-
changedBetween
Checks if the state of a givenitemhas changed between two points in time. The default persistence service is used.- Parameters:
item- the item to check for state changes- Returns:
trueif item state changed,falseif either item has not been changed in the given interval or if the default persistence does not refer to aQueryablePersistenceService, ornullif the default persistence service is not available
-
changedSince
Checks if the state of a givenitemhas changed since a certain point in time. ThePersistenceServiceidentified by theserviceIdis used.- Parameters:
item- the item to check for state changestimestamp- the point in time to start the checkserviceId- the name of thePersistenceServiceto use- Returns:
trueif item state has changed, orfalseif it has not changed or if the providedserviceIddoes not refer to an availableQueryablePersistenceService
-
changedBetween
public static boolean changedBetween(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Checks if the state of a givenitemchanged between two points in time. ThePersistenceServiceidentified by theserviceIdis used.- Parameters:
item- the item to check for state changesbegin- the point in time to start the checkend- the point in time to stop the checkserviceId- the name of thePersistenceServiceto use- Returns:
trueif item state changed orfalseif either the item has not changed in the given interval or if the givenserviceIddoes not refer to aQueryablePersistenceService
-
updatedSince
Checks if the state of a givenitemhas been updated since a certain point in time. The default persistence service is used.- Parameters:
item- the item to check for state updatestimestamp- the point in time to start the check- Returns:
trueif item state was updated,falseif either item has not been updated sincetimestampor if the default persistence does not refer to aQueryablePersistenceService, ornullif the default persistence service is not available
-
updatedBetween
Checks if the state of a givenitemhas been updated between two points in time. The default persistence service is used.- Parameters:
item- the item to check for state updatesbegin- the point in time to start the checkend- the point in time to stop the check- Returns:
trueif item state was updated,falseif either item has not been updated in the given interval or if the default persistence does not refer to aQueryablePersistenceService, ornullif the default persistence service is not available
-
updatedSince
Checks if the state of a givenitemhas been updated since a certain point in time. ThePersistenceServiceidentified by theserviceIdis used.- Parameters:
item- the item to check for state changestimestamp- the point in time to start the checkserviceId- the name of thePersistenceServiceto use- Returns:
trueif item state was updated orfalseif either the item has not been updated sincetimestampor if the givenserviceIddoes not refer to aQueryablePersistenceService
-
updatedBetween
public static boolean updatedBetween(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Checks if the state of a givenitemhas been updated between two points in time. ThePersistenceServiceidentified by theserviceIdis used.- Parameters:
item- the item to check for state changesbegin- the point in time to start the checkend- the point in time to stop the checkserviceId- the name of thePersistenceServiceto use- Returns:
trueif item state was updated orfalseif either the item has not been updated in the given interval or if the givenserviceIddoes not refer to aQueryablePersistenceService
-
maximumSince
Gets the historic item with the maximum value of the state of a givenitemsince a certain point in time. The default persistence service is used.- Parameters:
item- the item to get the maximum state value fortimestamp- 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
HistoricItemconstructed from theitemif the default persistence service does not refer to aQueryablePersistenceService
-
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 givenitemsince a certain point in time. The default persistence service is used.- Parameters:
item- the item to get the maximum state value forbegin- the point in time to start the checkend- the point in time to stop the check- Returns:
- a
HistoricItemwith the maximum state value since the given point in time, ornullif no states found or if the default persistence service does not refer to an availableQueryablePersistenceService
-
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 givenitemsince a certain point in time. ThePersistenceServiceidentified by theserviceIdis used.- Parameters:
item- the item to get the maximum state value fortimestamp- the point in time to start the checkserviceId- the name of thePersistenceServiceto use- Returns:
- a
HistoricItemwith the maximum state value since the given point in time, or aHistoricItemconstructed from theitem's state ifitem's state is the maximum value or if the givenserviceIddoes not refer to an availableQueryablePersistenceService
-
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 givenitemsince a certain point in time. ThePersistenceServiceidentified by theserviceIdis used.- Parameters:
item- the item to get the maximum state value forbegin- the point in time to start the checkend- the point in time to stop the checkserviceId- the name of thePersistenceServiceto use- Returns:
- a
HistoricItemwith the maximum state value since the given point in time, ornullno states found or if the givenserviceIddoes not refer to an availableQueryablePersistenceService
-
minimumSince
Gets the historic item with the minimum value of the state of a givenitemsince a certain point in time. The default persistence service is used.- Parameters:
item- the item to get the minimum state value fortimestamp- 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
HistoricItemconstructed from theitem's state ifitem's state is the minimum value or if the default persistence service does not refer to an availableQueryablePersistenceService
-
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 givenitembetween two certain points in time. The default persistence service is used.- Parameters:
item- the item to get the minimum state value forbegin- the beginning point in timeend- the end point in time to- Returns:
- the historic item with the minimum state value between the given points in time, or
nullif not state was found or if the default persistence service does not refer to an availableQueryablePersistenceService
-
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 givenitemsince a certain point in time. ThePersistenceServiceidentified by theserviceIdis used.- Parameters:
item- the item to get the minimum state value fortimestamp- the point in time from which to search for the minimum state valueserviceId- the name of thePersistenceServiceto use- Returns:
- the historic item with the minimum state value since the given point in time, or a
HistoricItemconstructed from theitem's state ifitem's state is the minimum value or if the givenserviceIddoes not refer to an availableQueryablePersistenceService.
-
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 givenitembetween two certain points in time. ThePersistenceServiceidentified by theserviceIdis used.- Parameters:
item- the item to get the minimum state value forbegin- the beginning point in timeend- the end point in time toserviceId- the name of thePersistenceServiceto use- Returns:
- the historic item with the minimum state value between the given points in time, or
nullif not state was found or if the givenserviceIddoes not refer to an availableQueryablePersistenceService
-
varianceSince
Gets the variance of the state of the givenItemsince a certain point in time. The defaultPersistenceServiceis used.- Parameters:
item- theItemto get the variance fortimestamp- the point in time from which to compute the variance- Returns:
- the variance between now and then, or
nullif there is no default persistence service available, or it is not aQueryablePersistenceService, or if there is no persisted state for the givenitemat the giventimestamp
-
varianceBetween
public static @Nullable DecimalType varianceBetween(Item item, ZonedDateTime begin, ZonedDateTime end) Gets the variance of the state of the givenItembetween two certain point in time. The defaultPersistenceServiceis used.- Parameters:
item- theItemto get the variance forbegin- the point in time from which to compute the varianceend- the end time for the computation- Returns:
- the variance between both points of time, or
nullif there is no default persistence service available, or it is not aQueryablePersistenceService, or if there is no persisted state for the givenitemat the giventimestamp
-
varianceSince
public static @Nullable DecimalType varianceSince(Item item, ZonedDateTime timestamp, String serviceId) Gets the variance of the state of the givenItemsince a certain point in time. ThePersistenceServiceidentified by theserviceIdis used.- Parameters:
item- theItemto get the variance fortimestamp- the point in time from which to compute the varianceserviceId- the name of thePersistenceServiceto use- Returns:
- the variance between now and then, or
nullif the persistence service given byserviceIdis not available, or it is not aQueryablePersistenceService, or if there is no persisted state for the givenitemat the giventimestamp
-
varianceBetween
public static @Nullable DecimalType varianceBetween(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Gets the variance of the state of the givenItembetween two points in time. ThePersistenceServiceidentified by theserviceIdis used.- Parameters:
item- theItemto get the variance forbegin- the point in time from which to computeend- the end time for the computationserviceId- the name of thePersistenceServiceto use- Returns:
- the variance between the given points in time, or
nullif the persistence service given byserviceIdis not available, or it is not aQueryablePersistenceService, or if there is no persisted state for the givenitemat the giventimestamp
-
deviationSince
Gets the standard deviation of the state of the givenItemsince a certain point in time. The defaultPersistenceServiceis 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- theItemto get the standard deviation fortimestamp- the point in time from which to compute the standard deviation- Returns:
- the standard deviation between now and then, or
nullif there is no default persistence service available, or it is not aQueryablePersistenceService, or if there is no persisted state for the givenitemat the giventimestamp
-
deviationBetween
public static @Nullable DecimalType deviationBetween(Item item, ZonedDateTime begin, ZonedDateTime end) Gets the standard deviation of the state of the givenItembetween two points in time. The defaultPersistenceServiceis 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- theItemto get the standard deviation forbegin- the point in time from which to computeend- the end time for the computation- Returns:
- the standard deviation between now and then, or
nullif there is no default persistence service available, or it is not aQueryablePersistenceService, or if there is no persisted state for the givenitemin the given interval
-
deviationSince
public static @Nullable DecimalType deviationSince(Item item, ZonedDateTime timestamp, String serviceId) Gets the standard deviation of the state of the givenItemsince a certain point in time. ThePersistenceServiceidentified by theserviceIdis 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- theItemto get the standard deviation fortimestamp- the point in time from which to compute the standard deviationserviceId- the name of thePersistenceServiceto use- Returns:
- the standard deviation between now and then, or
nullif the persistence service given byserviceIdit is not available or is not aQueryablePersistenceService, or if there is no persisted state for the givenitemat the giventimestamp
-
deviationBetween
public static @Nullable DecimalType deviationBetween(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Gets the standard deviation of the state of the givenItembetween two points in time. ThePersistenceServiceidentified by theserviceIdis 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- theItemto get the standard deviation forbegin- the point in time from which to computeend- the end time for the computationserviceId- the name of thePersistenceServiceto use- Returns:
- the standard deviation between now and then, or
nullif the persistence service given byserviceIdit is not available or is not aQueryablePersistenceService, or if there is no persisted state for the givenitemin the given interval
-
averageSince
Gets the average value of the state of a givenItemsince a certain point in time. The defaultPersistenceServiceis used.- Parameters:
item- theItemto get the average value fortimestamp- the point in time from which to search for the average value- Returns:
- the average value since
timestampornullif no previous states could be found or if the default persistence service does not refer to an availableQueryablePersistenceService. 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 givenItembetween two certain points in time. The defaultPersistenceServiceis used.- Parameters:
item- theItemto get the average value forbegin- the point in time from which to start the summationend- the point in time to which to start the summation- Returns:
- the average value since
timestampornullif no previous states could be found or if the default persistence service does not refer to an availableQueryablePersistenceService.
-
averageSince
public static @Nullable DecimalType averageSince(Item item, ZonedDateTime timestamp, String serviceId) Gets the average value of the state of a givenItemsince a certain point in time. ThePersistenceServiceidentified by theserviceIdis used.- Parameters:
item- theItemto get the average value fortimestamp- the point in time from which to search for the average valueserviceId- the name of thePersistenceServiceto use- Returns:
- the average value since
timestamp, ornullif no previous states could be found or if the persistence service given byserviceIddoes not refer to an availableQueryablePersistenceService. 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 givenItembetween two certain points in time. ThePersistenceServiceidentified by theserviceIdis used.- Parameters:
item- theItemto get the average value forbegin- the point in time from which to start the summationend- the point in time to which to start the summationserviceId- the name of thePersistenceServiceto use- Returns:
- the average value since
timestamp, ornullif no previous states could be found or if the persistence service given byserviceIddoes not refer to an availableQueryablePersistenceService
-
sumSince
Gets the sum of the state of a givenitemsince a certain point in time. The default persistence service is used.- Parameters:
item- the item for which we will sum its persisted state values sincetimestamptimestamp- the point in time from which to start the summation- Returns:
- the sum of the state values since
timestamp, orDecimalType.ZEROif no historic states could be found or if the default persistence service does not refer to aQueryablePersistenceService
-
sumBetween
Gets the sum of the state of a givenitembetween two certain points in time. The default persistence service is used.- Parameters:
item- the item for which we will sum its persisted state values betweenbeginandendbegin- the point in time from which to start the summationend- 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.ZEROif no historic states could be found or if the default persistence service does not refer to aQueryablePersistenceService
-
sumSince
Gets the sum of the state of a givenitemsince a certain point in time. ThePersistenceServiceidentified by theserviceIdis used.- Parameters:
item- the item for which we will sum its persisted state values sincetimestamptimestamp- the point in time from which to start the summationserviceId- the name of thePersistenceServiceto use- Returns:
- the sum of the state values since the given point in time, or
DecimalType.ZEROif no historic states could be found for theitemor ifserviceIddoes not refer to aQueryablePersistenceService
-
sumBetween
public static DecimalType sumBetween(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Gets the sum of the state of a givenitembetween two certain points in time. ThePersistenceServiceidentified by theserviceIdis used.- Parameters:
item- the item for which we will sum its persisted state values betweenbeginandendbegin- the point in time from which to start the summationend- the point in time to which to start the summationserviceId- the name of thePersistenceServiceto use- Returns:
- the sum of the state values between the given points in time, or
DecimalType.ZEROif no historic states could be found for theitemor ifserviceIddoes not refer to aQueryablePersistenceService
-
deltaSince
Gets the difference value of the state of a givenitemsince a certain point in time. The default persistence service is used.- Parameters:
item- the item to get the average state value fortimestamp- the point in time from which to compute the delta- Returns:
- the difference between now and then, or
nullif there is no default persistence service available, the default persistence service is not aQueryablePersistenceService, or if there is no persisted state for the givenitemat the giventimestampavailable in the default persistence service
-
deltaBetween
Gets the difference value of the state of a givenitembetween two certain point in time. The default persistence service is used.- Parameters:
item- the item to get the delta forbegin- the beginning point in timeend- the end point in time- Returns:
- the difference between end and begin, or
nullif the default persistence service does not refer to an availableQueryablePersistenceService, or if there is no persisted state for the givenitemfor 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 givenitemsince a certain point in time. ThePersistenceServiceidentified by theserviceIdis used.- Parameters:
item- the item to get the delta fortimestamp- the point in time from which to compute the deltaserviceId- the name of thePersistenceServiceto use- Returns:
- the difference between now and then, or
nullif the given serviceId does not refer to an availableQueryablePersistenceService, or if there is no persisted state for the givenitemat the giventimestampusing the persistence service namedserviceId
-
deltaBetween
public static @Nullable DecimalType deltaBetween(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Gets the difference value of the state of a givenitembetween two certain point in time. ThePersistenceServiceidentified by theserviceIdis used.- Parameters:
item- the item to get the delta forbegin- the beginning point in timeend- the end point in timeserviceId- the name of thePersistenceServiceto use- Returns:
- the difference between end and begin, or
nullif the given serviceId does not refer to an availableQueryablePersistenceService, or if there is no persisted state for the givenitemat the given points in time
-
evolutionRate
Gets the evolution rate of the state of a givenItemsince a certain point in time. The defaultPersistenceServiceis used.- Parameters:
item- the item to get the evolution rate value fortimestamp- 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
nullif there is no default persistence service available, the default persistence service is not aQueryablePersistenceService, or if there is no persisted state for the givenitemat the giventimestamp, or if there is a state but it is zero (which would cause a divide-by-zero error)
-
evolutionRate
Gets the evolution rate of the state of a givenItembetween two points in time. The defaultPersistenceServiceis used.- Parameters:
item- the item to get the evolution rate value forbegin- the beginning point in timeend- the end point in time- Returns:
- the evolution rate in percent (positive and negative) in the given interval, or
nullif there is no default persistence service available, the default persistence service is not aQueryablePersistenceService, or if there are no persisted state for the givenitemat 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 givenItemsince a certain point in time. ThePersistenceServiceidentified by theserviceIdis used.- Parameters:
item- theItemto get the evolution rate value fortimestamp- the point in time from which to compute the evolution rateserviceId- the name of thePersistenceServiceto use- Returns:
- the evolution rate in percent (positive and negative) between now and then, or
nullif the persistence service given byserviceIdis not available or is not aQueryablePersistenceService, or if there is no persisted state for the givenitemat the giventimestampusing the persistence service given byserviceId, 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 givenItembetween two points in time. ThePersistenceServiceidentified by theserviceIdis used.- Parameters:
item- theItemto get the evolution rate value forbegin- the beginning point in timeend- the end point in timeserviceId- the name of thePersistenceServiceto use- Returns:
- the evolution rate in percent (positive and negative) in the given interval, or
nullif the persistence service given byserviceIdis not available or is not aQueryablePersistenceService, or if there is no persisted state for the givenitemat the givenbeginandendusing the persistence service given byserviceId, or if there is a state but it is zero (which would cause a divide-by-zero error)
-
countSince
Gets the number of available historic data points of a givenItemfrom a point in time until now. The defaultPersistenceServiceis used.- Parameters:
item- theItemto querybegin- the beginning point in time- Returns:
- the number of values persisted for this item
-
countSince
Gets the number of available historic data points of a givenItemfrom a point in time until now. ThePersistenceServiceidentified by theserviceIdis used.- Parameters:
item- theItemto querybegin- the beginning point in timeserviceId- the name of thePersistenceServiceto use- Returns:
- the number of values persisted for this item
-
countBetween
Gets the number of available historic data points of a givenItembetween two points in time. The defaultPersistenceServiceis used.- Parameters:
item- theItemto querybegin- the beginning point in timeend- the end point in time- Returns:
- the number of values persisted for this item
-
countBetween
public static long countBetween(Item item, ZonedDateTime begin, @Nullable ZonedDateTime end, String serviceId) Gets the number of available historic data points of a givenItembetween two points in time. ThePersistenceServiceidentified by theserviceIdis used.- Parameters:
item- theItemto querybegin- the beginning point in timeend- the end point in timeserviceId- the name of thePersistenceServiceto use- Returns:
- the number of values persisted for this item
-
countStateChangesSince
Gets the number of changes in historic data points of a givenItemfrom a point in time until now. The defaultPersistenceServiceis used.- Parameters:
item- theItemto querybegin- the beginning point in time- Returns:
- the number of state changes for this item
-
countStateChangesSince
Gets the number of changes in historic data points of a givenItemfrom a point in time until now. ThePersistenceServiceidentified by theserviceIdis used.- Parameters:
item- theItemto querybegin- the beginning point in timeserviceId- the name of thePersistenceServiceto use- Returns:
- the number of state changes for this item
-
countStateChangesBetween
public static long countStateChangesBetween(Item item, ZonedDateTime begin, @Nullable ZonedDateTime end) Gets the number of changes in historic data points of a givenItembetween two points in time. The defaultPersistenceServiceis used.- Parameters:
item- theItemto querybegin- the beginning point in timeend- the end point in time- Returns:
- the number of state changes for this item
-
countStateChangesBetween
public static long countStateChangesBetween(Item item, ZonedDateTime begin, @Nullable ZonedDateTime end, String serviceId) Gets the number of changes in historic data points of a givenItembetween two points in time. ThePersistenceServiceidentified by theserviceIdis used.- Parameters:
item- theItemto querybegin- the beginning point in timeend- the end point in timeserviceId- the name of thePersistenceServiceto use- Returns:
- the number of state changes for this item
-
getAllStatesSince
Retrieves the historic items for a givenitemsince a certain point in time. The default persistence service is used.- Parameters:
item- the item for which to retrieve the historic itemtimestamp- the point in time from which to retrieve the states- Returns:
- the historic items since the given point in time, or
nullif no historic items could be found.
-
getAllStatesSince
public static Iterable<HistoricItem> getAllStatesSince(Item item, ZonedDateTime timestamp, String serviceId) Retrieves the historic items for a givenitemsince a certain point in time through aPersistenceServiceidentified by theserviceId.- Parameters:
item- the item for which to retrieve the historic itemtimestamp- the point in time from which to retrieve the statesserviceId- the name of thePersistenceServiceto use- Returns:
- the historic items since the given point in time, or
nullif no historic items could be found or if the providedserviceIddoes not refer to an availableQueryablePersistenceService
-
getAllStatesBetween
public static Iterable<HistoricItem> getAllStatesBetween(Item item, ZonedDateTime begin, @Nullable ZonedDateTime end) Retrieves the historic items for a givenitembeetween two certain points in time. The default persistence service is used.- Parameters:
item- the item for which to retrieve the historic itembegin- the point in time from which to retrieve the statesend- the point in time to which to retrieve the states- Returns:
- the historic items between the given points in time, or
nullif no historic items could be found.
-
getAllStatesBetween
public static Iterable<HistoricItem> getAllStatesBetween(Item item, ZonedDateTime begin, @Nullable ZonedDateTime end, String serviceId) Retrieves the historic items for a givenitembeetween two certain points in time through aPersistenceServiceidentified by theserviceId.- Parameters:
item- the item for which to retrieve the historic itembegin- the point in time from which to retrieve the statesend- the point in time to which to retrieve the statesserviceId- the name of thePersistenceServiceto use- Returns:
- the historic items between the given points in time, or
nullif no historic items could be found or if the providedserviceIddoes not refer to an availableQueryablePersistenceService
-