ItemHistory

items. ItemHistory

Class representing the historic state of an openHAB Item. If the Item receives its state from a binding that supports units of measurement, the returned state is in the according base unit, otherwise there is no unit conversion happening. Wrapping the PersistenceExtensions.

Be warned: This class can throw several exceptions from the underlying Java layer. It is recommended to wrap the methods of this class inside a try_catch block!

Methods

averageBetween(begin, end, serviceIdopt) → {number|null}

Description:
  • Gets the average value of the state of a given Item between two certain points in time.

Source:
Parameters:
Name Type Attributes Description
begin time.ZonedDateTime | Date

begin

end time.ZonedDateTime | Date

end

serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:
Type
number | null

averageSince(timestamp, serviceIdopt) → {number|null}

Description:
  • Gets the average value of the state of a given Item since a certain point in time.

Source:
Example
var yesterday = new Date(new Date().getTime() - (24 * 60 * 60 * 1000));
var item = items.getItem('KitchenDimmer');
console.log('KitchenDimmer average since yesterday', item.history.averageSince(yesterday));
Parameters:
Name Type Attributes Description
timestamp time.ZonedDateTime | Date
serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:
Type
number | null

changedBetween(begin, end, serviceIdopt) → {boolean}

Description:
  • Checks if the state of a given Item has changed between two certain points in time.

Source:
Parameters:
Name Type Attributes Description
begin time.ZonedDateTime | Date

begin

end time.ZonedDateTime | Date

end

serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:
Type
boolean

changedSince(timestamp, serviceIdopt) → {boolean}

Description:
  • Checks if the state of a given Item has changed since a certain point in time.

Source:
Parameters:
Name Type Attributes Description
timestamp time.ZonedDateTime | Date
serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:
Type
boolean

countBetween(begin, end, serviceIdopt) → {number}

Description:
  • Gets the number of available historic data points of a given Item between two certain points in time.

Source:
Parameters:
Name Type Attributes Description
begin time.ZonedDateTime | Date

begin

end time.ZonedDateTime | Date

end

serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:
Type
number

countSince(timestamp, serviceIdopt) → {number}

Description:
  • Gets the number of available historic data points of a given Item since a certain point in time.

Source:
Parameters:
Name Type Attributes Description
timestamp time.ZonedDateTime | Date
serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:
Type
number

countStateChangesBetween(begin, end, serviceIdopt) → {number}

Description:
  • Gets the number of changes in historic data points of a given Item between two certain points in time.

Source:
Parameters:
Name Type Attributes Description
begin time.ZonedDateTime | Date

begin

end time.ZonedDateTime | Date

end

serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:
Type
number

countStateChangesSince(timestamp, serviceIdopt) → {number}

Description:
  • Gets the number of changes in historic data points of a given Item since a certain point in time.

Source:
Parameters:
Name Type Attributes Description
timestamp time.ZonedDateTime | Date
serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:
Type
number

deltaBetween(begin, end, serviceIdopt) → {number|null}

Description:
  • Gets the difference value of the state of a given Item between two certain points in time.

Source:
Parameters:
Name Type Attributes Description
begin time.ZonedDateTime | Date

begin

end time.ZonedDateTime | Date

end

serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:
Type
number | null

deltaSince(timestamp, serviceIdopt) → {number|null}

Description:
  • Gets the difference value of the state of a given Item since a certain point in time.

Source:
Parameters:
Name Type Attributes Description
timestamp time.ZonedDateTime | Date
serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:
Type
number | null

deviationBetween(begin, end, serviceIdopt) → {number|null}

Description:
  • Gets the standard deviation of the state of the given Item between two certain points in time.

Source:
Parameters:
Name Type Attributes Description
begin time.ZonedDateTime | Date

begin

end time.ZonedDateTime | Date

end

serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:
Type
number | null

deviationSince(timestamp, serviceIdopt) → {number|null}

Description:
  • Gets the standard deviation of the state of the given Item since a certain point in time.

Source:
Parameters:
Name Type Attributes Description
timestamp time.ZonedDateTime | Date
serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:
Type
number | null

evolutionRate(timestamp, serviceIdopt) → {number|null}

Description:
  • Gets the evolution rate of the state of a given Item since a certain point in time.

Source:
Deprecated:
  • Replaced by evolutionRateSince and evolutionRateBetween.
Parameters:
Name Type Attributes Description
timestamp time.ZonedDateTime | Date
serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:
Type
number | null

evolutionRateBetween(begin, end, serviceIdopt) → {number|null}

Description:
  • Gets the evolution rate of the state of a given Item between two certain points in time.

Source:
Parameters:
Name Type Attributes Description
begin time.ZonedDateTime | Date

begin

end time.ZonedDateTime | Date

end

serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:
Type
number | null

evolutionRateSince(timestamp, serviceIdopt) → {number|null}

Description:
  • Gets the evolution rate of the state of a given Item since a certain point in time.

Source:
Parameters:
Name Type Attributes Description
timestamp time.ZonedDateTime | Date
serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:
Type
number | null

getAllStatesBetween(begin, end, serviceIdopt) → {Array.<HistoricItem>}

Description:
  • Retrieves the HistoricItems for for a given Item between two certain points in time.

Source:
Parameters:
Name Type Attributes Description
begin time.ZonedDateTime | Date

begin

end time.ZonedDateTime | Date

end

serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:
Type
Array.<HistoricItem>

getAllStatesSince(timestamp, serviceIdopt) → {Array.<HistoricItem>}

Description:
  • Retrieves the HistoricItems for for a given Item since a certain point in time.

Source:
Parameters:
Name Type Attributes Description
timestamp time.ZonedDateTime | Date
serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:
Type
Array.<HistoricItem>

historicState(timestamp, serviceIdopt) → {HistoricItem|null}

Description:
  • Retrieves the historic state for a given Item at a certain point in time.

Source:
Parameters:
Name Type Attributes Description
timestamp time.ZonedDateTime | Date
serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:

historic item

Type
HistoricItem | null

lastUpdate(serviceIdopt) → {time.ZonedDateTime|null}

Description:
  • Query the last update time of a given Item.

Source:
Parameters:
Name Type Attributes Description
serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:
Type
time.ZonedDateTime | null

latestState(serviceIdopt) → {string|null}

Description:
  • Retrieves the historic Item state for a given Item at the current point in time.

Source:
Parameters:
Name Type Attributes Description
serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:

state

Type
string | null

maximumBetween(begin, end, serviceIdopt) → {HistoricItem|null}

Description:
  • Gets the state with the maximum value of a given Item between two certain points in time.

Source:
Parameters:
Name Type Attributes Description
begin time.ZonedDateTime | Date

begin

end time.ZonedDateTime | Date

end

serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:

historic item or null

Type
HistoricItem | null

maximumSince(timestamp, serviceIdopt) → {HistoricItem|null}

Description:
  • Gets the state with the maximum value of a given Item since a certain point in time.

Source:
Parameters:
Name Type Attributes Description
timestamp time.ZonedDateTime | Date
serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:

historic item or null

Type
HistoricItem | null

minimumBetween(begin, end, serviceIdopt) → {HistoricItem|null}

Description:
  • Gets the state with the minimum value of a given Item between two certain points in time.

Source:
Parameters:
Name Type Attributes Description
begin time.ZonedDateTime | Date

begin

end time.ZonedDateTime | Date

end

serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:

historic item or null

Type
HistoricItem | null

minimumSince(timestamp, serviceIdopt) → {HistoricItem|null}

Description:
  • Gets the state with the minimum value of a given Item since a certain point in time.

Source:
Parameters:
Name Type Attributes Description
timestamp time.ZonedDateTime | Date
serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:

historic item or null

Type
HistoricItem | null

persist(serviceIdopt)

Description:
  • Persists the state of a given Item.

    Tells the persistence service to store the current state of the Item, which is then performed asynchronously. This has the side effect, that if the Item state changes shortly after .persist has been called, the new state will be persisted. To work around that side effect, you might add java.lang.Thread.sleep to your code:

Source:
Example
items.MyItem.history.persist(); // Tell persistence to store the current Item state
java.lang.Thread.sleep(100); // Wait 100 ms to make sure persistence has enough time to store the current Item state
items.MyItem.postUpdate(0); // Now set the Item state to a new value
Parameters:
Name Type Attributes Description
serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

previousState(skipEqualopt, serviceIdopt) → {HistoricItem|null}

Description:
  • Returns the previous state of a given Item.

Source:
Parameters:
Name Type Attributes Description
skipEqual boolean <optional>

optional, if true, skips equal state values and searches the first state not equal the current state

serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:

historic item or null

Type
HistoricItem | null

sumBetween(begin, end, serviceIdopt) → {number|null}

Description:
  • Gets the sum of the states of a given Item between two certain points in time.

Source:
Parameters:
Name Type Attributes Description
begin time.ZonedDateTime | Date

begin

end time.ZonedDateTime | Date

end

serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:
Type
number | null

sumSince(timestamp, serviceIdopt) → {number|null}

Description:
  • Gets the sum of the states of a given Item since a certain point in time.

Source:
Parameters:
Name Type Attributes Description
timestamp time.ZonedDateTime | Date
serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:
Type
number | null

updatedBetween(begin, end, serviceIdopt) → {boolean}

Description:
  • Checks if the state of a given Item has been updated between two certain points in time.

Source:
Parameters:
Name Type Attributes Description
begin time.ZonedDateTime | Date

begin

end time.ZonedDateTime | Date

end

serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:
Type
boolean

updatedSince(timestamp, serviceIdopt) → {boolean}

Description:
  • Checks if the state of a given Item has been updated since a certain point in time.

Source:
Parameters:
Name Type Attributes Description
timestamp time.ZonedDateTime | Date
serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:
Type
boolean

varianceBetween(begin, end, serviceIdopt) → {number|null}

Description:
  • Gets the variance of the state of the given Item between two certain points in time.

Source:
Parameters:
Name Type Attributes Description
begin time.ZonedDateTime | Date

begin

end time.ZonedDateTime | Date

end

serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:
Type
number | null

varianceSince(timestamp, serviceIdopt) → {number|null}

Description:
  • Gets the variance of the state of the given Item since a certain point in time.

Source:
Parameters:
Name Type Attributes Description
timestamp time.ZonedDateTime | Date
serviceId string <optional>

Optional persistence service ID, if omitted, the default persistence service will be used.

Returns:
Type
number | null