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
-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable DecimalType
averageBetween
(Item item, ZonedDateTime begin, ZonedDateTime end) Gets the average value of the state of a givenItem
between two certain points in time.static @Nullable DecimalType
averageBetween
(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Gets the average value of the state of a givenItem
between two certain points in time.static @Nullable DecimalType
averageSince
(Item item, ZonedDateTime timestamp) Gets the average value of the state of a givenItem
since a certain point in time.static @Nullable DecimalType
averageSince
(Item item, ZonedDateTime timestamp, String serviceId) Gets the average value of the state of a givenItem
since a certain point in time.static boolean
changedBetween
(Item item, ZonedDateTime begin, ZonedDateTime end) Checks if the state of a givenitem
has changed between two points in time.static boolean
changedBetween
(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Checks if the state of a givenitem
changed between two points in time.static boolean
changedSince
(Item item, ZonedDateTime timestamp) Checks if the state of a givenitem
has changed since a certain point in time.static boolean
changedSince
(Item item, ZonedDateTime timestamp, String serviceId) Checks if the state of a givenitem
has changed since a certain point in time.static long
countBetween
(Item item, ZonedDateTime begin, @Nullable ZonedDateTime end) Gets the number of available historic data points of a givenItem
between two points in time.static long
countBetween
(Item item, ZonedDateTime begin, @Nullable ZonedDateTime end, String serviceId) Gets the number of available historic data points of a givenItem
between two points in time.static long
countSince
(Item item, ZonedDateTime begin) Gets the number of available historic data points of a givenItem
from a point in time until now.static long
countSince
(Item item, ZonedDateTime begin, String serviceId) Gets the number of available historic data points of a givenItem
from a point in time until now.static long
countStateChangesBetween
(Item item, ZonedDateTime begin, @Nullable ZonedDateTime end) Gets the number of changes in historic data points of a givenItem
between two points in time.static long
countStateChangesBetween
(Item item, ZonedDateTime begin, @Nullable ZonedDateTime end, String serviceId) Gets the number of changes in historic data points of a givenItem
between two points in time.static long
countStateChangesSince
(Item item, ZonedDateTime begin) Gets the number of changes in historic data points of a givenItem
from a point in time until now.static long
countStateChangesSince
(Item item, ZonedDateTime begin, String serviceId) Gets the number of changes in historic data points of a givenItem
from a point in time until now.static @Nullable DecimalType
deltaBetween
(Item item, ZonedDateTime begin, ZonedDateTime end) Gets the difference value of the state of a givenitem
between two certain point in time.static @Nullable DecimalType
deltaBetween
(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Gets the difference value of the state of a givenitem
between two certain point in time.static @Nullable DecimalType
deltaSince
(Item item, ZonedDateTime timestamp) Gets the difference value of the state of a givenitem
since a certain point in time.static @Nullable DecimalType
deltaSince
(Item item, ZonedDateTime timestamp, String serviceId) Gets the difference value of the state of a givenitem
since a certain point in time.static @Nullable DecimalType
deviationBetween
(Item item, ZonedDateTime begin, ZonedDateTime end) Gets the standard deviation of the state of the givenItem
between two points in time.static @Nullable DecimalType
deviationBetween
(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Gets the standard deviation of the state of the givenItem
between two points in time.static @Nullable DecimalType
deviationSince
(Item item, ZonedDateTime timestamp) Gets the standard deviation of the state of the givenItem
since a certain point in time.static @Nullable DecimalType
deviationSince
(Item item, ZonedDateTime timestamp, String serviceId) Gets the standard deviation of the state of the givenItem
since a certain point in time.static DecimalType
evolutionRate
(Item item, ZonedDateTime timestamp) Gets the evolution rate of the state of a givenItem
since a certain point in time.static @Nullable DecimalType
evolutionRate
(Item item, ZonedDateTime timestamp, String serviceId) Gets the evolution rate of the state of a givenItem
since a certain point in time.static DecimalType
evolutionRate
(Item item, ZonedDateTime begin, ZonedDateTime end) Gets the evolution rate of the state of a givenItem
between two points in time.static @Nullable DecimalType
evolutionRate
(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Gets the evolution rate of the state of a givenItem
between two points in time.static Iterable<HistoricItem>
getAllStatesBetween
(Item item, ZonedDateTime begin, @Nullable ZonedDateTime end) Retrieves the historic items for a givenitem
beetween two certain points in time.static Iterable<HistoricItem>
getAllStatesBetween
(Item item, ZonedDateTime begin, @Nullable ZonedDateTime end, String serviceId) Retrieves the historic items for a givenitem
beetween two certain points in time through aPersistenceService
identified by theserviceId
.static Iterable<HistoricItem>
getAllStatesSince
(Item item, ZonedDateTime timestamp) Retrieves the historic items for a givenitem
since a certain point in time.static Iterable<HistoricItem>
getAllStatesSince
(Item item, ZonedDateTime timestamp, String serviceId) Retrieves the historic items for a givenitem
since a certain point in time through aPersistenceService
identified by theserviceId
.static @Nullable HistoricItem
historicState
(Item item, ZonedDateTime timestamp) Retrieves the historic item for a givenitem
at a certain point in time through the default persistence service.static @Nullable HistoricItem
historicState
(Item item, ZonedDateTime timestamp, String serviceId) Retrieves the historic item for a givenitem
at a certain point in time through aPersistenceService
identified by theserviceId
.static @Nullable ZonedDateTime
lastUpdate
(Item item) Query the last update time of a givenitem
.static @Nullable ZonedDateTime
lastUpdate
(Item item, String serviceId) Query for the last update time of a givenitem
.static @Nullable HistoricItem
maximumBetween
(Item item, ZonedDateTime begin, ZonedDateTime end) Gets the historic item with the maximum value of the state of a givenitem
since a certain point in time.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 givenitem
since a certain point in time.static @Nullable HistoricItem
maximumSince
(Item item, ZonedDateTime timestamp) Gets the historic item with the maximum value of the state of a givenitem
since a certain point in time.static @Nullable HistoricItem
maximumSince
(Item item, ZonedDateTime timestamp, String serviceId) Gets the historic item with the maximum value of the state of a givenitem
since a certain point in time.static @Nullable HistoricItem
minimumBetween
(Item item, ZonedDateTime begin, ZonedDateTime end) Gets the historic item with the minimum value of the state of a givenitem
between two certain points in time.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 givenitem
between two certain points in time.static @Nullable HistoricItem
minimumSince
(Item item, ZonedDateTime timestamp) Gets the historic item with the minimum value of the state of a givenitem
since a certain point in time.static @Nullable HistoricItem
minimumSince
(Item item, ZonedDateTime timestamp, String serviceId) Gets the historic item with the minimum value of the state of a givenitem
since a certain point in time.static void
Persists the state of a givenitem
through the default persistence service.static void
static @Nullable HistoricItem
previousState
(Item item) Returns the previous state of a givenitem
.static @Nullable HistoricItem
previousState
(Item item, boolean skipEqual) Returns the previous state of a givenitem
.static @Nullable HistoricItem
previousState
(Item item, boolean skipEqual, String serviceId) Returns the previous state of a givenitem
.static DecimalType
sumBetween
(Item item, ZonedDateTime begin, ZonedDateTime end) Gets the sum of the state of a givenitem
between two certain points in time.static DecimalType
sumBetween
(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Gets the sum of the state of a givenitem
between two certain points in time.static DecimalType
sumSince
(Item item, ZonedDateTime timestamp) Gets the sum of the state of a givenitem
since a certain point in time.static DecimalType
sumSince
(Item item, ZonedDateTime timestamp, String serviceId) Gets the sum of the state of a givenitem
since a certain point in time.static boolean
updatedBetween
(Item item, ZonedDateTime begin, ZonedDateTime end) Checks if the state of a givenitem
has been updated between two points in time.static boolean
updatedBetween
(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Checks if the state of a givenitem
has been updated between two points in time.static boolean
updatedSince
(Item item, ZonedDateTime timestamp) Checks if the state of a givenitem
has been updated since a certain point in time.static boolean
updatedSince
(Item item, ZonedDateTime timestamp, String serviceId) Checks if the state of a givenitem
has been updated since a certain point in time.static @Nullable DecimalType
varianceBetween
(Item item, ZonedDateTime begin, ZonedDateTime end) Gets the variance of the state of the givenItem
between two certain point in time.static @Nullable DecimalType
varianceBetween
(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Gets the variance of the state of the givenItem
between two points in time.static @Nullable DecimalType
varianceSince
(Item item, ZonedDateTime timestamp) Gets the variance of the state of the givenItem
since a certain point in time.static @Nullable DecimalType
varianceSince
(Item item, ZonedDateTime timestamp, String serviceId) Gets the variance of the state of the givenItem
since a certain point in time.
-
Constructor Details
-
PersistenceExtensions
-
-
Method Details
-
persist
- Parameters:
item
- the item to storeserviceId
- the name of thePersistenceService
to use
-
persist
Persists the state of a givenitem
through the default persistence service.- Parameters:
item
- the item to store
-
historicState
Retrieves the historic item for a givenitem
at 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
null
if 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 givenitem
at a certain point in time through aPersistenceService
identified 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 thePersistenceService
to use- Returns:
- the historic item at the given point in time, or
null
if no historic item could be found or if the providedserviceId
does 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
, ornull
if 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 thePersistenceService
to use- Returns:
- last time
item
was updated, ornull
if there are no previously persisted updates or if persistence service given byserviceId
does 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
null
if 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
null
if 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
. ThePersistenceService
identified by theserviceId
is 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 thePersistenceService
to use- Returns:
- the previous state or
null
if no previous state could be found, or if the givenserviceId
is not available or does not refer to aQueryablePersistenceService
-
changedSince
Checks if the state of a givenitem
has 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:
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 aQueryablePersistenceService
-
changedBetween
Checks if the state of a givenitem
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 aQueryablePersistenceService
, ornull
if the default persistence service is not available
-
changedSince
Checks if the state of a givenitem
has changed since a certain point in time. ThePersistenceService
identified by theserviceId
is used.- Parameters:
item
- the item to check for state changestimestamp
- the point in time to start the checkserviceId
- the name of thePersistenceService
to use- Returns:
true
if item state has changed, orfalse
if it has not changed or if the providedserviceId
does not refer to an availableQueryablePersistenceService
-
changedBetween
public static boolean changedBetween(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Checks if the state of a givenitem
changed between two points in time. ThePersistenceService
identified by theserviceId
is 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 thePersistenceService
to use- Returns:
true
if item state changed orfalse
if either the item has not changed in the given interval or if the givenserviceId
does not refer to aQueryablePersistenceService
-
updatedSince
Checks if the state of a givenitem
has 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:
true
if item state was updated,false
if either item has not been updated sincetimestamp
or if the default persistence does not refer to aQueryablePersistenceService
, ornull
if the default persistence service is not available
-
updatedBetween
Checks if the state of a givenitem
has 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:
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 aQueryablePersistenceService
, ornull
if the default persistence service is not available
-
updatedSince
Checks if the state of a givenitem
has been updated since a certain point in time. ThePersistenceService
identified by theserviceId
is used.- Parameters:
item
- the item to check for state changestimestamp
- the point in time to start the checkserviceId
- the name of thePersistenceService
to use- Returns:
true
if item state was updated orfalse
if either the item has not been updated sincetimestamp
or if the givenserviceId
does not refer to aQueryablePersistenceService
-
updatedBetween
public static boolean updatedBetween(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Checks if the state of a givenitem
has been updated between two points in time. ThePersistenceService
identified by theserviceId
is 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 thePersistenceService
to use- Returns:
true
if item state was updated orfalse
if either the item has not been updated in the given interval or if the givenserviceId
does not refer to aQueryablePersistenceService
-
maximumSince
Gets the historic item with the maximum value of the state of a givenitem
since 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
HistoricItem
constructed from theitem
if 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 givenitem
since 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
HistoricItem
with the maximum state value since the given point in time, ornull
if 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 givenitem
since a certain point in time. ThePersistenceService
identified by theserviceId
is used.- Parameters:
item
- the item to get the maximum state value fortimestamp
- the point in time to start the checkserviceId
- the name of thePersistenceService
to use- Returns:
- a
HistoricItem
with the maximum state value since the given point in time, or aHistoricItem
constructed from theitem
's state ifitem
's state is the maximum value or if the givenserviceId
does 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 givenitem
since a certain point in time. ThePersistenceService
identified by theserviceId
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 checkserviceId
- the name of thePersistenceService
to use- Returns:
- a
HistoricItem
with the maximum state value since the given point in time, ornull
no states found or if the givenserviceId
does not refer to an availableQueryablePersistenceService
-
minimumSince
Gets the historic item with the minimum value of the state of a givenitem
since 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
HistoricItem
constructed 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 givenitem
between 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
null
if 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 givenitem
since a certain point in time. ThePersistenceService
identified by theserviceId
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 valueserviceId
- the name of thePersistenceService
to use- Returns:
- the historic item with the minimum state value since the given point in time, or a
HistoricItem
constructed from theitem
's state ifitem
's state is the minimum value or if the givenserviceId
does 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 givenitem
between two certain points in time. ThePersistenceService
identified by theserviceId
is 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 thePersistenceService
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 givenserviceId
does not refer to an availableQueryablePersistenceService
-
varianceSince
Gets the variance of the state of the givenItem
since a certain point in time. The defaultPersistenceService
is used.- Parameters:
item
- theItem
to get the variance fortimestamp
- 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 aQueryablePersistenceService
, or if there is no persisted state for the givenitem
at the giventimestamp
-
varianceBetween
public static @Nullable DecimalType varianceBetween(Item item, ZonedDateTime begin, ZonedDateTime end) Gets the variance of the state of the givenItem
between two certain point in time. The defaultPersistenceService
is used.- Parameters:
item
- theItem
to 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
null
if there is no default persistence service available, or it is not aQueryablePersistenceService
, or if there is no persisted state for the givenitem
at the giventimestamp
-
varianceSince
public static @Nullable DecimalType varianceSince(Item item, ZonedDateTime timestamp, String serviceId) Gets the variance of the state of the givenItem
since a certain point in time. ThePersistenceService
identified by theserviceId
is used.- Parameters:
item
- theItem
to get the variance fortimestamp
- the point in time from which to compute the varianceserviceId
- the name of thePersistenceService
to use- Returns:
- the variance between now and then, or
null
if the persistence service given byserviceId
is not available, or it is not aQueryablePersistenceService
, or if there is no persisted state for the givenitem
at the giventimestamp
-
varianceBetween
public static @Nullable DecimalType varianceBetween(Item item, ZonedDateTime begin, ZonedDateTime end, String serviceId) Gets the variance of the state of the givenItem
between two points in time. ThePersistenceService
identified by theserviceId
is used.- Parameters:
item
- theItem
to get the variance forbegin
- the point in time from which to computeend
- the end time for the computationserviceId
- the name of thePersistenceService
to use- Returns:
- the variance between the given points in time, or
null
if the persistence service given byserviceId
is not available, or it is not aQueryablePersistenceService
, or if there is no persisted state for the givenitem
at the giventimestamp
-
deviationSince
Gets the standard deviation of the state of the givenItem
since a certain point in time. The defaultPersistenceService
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
- theItem
to 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
null
if there is no default persistence service available, or it is not aQueryablePersistenceService
, or if there is no persisted state for the givenitem
at the giventimestamp
-
deviationBetween
public static @Nullable DecimalType deviationBetween(Item item, ZonedDateTime begin, ZonedDateTime end) Gets the standard deviation of the state of the givenItem
between two points in time. The defaultPersistenceService
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
- theItem
to 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
null
if there is no default persistence service available, or it is not aQueryablePersistenceService
, or if there is no persisted state for the givenitem
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 givenItem
since a certain point in time. ThePersistenceService
identified by theserviceId
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
- theItem
to get the standard deviation fortimestamp
- the point in time from which to compute the standard deviationserviceId
- the name of thePersistenceService
to use- Returns:
- the standard deviation between now and then, or
null
if the persistence service given byserviceId
it is not available or is not aQueryablePersistenceService
, or if there is no persisted state for the givenitem
at 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 givenItem
between two points in time. ThePersistenceService
identified by theserviceId
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
- theItem
to get the standard deviation forbegin
- the point in time from which to computeend
- the end time for the computationserviceId
- the name of thePersistenceService
to use- Returns:
- the standard deviation between now and then, or
null
if the persistence service given byserviceId
it is not available or is not aQueryablePersistenceService
, or if there is no persisted state for the givenitem
in the given interval
-
averageSince
Gets the average value of the state of a givenItem
since a certain point in time. The defaultPersistenceService
is used.- Parameters:
item
- theItem
to get the average value fortimestamp
- the point in time from which to search for the average value- Returns:
- the average value since
timestamp
ornull
if 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 givenItem
between two certain points in time. The defaultPersistenceService
is used.- Parameters:
item
- theItem
to 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
timestamp
ornull
if 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 givenItem
since a certain point in time. ThePersistenceService
identified by theserviceId
is used.- Parameters:
item
- theItem
to get the average value fortimestamp
- the point in time from which to search for the average valueserviceId
- the name of thePersistenceService
to use- Returns:
- the average value since
timestamp
, ornull
if no previous states could be found or if the persistence service given byserviceId
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, String serviceId) Gets the average value of the state of a givenItem
between two certain points in time. ThePersistenceService
identified by theserviceId
is used.- Parameters:
item
- theItem
to 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 thePersistenceService
to use- Returns:
- the average value since
timestamp
, ornull
if no previous states could be found or if the persistence service given byserviceId
does not refer to an availableQueryablePersistenceService
-
sumSince
Gets the sum of the state of a givenitem
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 sincetimestamp
timestamp
- the point in time from which to start the summation- Returns:
- the sum of the state values since
timestamp
, orDecimalType.ZERO
if 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 givenitem
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 betweenbegin
andend
begin
- 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.ZERO
if 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 givenitem
since a certain point in time. ThePersistenceService
identified by theserviceId
is used.- Parameters:
item
- the item for which we will sum its persisted state values sincetimestamp
timestamp
- the point in time from which to start the summationserviceId
- the name of thePersistenceService
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 theitem
or ifserviceId
does 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 givenitem
between two certain points in time. ThePersistenceService
identified by theserviceId
is used.- Parameters:
item
- the item for which we will sum its persisted state values betweenbegin
andend
begin
- the point in time from which to start the summationend
- the point in time to which to start the summationserviceId
- the name of thePersistenceService
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 theitem
or ifserviceId
does not refer to aQueryablePersistenceService
-
deltaSince
Gets the difference value of the state of a givenitem
since 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
null
if there is no default persistence service available, the default persistence service is not aQueryablePersistenceService
, or if there is no persisted state for the givenitem
at the giventimestamp
available in the default persistence service
-
deltaBetween
Gets the difference value of the state of a givenitem
between 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
null
if the default persistence service does not refer to an availableQueryablePersistenceService
, or if there is no persisted state for the givenitem
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 givenitem
since a certain point in time. ThePersistenceService
identified by theserviceId
is used.- Parameters:
item
- the item to get the delta fortimestamp
- the point in time from which to compute the deltaserviceId
- the name of thePersistenceService
to use- Returns:
- the difference between now and then, or
null
if the given serviceId does not refer to an availableQueryablePersistenceService
, or if there is no persisted state for the givenitem
at the giventimestamp
using 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 givenitem
between two certain point in time. ThePersistenceService
identified by theserviceId
is used.- Parameters:
item
- the item to get the delta forbegin
- the beginning point in timeend
- the end point in timeserviceId
- the name of thePersistenceService
to use- Returns:
- the difference between end and begin, or
null
if the given serviceId does not refer to an availableQueryablePersistenceService
, or if there is no persisted state for the givenitem
at the given points in time
-
evolutionRate
Gets the evolution rate of the state of a givenItem
since a certain point in time. The defaultPersistenceService
is 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
null
if there is no default persistence service available, the default persistence service is not aQueryablePersistenceService
, or if there is no persisted state for the givenitem
at 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 givenItem
between two points in time. The defaultPersistenceService
is 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
null
if there is no default persistence service available, the default persistence service is not aQueryablePersistenceService
, or if there are no persisted state for the givenitem
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 givenItem
since a certain point in time. ThePersistenceService
identified by theserviceId
is used.- Parameters:
item
- theItem
to get the evolution rate value fortimestamp
- the point in time from which to compute the evolution rateserviceId
- the name of thePersistenceService
to use- Returns:
- the evolution rate in percent (positive and negative) between now and then, or
null
if the persistence service given byserviceId
is not available or is not aQueryablePersistenceService
, or if there is no persisted state for the givenitem
at the giventimestamp
using 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 givenItem
between two points in time. ThePersistenceService
identified by theserviceId
is used.- Parameters:
item
- theItem
to get the evolution rate value forbegin
- the beginning point in timeend
- the end point in timeserviceId
- the name of thePersistenceService
to use- Returns:
- the evolution rate in percent (positive and negative) in the given interval, or
null
if the persistence service given byserviceId
is not available or is not aQueryablePersistenceService
, or if there is no persisted state for the givenitem
at the givenbegin
andend
using 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 givenItem
from a point in time until now. The defaultPersistenceService
is used.- Parameters:
item
- theItem
to 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 givenItem
from a point in time until now. ThePersistenceService
identified by theserviceId
is used.- Parameters:
item
- theItem
to querybegin
- the beginning point in timeserviceId
- the name of thePersistenceService
to use- Returns:
- the number of values persisted for this item
-
countBetween
Gets the number of available historic data points of a givenItem
between two points in time. The defaultPersistenceService
is used.- Parameters:
item
- theItem
to 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 givenItem
between two points in time. ThePersistenceService
identified by theserviceId
is used.- Parameters:
item
- theItem
to querybegin
- the beginning point in timeend
- the end point in timeserviceId
- the name of thePersistenceService
to use- Returns:
- the number of values persisted for this item
-
countStateChangesSince
Gets the number of changes in historic data points of a givenItem
from a point in time until now. The defaultPersistenceService
is used.- Parameters:
item
- theItem
to 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 givenItem
from a point in time until now. ThePersistenceService
identified by theserviceId
is used.- Parameters:
item
- theItem
to querybegin
- the beginning point in timeserviceId
- the name of thePersistenceService
to 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 givenItem
between two points in time. The defaultPersistenceService
is used.- Parameters:
item
- theItem
to 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 givenItem
between two points in time. ThePersistenceService
identified by theserviceId
is used.- Parameters:
item
- theItem
to querybegin
- the beginning point in timeend
- the end point in timeserviceId
- the name of thePersistenceService
to use- Returns:
- the number of state changes for this item
-
getAllStatesSince
Retrieves the historic items for a givenitem
since 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
null
if no historic items could be found.
-
getAllStatesSince
public static Iterable<HistoricItem> getAllStatesSince(Item item, ZonedDateTime timestamp, String serviceId) Retrieves the historic items for a givenitem
since a certain point in time through aPersistenceService
identified 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 thePersistenceService
to use- Returns:
- the historic items since the given point in time, or
null
if no historic items could be found or if the providedserviceId
does not refer to an availableQueryablePersistenceService
-
getAllStatesBetween
public static Iterable<HistoricItem> getAllStatesBetween(Item item, ZonedDateTime begin, @Nullable ZonedDateTime end) Retrieves the historic items for a givenitem
beetween 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
null
if 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 givenitem
beetween two certain points in time through aPersistenceService
identified 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 thePersistenceService
to use- Returns:
- the historic items between the given points in time, or
null
if no historic items could be found or if the providedserviceId
does not refer to an availableQueryablePersistenceService
-