diff --git a/README.md b/README.md
index 040b5469..506feccb 100644
--- a/README.md
+++ b/README.md
@@ -396,7 +396,7 @@ Calling `getItem(...)` or `...` returns an `Item` object with the following prop
- Item : `object`
- .rawItem ⇒ `HostItem`
- - .history ⇒ [`ItemHistory`](#itemhistory)
+ - .persistence ⇒ [`ItemPersistence`](#itempersistence)
- .semantics ⇒ [`ItemSemantics`](https://openhab.github.io/openhab-js/items.ItemSemantics.html)
- .type ⇒ `string`
- .name ⇒ `string`
@@ -496,63 +496,84 @@ items.replaceItem({
See [openhab-js : ItemConfig](https://openhab.github.io/openhab-js/global.html#ItemConfig) for full API documentation.
-#### `ItemHistory`
+#### `ItemPersistence`
-Calling `Item.history` returns an `ItemHistory` object with the following functions:
+Calling `Item.history` returns an `ItemPersistence` object with the following functions:
-- ItemHistory :`object`
- - .averageBetween(begin, end, serviceId) ⇒ `number | null`
- - .averageSince(timestamp, serviceId) ⇒ `number | null`
- - .changedBetween(begin, end, serviceId) ⇒ `boolean`
+- ItemPersistence :`object`
+ - .averageSince(timestamp, serviceId) ⇒ `PersistedState | null`
+ - .averageUntil(timestamp, serviceId) ⇒ `PersistedState | null`
+ - .averageBetween(begin, end, serviceId) ⇒ `PersistedState | null`
- .changedSince(timestamp, serviceId) ⇒ `boolean`
- - .deltaBetween(begin, end, serviceId) ⇒ `number | null`
- - .deltaSince(timestamp, serviceId) ⇒ `number | null`
- - .deviationBetween(begin, end, serviceId) ⇒ `number | null`
- - .deviationSince(timestamp, serviceId) ⇒ `number | null`
- - .evolutionRateBetween(begin, end, serviceId) ⇒ `number | null`
+ - .changedUntil(timestamp, serviceId) ⇒ `boolean`
+ - .changedBetween(begin, end, serviceId) ⇒ `boolean`
+ - .countSince(timestamp, serviceId) ⇒ `number`
+ - .countUntil(timestamp, serviceId) ⇒ `number`
+ - .countBetween(begin, end, serviceId) ⇒ `number`
+ - .countStateChangesSince(timestamp, serviceId) ⇒ `number`
+ - .countStateChangesUntil(timestamp, serviceId) ⇒ `number`
+ - .countStateChangesBetween(begin, end, serviceId) ⇒ `number`
+ - .deltaSince(timestamp, serviceId) ⇒ `PersistedState | null`
+ - .deltaUntil(timestamp, serviceId) ⇒ `PersistedState | null`
+ - .deltaBetween(begin, end, serviceId) ⇒ `PersistedState | null`
+ - .deviationSince(timestamp, serviceId) ⇒ `PersistedState | null`
+ - .deviationUntil(timestamp, serviceId) ⇒ `PersistedState | null`
+ - .deviationBetween(begin, end, serviceId) ⇒ `PersistedState | null`
- .evolutionRateSince(timestamp, serviceId) ⇒ `number | null`
- - .getAllStatesBetween(begin, end, serviceId) ⇒ `Array[HistoricItem]`
- - .getAllStatesSince(timestamp, serviceId) ⇒ `Array[HistoricItem]`
- - .historicState(timestamp, serviceId) ⇒ `HistoricItem | null`
+ - .evolutionRateUntil(timestamp, serviceId) ⇒ `number | null`
+ - .evolutionRateBetween(begin, end, serviceId) ⇒ `number | null`
+ - .getAllStatesSince(timestamp, serviceId) ⇒ `Array[PersistedItem]`
+ - .getAllStatesUntil(timestamp, serviceId) ⇒ `Array[PersistedItem]`
+ - .getAllStatesBetween(begin, end, serviceId) ⇒ `Array[PersistedItem]`
- .lastUpdate(serviceId) ⇒ `ZonedDateTime | null`
- - .latestState(serviceId) ⇒ `string | null`
- - .maximumBetween(begin, end, serviceId) ⇒ `HistoricItem | null`
- - .maximumSince(timestamp,serviceId) ⇒ `HistoricItem | null`
- - .minimumSince(begin, end, serviceId) ⇒ `HistoricItem | null`
- - .minimumSince(timestamp, serviceId) ⇒ `HistoricItem | null`
+ - .nextUpdate(serviceId) ⇒ `ZonedDateTime | null`
+ - .maximumSince(timestamp,serviceId) ⇒ `PersistedItem | null`
+ - .maximumUntil(timestamp,serviceId) ⇒ `PersistedItem | null`
+ - .maximumBetween(begin, end, serviceId) ⇒ `PersistedItem | null`
+ - .minimumSince(timestamp, serviceId) ⇒ `PersistedItem | null`
+ - .minimumUntil(timestamp, serviceId) ⇒ `PersistedItem | null`
+ - .minimumBetween(begin, end, serviceId) ⇒ `PersistedItem | null`
- .persist(serviceId): Tells the persistence service to store the current Item state, which is then done asynchronously.
**Warning:** This has the side effect, that if the Item state changes shortly after `.persist` has been called, the new Item state will be persisted. See [JSDoc](https://openhab.github.io/openhab-js/items.ItemHistory.html#persist) for a possible work-around.
- - .previousState(skipEqual, serviceId) ⇒ `HistoricItem | null`
- - .sumBetween(begin, end, serviceId) ⇒ `number | null`
- - .sumSince(timestamp, serviceId) ⇒ `number | null`
- - .updatedBetween(begin, end, serviceId) ⇒ `boolean`
+ - .persistedState(timestamp, serviceId) ⇒ `PersistedItem | null`
+ - .previousState(skipEqual, serviceId) ⇒ `PersistedItem | null`
+ - .nextState(skipEqual, serviceId) ⇒ `PersistedItem | null`
+ - .sumSince(timestamp, serviceId) ⇒ `PersistedState | null`
+ - .sumUntil(timestamp, serviceId) ⇒ `PersistedState | null`
+ - .sumBetween(begin, end, serviceId) ⇒ `PersistedState | null`
- .updatedSince(timestamp, serviceId) ⇒ `boolean`
- - .varianceBetween(begin, end, serviceId) ⇒ `number | null`
- - .varianceSince(timestamp, serviceId) ⇒ `number | null`
+ - .updatedUntil(timestamp, serviceId) ⇒ `boolean`
+ - .updatedBetween(begin, end, serviceId) ⇒ `boolean`
+ - .varianceSince(timestamp, serviceId) ⇒ `PersistedState | null`
+ - .varianceUntil(timestamp, serviceId) ⇒ `PersistedState | null`
+ - .varianceBetween(begin, end, serviceId) ⇒ `PersistedState | null`
Note: `serviceId` is optional, if omitted, the default persistence service will be used.
```javascript
var yesterday = new Date(new Date().getTime() - (24 * 60 * 60 * 1000));
var item = items.KitchenDimmer;
-console.log('KitchenDimmer averageSince', item.history.averageSince(yesterday));
+console.log('KitchenDimmer averageSince', item.persistence.averageSince(yesterday));
```
-The `HistoricItem` object contains the following properties, representing Item state and the respective timestamp:
+The `PersistedState` object contains the following properties, representing Item state:
- `state`: State as string
- `numericState`: State as number, if state can be represented as number, or `null` if that's not the case
- `quantityState`: Item state as [`Quantity`](#quantity) or `null` if state is not Quantity-compatible
- `rawState`: State as Java `State` object
+
+The `PersistedItem` object extends `PersistedState` with the following properties, representing Item state and the respective timestamp:
+
- `timestamp`: Timestamp as [`time.ZonedDateTime`](#time)
```javascript
var midnight = time.toZDT('00:00');
-var historic = items.KitchenDimmer.history.maximumSince(midnight);
+var historic = items.KitchenDimmer.persistence.maximumSince(midnight);
console.log('KitchenDimmer maximum was ', historic.state, ' at ', historic.timestamp);
```
-See [openhab-js : ItemHistory](https://openhab.github.io/openhab-js/items.ItemHistory.html) for full API documentation.
+See [openhab-js : ItemPersistence](https://openhab.github.io/openhab-js/items.ItemHistory.html) for full API documentation.
### Things
@@ -822,7 +843,7 @@ Examples:
var now = time.ZonedDateTime.now();
var yesterday = time.ZonedDateTime.now().minusHours(24);
var item = items.Kitchen;
-console.log("averageSince", item.history.averageSince(yesterday));
+console.log("averageSince", item.persistence.averageSince(yesterday));
```
```javascript
diff --git a/src/items/item-history.js b/src/items/item-history.js
deleted file mode 100644
index 42357d48..00000000
--- a/src/items/item-history.js
+++ /dev/null
@@ -1,496 +0,0 @@
-/**
- * @typedef {import('@js-joda/core').ZonedDateTime} time.ZonedDateTime
- * @private
- */
-const time = require('../time');
-const utils = require('../utils');
-/**
- * @typedef {import('../quantity').Quantity} Quantity
- * @private
- */
-const { getQuantity, QuantityError } = require('../quantity');
-const PersistenceExtensions = Java.type('org.openhab.core.persistence.extensions.PersistenceExtensions');
-
-/**
- * Class representing an openHAB HistoricItem
- *
- * @memberof items
- * @hideconstructor
- */
-class HistoricItem {
- /**
- * @param {*} rawHistoricItem {@link https://www.openhab.org/javadoc/latest/org/openhab/core/persistence/historicitem org.openhab.core.persistence.HistoricItem}
- */
- constructor (rawHistoricItem) {
- this.rawHistoricItem = rawHistoricItem;
- /**
- * Raw Java Item state
- * @type {HostState}
- */
- this.rawState = rawHistoricItem.getState();
- }
-
- /**
- * String representation of the Item state.
- * @type {string}
- */
- get state () {
- return this.rawState.toString();
- }
-
- /**
- * Numeric representation of Item state, or `null` if state is not numeric
- * @type {number|null}
- */
- get numericState () {
- const numericState = parseFloat(this.rawState.toString());
- return isNaN(numericState) ? null : numericState;
- }
-
- /**
- * Item state as {@link Quantity} or `null` if state is not Quantity-compatible or Quantity would be unit-less (without unit)
- * @type {Quantity|null}
- */
- get quantityState () {
- try {
- const qty = getQuantity(this.rawState.toString());
- return (qty !== null && qty.symbol !== null) ? qty : null;
- } catch (e) {
- if (e instanceof QuantityError) {
- return null;
- } else {
- throw Error('Failed to create "quantityState": ' + e);
- }
- }
- }
-
- /**
- * Timestamp of persisted Item.
- * @type {time.ZonedDateTime}
- */
- get timestamp () {
- return utils.javaZDTToJsZDT(this.rawHistoricItem.getTimestamp());
- }
-}
-
-function _ZDTOrNull (result) {
- return result === null ? null : time.ZonedDateTime.parse(result.toString());
-}
-
-function _decimalOrNull (result) {
- return result === null ? null : result.toBigDecimal();
-}
-
-function _historicItemOrNull (result) {
- if (result === null) return null;
- return new HistoricItem(result);
-}
-
-function _javaIterableOfJavaHistoricItemsToJsArrayOfHistoricItems (result) {
- if (result === null) return null;
-
- const historicItems = [];
- result.forEach((hi) => {
- const historicItem = _historicItemOrNull(hi);
- if (historicItem !== null) historicItems.push(historicItem);
- });
- return historicItems;
-}
-
-/**
- * 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 {@link https://www.openhab.org/javadoc/latest/org/openhab/core/persistence/extensions/persistenceextensions 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!
- *
- * @memberOf items
- * @hideconstructor
- */
-class ItemHistory {
- constructor (rawItem) {
- this.rawItem = rawItem;
- }
-
- /**
- * Gets the average value of the state of a given Item between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- averageBetween (begin, end, serviceId) {
- return _decimalOrNull(PersistenceExtensions.averageBetween(this.rawItem, ...arguments));
- }
-
- /**
- * Gets the average value of the state of a given Item since a certain point in time.
- *
- * @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));
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- averageSince (timestamp, serviceId) {
- return _decimalOrNull(PersistenceExtensions.averageSince(this.rawItem, ...arguments));
- }
-
- /**
- * Checks if the state of a given Item has changed between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {boolean}
- */
- changedBetween (begin, end, serviceId) {
- return PersistenceExtensions.changedBetween(this.rawItem, ...arguments);
- }
-
- /**
- * Checks if the state of a given Item has changed since a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {boolean}
- */
- changedSince (timestamp, serviceId) {
- return PersistenceExtensions.changedSince(this.rawItem, ...arguments);
- }
-
- /**
- * Gets the number of available historic data points of a given Item between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {number}
- */
- countBetween (begin, end, serviceId) {
- return PersistenceExtensions.countBetween(this.rawItem, ...arguments);
- }
-
- /**
- * Gets the number of available historic data points of a given Item since a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {number}
- */
- countSince (timestamp, serviceId) {
- return PersistenceExtensions.countSince(this.rawItem, ...arguments);
- }
-
- /**
- * Gets the number of changes in historic data points of a given Item between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {number}
- */
- countStateChangesBetween (begin, end, serviceId) {
- return PersistenceExtensions.countStateChangesBetween(this.rawItem, ...arguments);
- }
-
- /**
- * Gets the number of changes in historic data points of a given Item since a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {number}
- */
- countStateChangesSince (timestamp, serviceId) {
- return PersistenceExtensions.countStateChangesSince(this.rawItem, ...arguments);
- }
-
- /**
- * Gets the difference value of the state of a given Item between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- deltaBetween (begin, end, serviceId) {
- return _decimalOrNull(PersistenceExtensions.deltaBetween(this.rawItem, ...arguments));
- }
-
- /**
- * Gets the difference value of the state of a given Item since a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- deltaSince (timestamp, serviceId) {
- return _decimalOrNull(PersistenceExtensions.deltaSince(this.rawItem, ...arguments));
- }
-
- /**
- * Gets the standard deviation of the state of the given Item between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- deviationBetween (begin, end, serviceId) {
- return _decimalOrNull(PersistenceExtensions.deviationBetween(this.rawItem, ...arguments));
- }
-
- /**
- * Gets the standard deviation of the state of the given Item since a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- deviationSince (timestamp, serviceId) {
- return _decimalOrNull(PersistenceExtensions.deviationSince(this.rawItem, ...arguments));
- }
-
- /**
- * Gets the evolution rate of the state of a given Item since a certain point in time.
- *
- * @deprecated Replaced by evolutionRateSince and evolutionRateBetween.
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- evolutionRate (timestamp, serviceId) {
- console.warn('"evolutionRate" is deprecated and will be removed in the future. Use "evolutionRateSince" instead.');
- return _decimalOrNull(PersistenceExtensions.evolutionRate(this.rawItem, ...arguments));
- }
-
- /**
- * Gets the evolution rate of the state of a given Item between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- evolutionRateBetween (begin, end, serviceId) {
- return _decimalOrNull(PersistenceExtensions.evolutionRate(this.rawItem, ...arguments));
- }
-
- /**
- * Gets the evolution rate of the state of a given Item since a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- evolutionRateSince (timestamp, serviceId) {
- return _decimalOrNull(PersistenceExtensions.evolutionRate(this.rawItem, ...arguments));
- }
-
- /**
- * Retrieves the {@link HistoricItems} for for a given Item between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {HistoricItem[]}
- */
- getAllStatesBetween (begin, end, serviceId) {
- return _javaIterableOfJavaHistoricItemsToJsArrayOfHistoricItems(PersistenceExtensions.getAllStatesBetween(this.rawItem, ...arguments));
- }
-
- /**
- * Retrieves the {@link HistoricItems} for for a given Item since a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {HistoricItem[]}
- */
- getAllStatesSince (timestamp, serviceId) {
- return _javaIterableOfJavaHistoricItemsToJsArrayOfHistoricItems(PersistenceExtensions.getAllStatesSince(this.rawItem, ...arguments));
- }
-
- /**
- * Retrieves the historic state for a given Item at a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(HistoricItem | null)} historic item
- */
- historicState (timestamp, serviceId) {
- return _historicItemOrNull(PersistenceExtensions.historicState(this.rawItem, ...arguments));
- }
-
- /**
- * Query the last update time of a given Item.
- *
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(time.ZonedDateTime | null)}
- */
- lastUpdate (serviceId) {
- return _ZDTOrNull(PersistenceExtensions.lastUpdate(this.rawItem, ...arguments));
- }
-
- /**
- * Retrieves the historic Item state for a given Item at the current point in time.
- *
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(string | null)} state
- */
- latestState (serviceId) {
- const result = this.historicState(time.ZonedDateTime.now(), ...arguments);
- return (result === null) ? null : result.state;
- }
-
- /**
- * Gets the state with the maximum value of a given Item between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(HistoricItem | null)} historic item or null
- */
- maximumBetween (begin, end, serviceId) {
- return _historicItemOrNull(PersistenceExtensions.maximumBetween(this.rawItem, ...arguments));
- }
-
- /**
- * Gets the state with the maximum value of a given Item since a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(HistoricItem | null)} historic item or null
- */
- maximumSince (timestamp, serviceId) {
- return _historicItemOrNull(PersistenceExtensions.maximumSince(this.rawItem, ...arguments));
- }
-
- /**
- * Gets the state with the minimum value of a given Item between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(HistoricItem | null)} historic item or null
- */
- minimumBetween (begin, end, serviceId) {
- return _historicItemOrNull(PersistenceExtensions.minimumBetween(this.rawItem, ...arguments));
- }
-
- /**
- * Gets the state with the minimum value of a given Item since a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(HistoricItem | null)} historic item or null
- */
- minimumSince (timestamp, serviceId) {
- return _historicItemOrNull(PersistenceExtensions.minimumSince(this.rawItem, ...arguments));
- }
-
- /**
- * 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:
- * @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
- *
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- */
- persist (serviceId) {
- PersistenceExtensions.persist(this.rawItem, ...arguments);
- }
-
- /**
- * Returns the previous state of a given Item.
- *
- * @param {boolean} [skipEqual] optional, if true, skips equal state values and searches the first state not equal the current state
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(HistoricItem | null)} historic item or null
- */
- previousState (skipEqual, serviceId) {
- return _historicItemOrNull(PersistenceExtensions.previousState(this.rawItem, ...arguments));
- }
-
- /**
- * Gets the sum of the states of a given Item between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- sumBetween (begin, end, serviceId) {
- return _decimalOrNull(PersistenceExtensions.sumBetween(this.rawItem, ...arguments));
- }
-
- /**
- * Gets the sum of the states of a given Item since a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- sumSince (timestamp, serviceId) {
- return _decimalOrNull(PersistenceExtensions.sumSince(this.rawItem, ...arguments));
- }
-
- /**
- * Checks if the state of a given Item has been updated between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {boolean}
- */
- updatedBetween (begin, end, serviceId) {
- return PersistenceExtensions.updatedBetween(this.rawItem, ...arguments);
- }
-
- /**
- * Checks if the state of a given Item has been updated since a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {boolean}
- */
- updatedSince (timestamp, serviceId) {
- return PersistenceExtensions.updatedSince(this.rawItem, ...arguments);
- }
-
- /**
- * Gets the variance of the state of the given Item between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- varianceBetween (begin, end, serviceId) {
- return _decimalOrNull(PersistenceExtensions.varianceBetween(this.rawItem, ...arguments));
- }
-
- /**
- * Gets the variance of the state of the given Item since a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- varianceSince (timestamp, serviceId) {
- return _decimalOrNull(PersistenceExtensions.varianceSince(this.rawItem, ...arguments));
- }
-}
-
-module.exports = {
- ItemHistory,
- HistoricItem
-};
diff --git a/src/items/item-persistence.js b/src/items/item-persistence.js
new file mode 100644
index 00000000..988adc16
--- /dev/null
+++ b/src/items/item-persistence.js
@@ -0,0 +1,730 @@
+/**
+ * @typedef {import('@js-joda/core').ZonedDateTime} time.ZonedDateTime
+ * @private
+ */
+const time = require('../time');
+const utils = require('../utils');
+/**
+ * @typedef {import('../quantity').Quantity} Quantity
+ * @private
+ */
+const { getQuantity, QuantityError } = require('../quantity');
+const PersistenceExtensions = Java.type('org.openhab.core.persistence.extensions.PersistenceExtensions');
+
+/**
+ * Class representing an instance of {@link https://www.openhab.org/javadoc/latest/org/openhab/core/types/state org.openhab.core.types.State}.
+ *
+ * @memberof items
+ * @hideconstructor
+ */
+class PersistedState {
+ #rawState;
+
+ /**
+ * @param {HostState} rawState
+ */
+ constructor (rawState) {
+ this.#rawState = rawState;
+ }
+
+ /**
+ * String representation of the Item state.
+ * @type {string}
+ */
+ get state () {
+ return this.#rawState.toString();
+ }
+
+ /**
+ * Numeric representation of Item state, or `null` if state is not numeric
+ * @type {number|null}
+ */
+ get numericState () {
+ const numericState = parseFloat(this.#rawState.toString());
+ return isNaN(numericState) ? null : numericState;
+ }
+
+ /**
+ * Item state as {@link Quantity} or `null` if state is not Quantity-compatible or Quantity would be unit-less (without unit)
+ * @type {Quantity|null}
+ */
+ get quantityState () {
+ try {
+ const qty = getQuantity(this.#rawState.toString());
+ return (qty !== null && qty.symbol !== null) ? qty : null;
+ } catch (e) {
+ if (e instanceof QuantityError) {
+ return null;
+ } else {
+ throw Error('Failed to create "quantityState": ' + e);
+ }
+ }
+ }
+}
+
+/**
+ * Class representing an instance of {@link https://www.openhab.org/javadoc/latest/org/openhab/core/persistence/historicitem org.openhab.core.persistence.HistoricItem}.
+ * Extends {@link items.PersistedState}.
+ *
+ * @memberof items
+ * @hideconstructor
+ */
+class PersistedItem extends PersistedState {
+ #rawHistoricItem;
+
+ /**
+ * @param {*} rawHistoricItem {@link https://www.openhab.org/javadoc/latest/org/openhab/core/persistence/historicitem org.openhab.core.persistence.HistoricItem}
+ */
+ constructor (rawHistoricItem) {
+ super(rawHistoricItem.getState());
+ this.#rawHistoricItem = rawHistoricItem;
+ }
+
+ /**
+ * Timestamp of persisted Item.
+ * @type {time.ZonedDateTime}
+ */
+ get timestamp () {
+ return utils.javaZDTToJsZDT(this.#rawHistoricItem.getTimestamp());
+ }
+}
+
+function _ZDTOrNull (result) {
+ return result === null ? null : time.ZonedDateTime.parse(result.toString());
+}
+
+function _decimalOrNull (result) {
+ return result === null ? null : result.toBigDecimal();
+}
+
+function _stateOrNull (result) {
+ return result === null ? null : new PersistedState(result);
+}
+
+function _historicItemOrNull (result) {
+ if (result === null) return null;
+ return new PersistedItem(result);
+}
+
+function _javaIterableOfJavaHistoricItemsToJsArrayOfHistoricItems (result) {
+ if (result === null) return null;
+
+ const historicItems = [];
+ result.forEach((hi) => {
+ const historicItem = _historicItemOrNull(hi);
+ if (historicItem !== null) historicItems.push(historicItem);
+ });
+ return historicItems;
+}
+
+/**
+ * Class representing the historic state of an openHAB Item.
+ * Wrapping the {@link https://www.openhab.org/javadoc/latest/org/openhab/core/persistence/extensions/persistenceextensions 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!
+ *
+ * Please note: Several methods return null
if the default persistence service is no queryable persistence service
+ * or the provided serviceId
does not refer to an available queryable persistence service.
+ *
+ * @memberOf items
+ * @hideconstructor
+ */
+class ItemPersistence {
+ constructor (rawItem) {
+ this.rawItem = rawItem;
+ }
+
+ /**
+ * 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:
+ * @example
+ * items.MyItem.persistence.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
+ *
+ * @param {(time.ZonedDateTime | Date)} [timestamp] the date for the item state to be stored
+ * @param {string} [state] the state to be stored
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ */
+ persist (timestamp, state, serviceId) {
+ PersistenceExtensions.persist(this.rawItem, ...arguments);
+ }
+
+ // TODO: Add persist for TimeSeries
+
+ /**
+ * Retrieves the persisted state for a given Item at a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time for which the persisted item should be retrieved
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedItem | null)} the {@link items.PersistedItem} at the given point in time, or null
if no persisted item could be found
+ */
+ persistedState (timestamp, serviceId) {
+ return _historicItemOrNull(PersistenceExtensions.persistedState(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Query the last update time of a given Item.
+ *
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(time.ZonedDateTime | null)} point in time of the last historic update to Item, or null
if there are no historic persisted updates
+ */
+ lastUpdate (serviceId) {
+ return _ZDTOrNull(PersistenceExtensions.lastUpdate(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Query the next update time of a given Item.
+ *
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(time.ZonedDateTime | null)} point in time of the first future update to Item, or null
if there are no future persisted updates
+ */
+ nextUpdate (serviceId) {
+ return _ZDTOrNull(PersistenceExtensions.nextUpdate(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Returns the previous state of a given Item.
+ *
+ * @param {boolean} [skipEqual] optional, if true, skips equal state values and searches the first state not equal the current state
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedItem | null)} the {@link items.PersistedItem} at the given point in time, or null
if no persisted item could be found or null
+ */
+ previousState (skipEqual, serviceId) {
+ return _historicItemOrNull(PersistenceExtensions.previousState(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Returns the next state of a given Item.
+ *
+ * @param {boolean} [skipEqual] optional, if true, skips equal state values and searches the first state not equal the current state
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedItem | null)} the {@link items.PersistedItem} at the given point in time, or null
if no persisted item could be found or null
+ */
+ nextState (skipEqual, serviceId) {
+ return _historicItemOrNull(PersistenceExtensions.nextState(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Checks if the state of a given Item has changed since a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to start the check
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {boolean} true
if item state has changed, false
if it has not changed,
+ * null
if timestamp
is in the future
+ */
+ changedSince (timestamp, serviceId) {
+ return PersistenceExtensions.changedSince(this.rawItem, ...arguments);
+ }
+
+ /**
+ * Checks if the state of a given Item will change by a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to end the check
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {boolean} true
if item state will change, false
if it will not change,
+ * null
if timestamp>
is in the past
+ */
+ changedUntil (timestamp, serviceId) {
+ return PersistenceExtensions.changedUntil(this.rawItem, ...arguments);
+ }
+
+ /**
+ * Checks if the state of a given Item has changed between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the point in time to start the check
+ * @param {(time.ZonedDateTime | Date)} end the point in time to stop the check
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {boolean} true
if item state changes, false
if the item does not change in the given interval,
+ * null
if begin
is after end
+ */
+ changedBetween (begin, end, serviceId) {
+ return PersistenceExtensions.changedBetween(this.rawItem, ...arguments);
+ }
+
+ /**
+ * Checks if the state of a given Item has been updated since a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to start the check
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {boolean} true
if item state was updated, false
if the item has not been updated since timestamp
,
+ * null
if timestamp
is in the future
+ */
+ updatedSince (timestamp, serviceId) {
+ return PersistenceExtensions.updatedSince(this.rawItem, ...arguments);
+ }
+
+ /**
+ * Checks if the state of a given Item will be updated until a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to end the check
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {boolean} true
if item state is updated, false
if the item is not updated until timestamp
,
+ * null
if timestamp
is in the past
+ */
+ updatedUntil (timestamp, serviceId) {
+ return PersistenceExtensions.updatedUntil(this.rawItem, ...arguments);
+ }
+
+ /**
+ * Checks if the state of a given Item has been updated between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the point in time to start the check
+ * @param {(time.ZonedDateTime | Date)} end the point in time to stop the check
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {boolean} true
if item state was updated, false
if the item has not been updated in the given interval,
+ * null
if begin
is after end
+ */
+ updatedBetween (begin, end, serviceId) {
+ return PersistenceExtensions.updatedBetween(this.rawItem, ...arguments);
+ }
+
+ /**
+ * Gets the historic Item with the maximum value of a given Item since a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to start the check
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedItem | null)} a {@link items.PersistedItem} with the maximum state value since the given point in time,
+ * or null
if timestamp
is in the future
+ */
+ maximumSince (timestamp, serviceId) {
+ return _historicItemOrNull(PersistenceExtensions.maximumSince(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Gets the historic Item with the maximum value of a given Item until a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to end the check
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedItem | null)} a {@link items.PersistedItem}m with the maximum state value until the given point in time,
+ * or null
if timestamp
is in the past
+ */
+ maximumUntil (timestamp, serviceId) {
+ return _historicItemOrNull(PersistenceExtensions.maximumUntil(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Gets the historic Item with the maximum value of a given Item between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the point in time to start the check
+ * @param {(time.ZonedDateTime | Date)} end the point in time to stop the check
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedItem | null)} a {@link items.PersistedItem} with the maximum state value between two points in time,
+ * or null
if begin
is after end
+ */
+ maximumBetween (begin, end, serviceId) {
+ return _historicItemOrNull(PersistenceExtensions.maximumBetween(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Gets the historic Item with the minimum value of a given Item since a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to start the check
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedItem | null)} a {@link items.PersistedItem} with the minimum state value since the given point in time,
+ * or null
if timestamp
is in the future
+ */
+ minimumSince (timestamp, serviceId) {
+ return _historicItemOrNull(PersistenceExtensions.minimumSince(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Gets the historic Item with the minimum value of a given Item until a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to end the check
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedItem | null)} a {@link items.PersistedItem} with the minimum state value until the given point in time,
+ * or null
if timestamp
is in the past
+ */
+ minimumUntil (timestamp, serviceId) {
+ return _historicItemOrNull(PersistenceExtensions.minimumUntil(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Gets the state with the minimum value of a given Item between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the point in time to start the check
+ * @param {(time.ZonedDateTime | Date)} end the point in time to stop the check
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedItem | null)} a {@link items.PersistedItem} with the minimum state value between two points in time,
+ * or null
if begin
is after end
+ */
+ minimumBetween (begin, end, serviceId) {
+ return _historicItemOrNull(PersistenceExtensions.minimumBetween(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Gets the variance of the state of the given Item since a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time from which to compute the variance
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the variance between then and now as {@link items.PersistedState}, or null
if
+ * timestamp
is in the future, or if there is no persisted state for the given
+ * Item at the given timestamp
+ */
+ varianceSince (timestamp, serviceId) {
+ return _stateOrNull(PersistenceExtensions.varianceSince(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Gets the variance of the state of the given Item until a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to which to compute the variance
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the variance between now and then as {@link items.PersistedState}, or null
if
+ * timestamp
is in the past, or if there is no persisted state for the given
+ * Item at the given timestamp
+ */
+ varianceUntil (timestamp, serviceId) {
+ return _stateOrNull(PersistenceExtensions.varianceUntil(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Gets the variance of the state of the given Item between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the point in time from which to compute the variance
+ * @param {(time.ZonedDateTime | Date)} end the end time for the computation
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the variance between both points of time as {@link items.PersistedState}, or null
if
+ * begin
is after end
, or if there is no persisted state for the given
+ * Item between begin
and end
+ */
+ varianceBetween (begin, end, serviceId) {
+ return _stateOrNull(PersistenceExtensions.varianceBetween(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Gets the standard deviation of the state of the given Item since a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time from which to compute the standard deviation
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the standard deviation between then and now as {@link items.PersistedState}, or null
+ * if timestamp
is in the future, or if there is no persisted state for the given Item
+ * at the given timestamp
+ */
+ deviationSince (timestamp, serviceId) {
+ return _stateOrNull(PersistenceExtensions.deviationSince(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Gets the standard deviation of the state of the given Item until a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to which to compute the standard deviation
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the standard deviation between now and then as {@link items.PersistedState}, or null
+ * if timestamp
is in the past, or if there is no persisted state for the given Item
+ * at the given timestamp
+ */
+ deviationUntil (timestamp, serviceId) {
+ return _stateOrNull(PersistenceExtensions.deviationUntil(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Gets the standard deviation of the state of the given Item between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the point in time from which to compute
+ * @param {(time.ZonedDateTime | Date)} end the end time for the computation
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the standard deviation between both points of time as {@link items.PersistedState}, or null
+ * if begin
is after end
, or if there is no persisted state for the given Item
+ * between begin
and end
+ */
+ deviationBetween (begin, end, serviceId) {
+ return _stateOrNull(PersistenceExtensions.deviationBetween(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Gets the average value of the state of a given Item since a certain point in time.
+ *
+ * @example
+ * var yesterday = new Date(new Date().getTime() - (24 * 60 * 60 * 1000));
+ * var item = items.getItem('KitchenDimmer');
+ * console.log('KitchenDimmer average since yesterday', item.persistence.averageSince(yesterday));
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time from which to search for the average value
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the average value since timestamp
as {@link items.PersistedState} or null
if no previous states could be found
+ */
+ averageSince (timestamp, serviceId) {
+ return _stateOrNull(PersistenceExtensions.averageSince(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Gets the average value of the state of a given Item until a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to which to search for the average value
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the average value until timestamp
as {@link items.PersistedState} or null
if no future states could be found
+ */
+ averageUntil (timestamp, serviceId) {
+ return _stateOrNull(PersistenceExtensions.averageUntil(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Gets the average value of the state of a given Item between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the point in time from which to start the average
+ * @param {(time.ZonedDateTime | Date)} end the point in time to which to start the average
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the average value between begin
and end
as {@link items.PersistedState} or null
if no states could be found
+ */
+ averageBetween (begin, end, serviceId) {
+ return _stateOrNull(PersistenceExtensions.averageBetween(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Gets the sum of the states of a given Item since a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time from which to start the summation
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the sum of the state values since timestamp
as {@link items.PersistedState}, or null if timestamp
is in the future
+ */
+ sumSince (timestamp, serviceId) {
+ return _stateOrNull(PersistenceExtensions.sumSince(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Gets the sum of the states of a given Item until a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to which to start the summation
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the sum of the state values until timestamp
as {@link items.PersistedState}, or null if timestamp
is in the past
+ */
+ sumUntil (timestamp, serviceId) {
+ return _stateOrNull(PersistenceExtensions.sumUntil(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Gets the sum of the states of a given Item between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the point in time from which to start the summation
+ * @param {(time.ZonedDateTime | Date)} end the point in time to which to start the summation
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the sum of the state values between the given points in time as {@link items.PersistedState},
+ * or null if begin
is after end
+ */
+ sumBetween (begin, end, serviceId) {
+ return _stateOrNull(PersistenceExtensions.sumBetween(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Gets the difference value of the state of a given Item since a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time from which to compute the delta
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the difference between now and then as {@link items.PersistedState}, or null
+ * if there is no persisted state for the given Item at the given timestamp
available
+ */
+ deltaSince (timestamp, serviceId) {
+ return _stateOrNull(PersistenceExtensions.deltaSince(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Gets the difference value of the state of a given Item until a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to which to compute the delta
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the difference between then and now as {@link items.PersistedState}, or null
+ * if there is no persisted state for the given Item at the given timestamp
available
+ */
+ deltaUntil (timestamp, serviceId) {
+ return _stateOrNull(PersistenceExtensions.deltaUntil(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Gets the difference value of the state of a given Item between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the beginning point in time
+ * @param {(time.ZonedDateTime | Date)} end the end point in time
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the difference between end and begin as {@link items.PersistedState}, or null
+ * if there is no persisted state for the given Item for the given points in time
+ */
+ deltaBetween (begin, end, serviceId) {
+ return _stateOrNull(PersistenceExtensions.deltaBetween(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Gets the evolution rate of the state of a given Item since a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time from which to compute the evolution rate
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(number | null)} the evolution rate in percent (positive and negative) between then and now, or null
+ * if there is no persisted state for the given Item at the given timestamp
,
+ * or if there is a state, but it is zero (which would cause a divide-by-zero error)
+ */
+ evolutionRateSince (timestamp, serviceId) {
+ return _decimalOrNull(PersistenceExtensions.evolutionRateSince(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Gets the evolution rate of the state of a given Item until a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to which to compute the evolution rate
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(number | null)} the evolution rate in percent (positive and negative) between then and now, or null
+ * if there is no persisted state for the given Item at the given timestamp
,
+ * or if there is a state, but it is zero (which would cause a divide-by-zero error)
+ */
+ evolutionRateUntil (timestamp, serviceId) {
+ return _decimalOrNull(PersistenceExtensions.evolutionRateUntil(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Gets the evolution rate of the state of a given Item between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the beginning point in time
+ * @param {(time.ZonedDateTime | Date)} end the end point in time
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(number | null)} the evolution rate in percent (positive and negative) in the given interval, or null
+ * if there are no persisted states for the given Item at the given interval, or if there is a state,
+ * but it is zero (which would cause a divide-by-zero error)
+ */
+ evolutionRateBetween (begin, end, serviceId) {
+ return _decimalOrNull(PersistenceExtensions.evolutionRateBetween(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Gets the number of available historic data points of a given Item since a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the beginning point in time
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {number} the number of values persisted for this item, null
if timestamp
is in the future
+ */
+ countSince (timestamp, serviceId) {
+ return PersistenceExtensions.countSince(this.rawItem, ...arguments);
+ }
+
+ /**
+ * Gets the number of available data points of a given Item until a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the ending point in time
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {number} the number of values persisted for this item, null
if timestamp
is in the past
+ */
+ countUntil (timestamp, serviceId) {
+ return PersistenceExtensions.countUntil(this.rawItem, ...arguments);
+ }
+
+ /**
+ * Gets the number of available data points of a given Item between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the beginning point in time
+ * @param {(time.ZonedDateTime | Date)} end the end point in time
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {number} the number of values persisted for this item, null
if begin
is after end
+ */
+ countBetween (begin, end, serviceId) {
+ return PersistenceExtensions.countBetween(this.rawItem, ...arguments);
+ }
+
+ /**
+ * Gets the number of changes in historic data points of a given Item since a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the beginning point in time
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {number} the number of state changes for this item
+ */
+ countStateChangesSince (timestamp, serviceId) {
+ return PersistenceExtensions.countStateChangesSince(this.rawItem, ...arguments);
+ }
+
+ /**
+ * Gets the number of changes in data points of a given Item until a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the ending point in time
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {number} the number of state changes for this item
+ */
+ countStateChangesUntil (timestamp, serviceId) {
+ return PersistenceExtensions.countStateChangesUntil(this.rawItem, ...arguments);
+ }
+
+ /**
+ * Gets the number of changes in data points of a given Item between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the beginning point in time
+ * @param {(time.ZonedDateTime | Date)} end the end point in time
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {number} the number of state changes for this item
+ */
+ countStateChangesBetween (begin, end, serviceId) {
+ return PersistenceExtensions.countStateChangesBetween(this.rawItem, ...arguments);
+ }
+
+ /**
+ * Retrieves the historic Items for a given Item since a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time from which to retrieve the states
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {PersistedItem[]} the {@link items.PersistedItem}s since the given point in time
+ */
+ getAllStatesSince (timestamp, serviceId) {
+ return _javaIterableOfJavaHistoricItemsToJsArrayOfHistoricItems(PersistenceExtensions.getAllStatesSince(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Retrieves the future Items for a given Item until a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to which to retrieve the states
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {PersistedItem[]} the future {@link items.PersistedItem}s to the given point in time
+ */
+ getAllStatesUntil (timestamp, serviceId) {
+ return _javaIterableOfJavaHistoricItemsToJsArrayOfHistoricItems(PersistenceExtensions.getAllStatesUntil(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Retrieves the historic Items for a given Item between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the point in time from which to retrieve the states
+ * @param {(time.ZonedDateTime | Date)} end the point in time to which to retrieve the states
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {PersistedItem[]} the historic {@link items.PersistedItem}s between the given points in time,
+ */
+ getAllStatesBetween (begin, end, serviceId) {
+ return _javaIterableOfJavaHistoricItemsToJsArrayOfHistoricItems(PersistenceExtensions.getAllStatesBetween(this.rawItem, ...arguments));
+ }
+
+ /**
+ * Removes from persistence the historic items for a given Item since a certain point in time.
+ * This will only have effect if the persistence service is a modifiable persistence service.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time from which to remove the states
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ */
+ removeAllStatesSince (timestamp, serviceId) {
+ return PersistenceExtensions.removeAllStatesSince(this.rawItem, ...arguments);
+ }
+
+ /**
+ * Removes from persistence the future items for a given Item until a certain point in time.
+ * This will only have effect if the persistence service is a modifiable persistence service.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to which to remove the states
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ */
+ removeAllStatesUntil (timestamp, serviceId) {
+ return PersistenceExtensions.removeAllStatesUntil(this.rawItem, ...arguments);
+ }
+
+ /**
+ * Removes from persistence the historic items for a given Item between two certain points in time.
+ * This will only have effect if the persistence service is a modifiable persistence service.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the point in time from which to remove the states
+ * @param {(time.ZonedDateTime | Date)} end the point in time to which to remove the states
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ */
+ removeAllStatesBetween (begin, end, serviceId) {
+ return PersistenceExtensions.removeAllStatesBetween(this.rawItem, ...arguments);
+ }
+}
+
+module.exports = {
+ ItemPersistence,
+ PersistedItem
+};
diff --git a/src/items/items.js b/src/items/items.js
index b214d261..a1a5e900 100644
--- a/src/items/items.js
+++ b/src/items/items.js
@@ -8,7 +8,7 @@ const osgi = require('../osgi');
const utils = require('../utils');
const log = require('../log')('items');
const metadata = require('./metadata/metadata');
-const { ItemHistory } = require('./item-history');
+const { ItemPersistence } = require('./item-persistence');
const ItemSemantics = require('./item-semantics');
const { getQuantity, QuantityError } = require('../quantity');
@@ -96,10 +96,10 @@ class Item {
this.rawItem = rawItem;
/**
- * Access historical states for this Item {@link items.ItemHistory}
- * @type {ItemHistory}
+ * Access historical states for this Item {@link items.ItemPersistence}
+ * @type {ItemPersistence}
*/
- this.history = new ItemHistory(rawItem);
+ this.persistence = new ItemPersistence(rawItem);
/**
* Access Semantic information of this Item {@link items.ItemSemantics}
diff --git a/src/rules/rules.js b/src/rules/rules.js
index fe13b32d..96d0257b 100644
--- a/src/rules/rules.js
+++ b/src/rules/rules.js
@@ -320,7 +320,7 @@ function SwitchableJSRule (ruleConfig) {
// possibly load item's prior state
let historicState = null;
try {
- historicState = item.history.latestState();
+ historicState = item.persistence.latestState();
} catch (e) {
log.warn(`Failed to get historic state of ${item.name} for rule ${ruleConfig.name}: ${e}`);
}
diff --git a/types/items/item-history.d.ts b/types/items/item-history.d.ts
deleted file mode 100644
index 0b9d9f00..00000000
--- a/types/items/item-history.d.ts
+++ /dev/null
@@ -1,338 +0,0 @@
-export type Quantity = import('../quantity').Quantity;
-/**
- * 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 {@link https://www.openhab.org/javadoc/latest/org/openhab/core/persistence/extensions/persistenceextensions 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!
- *
- * @memberOf items
- * @hideconstructor
- */
-export class ItemHistory {
- constructor(rawItem: any);
- rawItem: any;
- /**
- * Gets the average value of the state of a given Item between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- averageBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (number | null);
- /**
- * Gets the average value of the state of a given Item since a certain point in time.
- *
- * @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));
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- averageSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (number | null);
- /**
- * Checks if the state of a given Item has changed between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {boolean}
- */
- changedBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): boolean;
- /**
- * Checks if the state of a given Item has changed since a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {boolean}
- */
- changedSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): boolean;
- /**
- * Gets the number of available historic data points of a given Item between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {number}
- */
- countBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): number;
- /**
- * Gets the number of available historic data points of a given Item since a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {number}
- */
- countSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): number;
- /**
- * Gets the number of changes in historic data points of a given Item between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {number}
- */
- countStateChangesBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): number;
- /**
- * Gets the number of changes in historic data points of a given Item since a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {number}
- */
- countStateChangesSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): number;
- /**
- * Gets the difference value of the state of a given Item between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- deltaBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (number | null);
- /**
- * Gets the difference value of the state of a given Item since a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- deltaSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (number | null);
- /**
- * Gets the standard deviation of the state of the given Item between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- deviationBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (number | null);
- /**
- * Gets the standard deviation of the state of the given Item since a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- deviationSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (number | null);
- /**
- * Gets the evolution rate of the state of a given Item since a certain point in time.
- *
- * @deprecated Replaced by evolutionRateSince and evolutionRateBetween.
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- evolutionRate(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (number | null);
- /**
- * Gets the evolution rate of the state of a given Item between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- evolutionRateBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (number | null);
- /**
- * Gets the evolution rate of the state of a given Item since a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- evolutionRateSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (number | null);
- /**
- * Retrieves the {@link HistoricItems} for for a given Item between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {HistoricItem[]}
- */
- getAllStatesBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): HistoricItem[];
- /**
- * Retrieves the {@link HistoricItems} for for a given Item since a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {HistoricItem[]}
- */
- getAllStatesSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): HistoricItem[];
- /**
- * Retrieves the historic state for a given Item at a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(HistoricItem | null)} historic item
- */
- historicState(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (HistoricItem | null);
- /**
- * Query the last update time of a given Item.
- *
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(time.ZonedDateTime | null)}
- */
- lastUpdate(serviceId?: string, ...args: any[]): (time.ZonedDateTime | null);
- /**
- * Retrieves the historic Item state for a given Item at the current point in time.
- *
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(string | null)} state
- */
- latestState(serviceId?: string, ...args: any[]): (string | null);
- /**
- * Gets the state with the maximum value of a given Item between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(HistoricItem | null)} historic item or null
- */
- maximumBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (HistoricItem | null);
- /**
- * Gets the state with the maximum value of a given Item since a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(HistoricItem | null)} historic item or null
- */
- maximumSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (HistoricItem | null);
- /**
- * Gets the state with the minimum value of a given Item between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(HistoricItem | null)} historic item or null
- */
- minimumBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (HistoricItem | null);
- /**
- * Gets the state with the minimum value of a given Item since a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(HistoricItem | null)} historic item or null
- */
- minimumSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (HistoricItem | null);
- /**
- * 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:
- * @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
- *
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- */
- persist(serviceId?: string, ...args: any[]): void;
- /**
- * Returns the previous state of a given Item.
- *
- * @param {boolean} [skipEqual] optional, if true, skips equal state values and searches the first state not equal the current state
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(HistoricItem | null)} historic item or null
- */
- previousState(skipEqual?: boolean, serviceId?: string, ...args: any[]): (HistoricItem | null);
- /**
- * Gets the sum of the states of a given Item between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- sumBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (number | null);
- /**
- * Gets the sum of the states of a given Item since a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- sumSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (number | null);
- /**
- * Checks if the state of a given Item has been updated between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {boolean}
- */
- updatedBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): boolean;
- /**
- * Checks if the state of a given Item has been updated since a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {boolean}
- */
- updatedSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): boolean;
- /**
- * Gets the variance of the state of the given Item between two certain points in time.
- *
- * @param {(time.ZonedDateTime | Date)} begin begin
- * @param {(time.ZonedDateTime | Date)} end end
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- varianceBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (number | null);
- /**
- * Gets the variance of the state of the given Item since a certain point in time.
- *
- * @param {(time.ZonedDateTime | Date)} timestamp
- * @param {string} [serviceId] Optional persistence service ID, if omitted, the default persistence service will be used.
- * @returns {(number | null)}
- */
- varianceSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (number | null);
-}
-/**
- * Class representing an openHAB HistoricItem
- *
- * @memberof items
- * @hideconstructor
- */
-export class HistoricItem {
- /**
- * @param {*} rawHistoricItem {@link https://www.openhab.org/javadoc/latest/org/openhab/core/persistence/historicitem org.openhab.core.persistence.HistoricItem}
- */
- constructor(rawHistoricItem: any);
- rawHistoricItem: any;
- /**
- * Raw Java Item state
- * @type {HostState}
- */
- rawState: HostState;
- /**
- * String representation of the Item state.
- * @type {string}
- */
- get state(): string;
- /**
- * Numeric representation of Item state, or `null` if state is not numeric
- * @type {number|null}
- */
- get numericState(): number;
- /**
- * Item state as {@link Quantity} or `null` if state is not Quantity-compatible or Quantity would be unit-less (without unit)
- * @type {Quantity|null}
- */
- get quantityState(): import("../quantity").Quantity;
- /**
- * Timestamp of persisted Item.
- * @type {time.ZonedDateTime}
- */
- get timestamp(): JSJoda.ZonedDateTime;
-}
-declare namespace time {
- type ZonedDateTime = import('@js-joda/core').ZonedDateTime;
-}
-import time = require("../time");
-export {};
-//# sourceMappingURL=item-history.d.ts.map
\ No newline at end of file
diff --git a/types/items/item-history.d.ts.map b/types/items/item-history.d.ts.map
deleted file mode 100644
index 37205360..00000000
--- a/types/items/item-history.d.ts.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"item-history.d.ts","sourceRoot":"","sources":["../../src/items/item-history.js"],"names":[],"mappings":"uBAOa,OAAO,aAAa,EAAE,QAAQ;AA4F3C;;;;;;;;;GASG;AACH;IACE,0BAEC;IADC,aAAsB;IAGxB;;;;;;;OAOG;IACH,sBALW,CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,OAC3B,CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,cAC3B,MAAM,mBACJ,CAAC,MAAM,GAAG,IAAI,CAAC,CAI3B;IAED;;;;;;;;;;;OAWG;IACH,wBAJW,CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,cAC3B,MAAM,mBACJ,CAAC,MAAM,GAAG,IAAI,CAAC,CAI3B;IAED;;;;;;;OAOG;IACH,sBALW,CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,OAC3B,CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,cAC3B,MAAM,mBACJ,OAAO,CAInB;IAED;;;;;;OAMG;IACH,wBAJW,CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,cAC3B,MAAM,mBACJ,OAAO,CAInB;IAED;;;;;;;OAOG;IACH,oBALW,CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,OAC3B,CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,cAC3B,MAAM,mBACJ,MAAM,CAIlB;IAED;;;;;;OAMG;IACH,sBAJW,CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,cAC3B,MAAM,mBACJ,MAAM,CAIlB;IAED;;;;;;;OAOG;IACH,gCALW,CAAC,KAAK,aAAa,GAAG,IAAI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KAAK,aAAa,GAAG,IAAI,CAAC,OAC3B,CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,cAC3B,MAAM,mBACJ,CAAC,MAAM,GAAG,IAAI,CAAC,CAI3B;IAED;;;;;;OAMG;IACH,oBAJW,CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,cAC3B,MAAM,mBACJ,CAAC,MAAM,GAAG,IAAI,CAAC,CAI3B;IAED;;;;;;;OAOG;IACH,sBALW,CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,OAC3B,CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,cAC3B,MAAM,mBACJ,OAAO,CAInB;IAED;;;;;;OAMG;IACH,wBAJW,CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,cAC3B,MAAM,mBACJ,OAAO,CAInB;IAED;;;;;;;OAOG;IACH,uBALW,CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,OAC3B,CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,cAC3B,MAAM,mBACJ,CAAC,MAAM,GAAG,IAAI,CAAC,CAI3B;IAED;;;;;;OAMG;IACH,yBAJW,CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,cAC3B,MAAM,mBACJ,CAAC,MAAM,GAAG,IAAI,CAAC,CAI3B;CACF;AA7dD;;;;;GAKG;AACH;IACE;;OAEG;IACH,kCAOC;IANC,qBAAsC;IACtC;;;OAGG;IACH,oBAA0C;IAG5C;;;OAGG;IACH,oBAEC;IAED;;;OAGG;IACH,2BAGC;IAED;;;OAGG;IACH,oDAWC;IAED;;;OAGG;IACH,sCAEC;CACF;;yBAxEY,OAAO,eAAe,EAAE,aAAa"}
\ No newline at end of file
diff --git a/types/items/item-persistence.d.ts b/types/items/item-persistence.d.ts
new file mode 100644
index 00000000..cb8849af
--- /dev/null
+++ b/types/items/item-persistence.d.ts
@@ -0,0 +1,509 @@
+export type Quantity = import('../quantity').Quantity;
+/**
+ * Class representing the historic state of an openHAB Item.
+ * Wrapping the {@link https://www.openhab.org/javadoc/latest/org/openhab/core/persistence/extensions/persistenceextensions 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!
+ *
+ * Please note: Several methods return null
if the default persistence service is no queryable persistence service
+ * or the provided serviceId
does not refer to an available queryable persistence service.
+ *
+ * @memberOf items
+ * @hideconstructor
+ */
+export class ItemPersistence {
+ constructor(rawItem: any);
+ rawItem: any;
+ /**
+ * 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:
+ * @example
+ * items.MyItem.persistence.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
+ *
+ * @param {(time.ZonedDateTime | Date)} [timestamp] the date for the item state to be stored
+ * @param {string} [state] the state to be stored
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ */
+ persist(timestamp?: (time.ZonedDateTime | Date), state?: string, serviceId?: string, ...args: any[]): void;
+ /**
+ * Retrieves the persisted state for a given Item at a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time for which the persisted item should be retrieved
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedItem | null)} the {@link items.PersistedItem} at the given point in time, or null
if no persisted item could be found
+ */
+ persistedState(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (PersistedItem | null);
+ /**
+ * Query the last update time of a given Item.
+ *
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(time.ZonedDateTime | null)} point in time of the last historic update to Item, or null
if there are no historic persisted updates
+ */
+ lastUpdate(serviceId?: string, ...args: any[]): (time.ZonedDateTime | null);
+ /**
+ * Query the next update time of a given Item.
+ *
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(time.ZonedDateTime | null)} point in time of the first future update to Item, or null
if there are no future persisted updates
+ */
+ nextUpdate(serviceId?: string, ...args: any[]): (time.ZonedDateTime | null);
+ /**
+ * Returns the previous state of a given Item.
+ *
+ * @param {boolean} [skipEqual] optional, if true, skips equal state values and searches the first state not equal the current state
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedItem | null)} the {@link items.PersistedItem} at the given point in time, or null
if no persisted item could be found or null
+ */
+ previousState(skipEqual?: boolean, serviceId?: string, ...args: any[]): (PersistedItem | null);
+ /**
+ * Returns the next state of a given Item.
+ *
+ * @param {boolean} [skipEqual] optional, if true, skips equal state values and searches the first state not equal the current state
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedItem | null)} the {@link items.PersistedItem} at the given point in time, or null
if no persisted item could be found or null
+ */
+ nextState(skipEqual?: boolean, serviceId?: string, ...args: any[]): (PersistedItem | null);
+ /**
+ * Checks if the state of a given Item has changed since a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to start the check
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {boolean} true
if item state has changed, false
if it has not changed,
+ * null
if timestamp
is in the future
+ */
+ changedSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): boolean;
+ /**
+ * Checks if the state of a given Item will change by a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to end the check
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {boolean} true
if item state will change, false
if it will not change,
+ * null
if timestamp>
is in the past
+ */
+ changedUntil(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): boolean;
+ /**
+ * Checks if the state of a given Item has changed between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the point in time to start the check
+ * @param {(time.ZonedDateTime | Date)} end the point in time to stop the check
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {boolean} true
if item state changes, false
if the item does not change in the given interval,
+ * null
if begin
is after end
+ */
+ changedBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): boolean;
+ /**
+ * Checks if the state of a given Item has been updated since a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to start the check
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {boolean} true
if item state was updated, false
if the item has not been updated since timestamp
,
+ * null
if timestamp
is in the future
+ */
+ updatedSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): boolean;
+ /**
+ * Checks if the state of a given Item will be updated until a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to end the check
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {boolean} true
if item state is updated, false
if the item is not updated until timestamp
,
+ * null
if timestamp
is in the past
+ */
+ updatedUntil(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): boolean;
+ /**
+ * Checks if the state of a given Item has been updated between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the point in time to start the check
+ * @param {(time.ZonedDateTime | Date)} end the point in time to stop the check
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {boolean} true
if item state was updated, false
if the item has not been updated in the given interval,
+ * null
if begin
is after end
+ */
+ updatedBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): boolean;
+ /**
+ * Gets the historic Item with the maximum value of a given Item since a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to start the check
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedItem | null)} a {@link items.PersistedItem} with the maximum state value since the given point in time,
+ * or null
if timestamp
is in the future
+ */
+ maximumSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (PersistedItem | null);
+ /**
+ * Gets the historic Item with the maximum value of a given Item until a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to end the check
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedItem | null)} a {@link items.PersistedItem}m with the maximum state value until the given point in time,
+ * or null
if timestamp
is in the past
+ */
+ maximumUntil(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (PersistedItem | null);
+ /**
+ * Gets the historic Item with the maximum value of a given Item between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the point in time to start the check
+ * @param {(time.ZonedDateTime | Date)} end the point in time to stop the check
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedItem | null)} a {@link items.PersistedItem} with the maximum state value between two points in time,
+ * or null
if begin
is after end
+ */
+ maximumBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (PersistedItem | null);
+ /**
+ * Gets the historic Item with the minimum value of a given Item since a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to start the check
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedItem | null)} a {@link items.PersistedItem} with the minimum state value since the given point in time,
+ * or null
if timestamp
is in the future
+ */
+ minimumSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (PersistedItem | null);
+ /**
+ * Gets the historic Item with the minimum value of a given Item until a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to end the check
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedItem | null)} a {@link items.PersistedItem} with the minimum state value until the given point in time,
+ * or null
if timestamp
is in the past
+ */
+ minimumUntil(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (PersistedItem | null);
+ /**
+ * Gets the state with the minimum value of a given Item between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the point in time to start the check
+ * @param {(time.ZonedDateTime | Date)} end the point in time to stop the check
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedItem | null)} a {@link items.PersistedItem} with the minimum state value between two points in time,
+ * or null
if begin
is after end
+ */
+ minimumBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (PersistedItem | null);
+ /**
+ * Gets the variance of the state of the given Item since a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time from which to compute the variance
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the variance between then and now as {@link items.PersistedState}, or null
if
+ * timestamp
is in the future, or if there is no persisted state for the given
+ * Item at the given timestamp
+ */
+ varianceSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (PersistedState | null);
+ /**
+ * Gets the variance of the state of the given Item until a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to which to compute the variance
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the variance between now and then as {@link items.PersistedState}, or null
if
+ * timestamp
is in the past, or if there is no persisted state for the given
+ * Item at the given timestamp
+ */
+ varianceUntil(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (PersistedState | null);
+ /**
+ * Gets the variance of the state of the given Item between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the point in time from which to compute the variance
+ * @param {(time.ZonedDateTime | Date)} end the end time for the computation
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the variance between both points of time as {@link items.PersistedState}, or null
if
+ * begin
is after end
, or if there is no persisted state for the given
+ * Item between begin
and end
+ */
+ varianceBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (PersistedState | null);
+ /**
+ * Gets the standard deviation of the state of the given Item since a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time from which to compute the standard deviation
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the standard deviation between then and now as {@link items.PersistedState}, or null
+ * if timestamp
is in the future, or if there is no persisted state for the given Item
+ * at the given timestamp
+ */
+ deviationSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (PersistedState | null);
+ /**
+ * Gets the standard deviation of the state of the given Item until a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to which to compute the standard deviation
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the standard deviation between now and then as {@link items.PersistedState}, or null
+ * if timestamp
is in the past, or if there is no persisted state for the given Item
+ * at the given timestamp
+ */
+ deviationUntil(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (PersistedState | null);
+ /**
+ * Gets the standard deviation of the state of the given Item between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the point in time from which to compute
+ * @param {(time.ZonedDateTime | Date)} end the end time for the computation
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the standard deviation between both points of time as {@link items.PersistedState}, or null
+ * if begin
is after end
, or if there is no persisted state for the given Item
+ * between begin
and end
+ */
+ deviationBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (PersistedState | null);
+ /**
+ * Gets the average value of the state of a given Item since a certain point in time.
+ *
+ * @example
+ * var yesterday = new Date(new Date().getTime() - (24 * 60 * 60 * 1000));
+ * var item = items.getItem('KitchenDimmer');
+ * console.log('KitchenDimmer average since yesterday', item.persistence.averageSince(yesterday));
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time from which to search for the average value
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the average value since timestamp
as {@link items.PersistedState} or null
if no previous states could be found
+ */
+ averageSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (PersistedState | null);
+ /**
+ * Gets the average value of the state of a given Item until a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to which to search for the average value
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the average value until timestamp
as {@link items.PersistedState} or null
if no future states could be found
+ */
+ averageUntil(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (PersistedState | null);
+ /**
+ * Gets the average value of the state of a given Item between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the point in time from which to start the average
+ * @param {(time.ZonedDateTime | Date)} end the point in time to which to start the average
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the average value between begin
and end
as {@link items.PersistedState} or null
if no states could be found
+ */
+ averageBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (PersistedState | null);
+ /**
+ * Gets the sum of the states of a given Item since a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time from which to start the summation
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the sum of the state values since timestamp
as {@link items.PersistedState}, or null if timestamp
is in the future
+ */
+ sumSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (PersistedState | null);
+ /**
+ * Gets the sum of the states of a given Item until a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to which to start the summation
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the sum of the state values until timestamp
as {@link items.PersistedState}, or null if timestamp
is in the past
+ */
+ sumUntil(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (PersistedState | null);
+ /**
+ * Gets the sum of the states of a given Item between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the point in time from which to start the summation
+ * @param {(time.ZonedDateTime | Date)} end the point in time to which to start the summation
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the sum of the state values between the given points in time as {@link items.PersistedState},
+ * or null if begin
is after end
+ */
+ sumBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (PersistedState | null);
+ /**
+ * Gets the difference value of the state of a given Item since a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time from which to compute the delta
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the difference between now and then as {@link items.PersistedState}, or null
+ * if there is no persisted state for the given Item at the given timestamp
available
+ */
+ deltaSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (PersistedState | null);
+ /**
+ * Gets the difference value of the state of a given Item until a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to which to compute the delta
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the difference between then and now as {@link items.PersistedState}, or null
+ * if there is no persisted state for the given Item at the given timestamp
available
+ */
+ deltaUntil(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (PersistedState | null);
+ /**
+ * Gets the difference value of the state of a given Item between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the beginning point in time
+ * @param {(time.ZonedDateTime | Date)} end the end point in time
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(PersistedState | null)} the difference between end and begin as {@link items.PersistedState}, or null
+ * if there is no persisted state for the given Item for the given points in time
+ */
+ deltaBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (PersistedState | null);
+ /**
+ * Gets the evolution rate of the state of a given Item since a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time from which to compute the evolution rate
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(number | null)} the evolution rate in percent (positive and negative) between then and now, or null
+ * if there is no persisted state for the given Item at the given timestamp
,
+ * or if there is a state but it is zero (which would cause a divide-by-zero error)
+ */
+ evolutionRateSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (number | null);
+ /**
+ * Gets the evolution rate of the state of a given Item until a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to which to compute the evolution rate
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(number | null)} the evolution rate in percent (positive and negative) between then and now, or null
+ * if there is no persisted state for the given Item at the given timestamp
,
+ * or if there is a state but it is zero (which would cause a divide-by-zero error)
+ */
+ evolutionRateUntil(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (number | null);
+ /**
+ * Gets the evolution rate of the state of a given Item between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the beginning point in time
+ * @param {(time.ZonedDateTime | Date)} end the end point in time
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {(number | null)} the evolution rate in percent (positive and negative) in the given interval, or null
+ * if there are no persisted states for the given Item at the given interval, or if there is a state #
+ * but it is zero (which would cause a divide-by-zero error)
+ */
+ evolutionRateBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): (number | null);
+ /**
+ * Gets the number of available historic data points of a given Item since a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the beginning point in time
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {number} the number of values persisted for this item, null
if timestamp
is in the future
+ */
+ countSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): number;
+ /**
+ * Gets the number of available data points of a given Item until a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the ending point in time
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {number} the number of values persisted for this item, null
if timestamp
is in the past
+ */
+ countUntil(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): number;
+ /**
+ * Gets the number of available data points of a given Item between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the beginning point in time
+ * @param {(time.ZonedDateTime | Date)} end the end point in time
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {number} the number of values persisted for this item, null
if begin
is after end
+ */
+ countBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): number;
+ /**
+ * Gets the number of changes in historic data points of a given Item since a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the beginning point in time
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {number} the number of state changes for this item
+ */
+ countStateChangesSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): number;
+ /**
+ * Gets the number of changes in data points of a given Item until a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the ending point in time
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {number} the number of state changes for this item
+ */
+ countStateChangesUntil(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): number;
+ /**
+ * Gets the number of changes in data points of a given Item between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the beginning point in time
+ * @param {(time.ZonedDateTime | Date)} end the end point in time
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {number} the number of state changes for this item
+ */
+ countStateChangesBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): number;
+ /**
+ * Retrieves the historic Items for a given Item since a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time from which to retrieve the states
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {PersistedItem[]} the {@link items.PersistedItem}s since the given point in time
+ */
+ getAllStatesSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): PersistedItem[];
+ /**
+ * Retrieves the future Items for a given Item until a certain point in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to which to retrieve the states
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {PersistedItem[]} the future {@link items.PersistedItem}s to the given point in time
+ */
+ getAllStatesUntil(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): PersistedItem[];
+ /**
+ * Retrieves the historic Items for a given Item between two certain points in time.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the point in time from which to retrieve the states
+ * @param {(time.ZonedDateTime | Date)} end the point in time to which to retrieve the states
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ * @returns {PersistedItem[]} the historic {@link items.PersistedItem}s between the given points in time,
+ */
+ getAllStatesBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): PersistedItem[];
+ /**
+ * Removes from persistence the historic items for a given Item since a certain point in time.
+ * This will only have effect if the persistence service is a modifiable persistence service.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time from which to remove the states
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ */
+ removeAllStatesSince(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): any;
+ /**
+ * Removes from persistence the future items for a given Item until a certain point in time.
+ * This will only have effect if the persistence service is a modifiable persistence service.
+ *
+ * @param {(time.ZonedDateTime | Date)} timestamp the point in time to which to remove the states
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ */
+ removeAllStatesUntil(timestamp: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): any;
+ /**
+ * Removes from persistence the historic items for a given Item between two certain points in time.
+ * This will only have effect if the persistence service is a modifiable persistence service.
+ *
+ * @param {(time.ZonedDateTime | Date)} begin the point in time from which to remove the states
+ * @param {(time.ZonedDateTime | Date)} end the point in time to which to remove the states
+ * @param {string} [serviceId] optional persistence service ID, if omitted, the default persistence service will be used
+ */
+ removeAllStatesBetween(begin: (time.ZonedDateTime | Date), end: (time.ZonedDateTime | Date), serviceId?: string, ...args: any[]): any;
+}
+/**
+ * Class representing an instance of {@link https://www.openhab.org/javadoc/latest/org/openhab/core/persistence/historicitem org.openhab.core.persistence.HistoricItem}.
+ * Extends {@link items.PersistedState}.
+ *
+ * @memberof items
+ * @hideconstructor
+ */
+export class PersistedItem extends PersistedState {
+ /**
+ * Timestamp of persisted Item.
+ * @type {time.ZonedDateTime}
+ */
+ get timestamp(): JSJoda.ZonedDateTime;
+ #private;
+}
+declare namespace time {
+ type ZonedDateTime = import('@js-joda/core').ZonedDateTime;
+}
+import time = require("../time");
+/**
+ * Class representing an instance of {@link https://www.openhab.org/javadoc/latest/org/openhab/core/types/state org.openhab.core.types.State}.
+ *
+ * @memberof items
+ * @hideconstructor
+ */
+declare class PersistedState {
+ /**
+ * @param {HostState} rawState
+ */
+ constructor(rawState: HostState);
+ /**
+ * String representation of the Item state.
+ * @type {string}
+ */
+ get state(): string;
+ /**
+ * Numeric representation of Item state, or `null` if state is not numeric
+ * @type {number|null}
+ */
+ get numericState(): number;
+ /**
+ * Item state as {@link Quantity} or `null` if state is not Quantity-compatible or Quantity would be unit-less (without unit)
+ * @type {Quantity|null}
+ */
+ get quantityState(): import("../quantity").Quantity;
+ #private;
+}
+export {};
+//# sourceMappingURL=item-persistence.d.ts.map
\ No newline at end of file
diff --git a/types/items/item-persistence.d.ts.map b/types/items/item-persistence.d.ts.map
new file mode 100644
index 00000000..0c0de66b
--- /dev/null
+++ b/types/items/item-persistence.d.ts.map
@@ -0,0 +1 @@
+{"version":3,"file":"item-persistence.d.ts","sourceRoot":"","sources":["../../src/items/item-persistence.js"],"names":[],"mappings":"uBAOa,OAAO,aAAa,EAAE,QAAQ;AAgH3C;;;;;;;;;;;GAWG;AACH;IACE,0BAEC;IADC,aAAsB;IAGxB;;;;;;;;;;;;;;OAcG;IACH,oBAJW,CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,UAC3B,MAAM,cACN,MAAM,wBAIhB;IAID;;;;;;OAMG;IACH,0BAJW,CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,cAC3B,MAAM,mBACJ,CAAC,aAAa,GAAG,IAAI,CAAC,CAIlC;IAED;;;;;OAKG;IACH,uBAHW,MAAM,mBACJ,CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,CAIvC;IAED;;;;;OAKG;IACH,uBAHW,MAAM,mBACJ,CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,CAIvC;IAED;;;;;;OAMG;IACH,0BAJW,OAAO,cACP,MAAM,mBACJ,CAAC,aAAa,GAAG,IAAI,CAAC,CAIlC;IAED;;;;;;OAMG;IACH,sBAJW,OAAO,cACP,MAAM,mBACJ,CAAC,aAAa,GAAG,IAAI,CAAC,CAIlC;IAED;;;;;;;OAOG;IACH,wBALW,CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,cAC3B,MAAM,mBACJ,OAAO,CAKnB;IAED;;;;;;;OAOG;IACH,wBALW,CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,cAC3B,MAAM,mBACJ,OAAO,CAKnB;IAED;;;;;;;;OAQG;IACH,sBANW,CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,OAC3B,CAAC,KAAK,aAAa,GAAG,IAAI,CA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CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,OAC3B,CAAC,KAAK,aAAa,GAAG,IAAI,CAAC,cAC3B,MAAM,uBAIhB;CACF;AAppBD;;;;;;GAMG;AACH;IAWE;;;OAGG;IACH,sCAEC;;CACF;;yBAxFY,OAAO,eAAe,EAAE,aAAa;;;AAYlD;;;;;GAKG;AACH;IAGE;;OAEG;IACH,iCAEC;IAED;;;OAGG;IACH,oBAEC;IAED;;;OAGG;IACH,2BAGC;IAED;;;OAGG;IACH,oDAWC;;CACF"}
\ No newline at end of file
diff --git a/types/items/items.d.ts b/types/items/items.d.ts
index 903a85f4..ec3a133d 100644
--- a/types/items/items.d.ts
+++ b/types/items/items.d.ts
@@ -137,10 +137,10 @@ export class Item {
*/
rawItem: HostItem;
/**
- * Access historical states for this Item {@link items.ItemHistory}
- * @type {ItemHistory}
+ * Access historical states for this Item {@link items.ItemPersistence}
+ * @type {ItemPersistence}
*/
- history: ItemHistory;
+ persistence: ItemPersistence;
/**
* Access Semantic information of this Item {@link items.ItemSemantics}
* @type {ItemSemantics}
@@ -311,7 +311,7 @@ export class Item {
toString(): any;
}
import metadata = require("./metadata/metadata");
-import { ItemHistory } from "./item-history";
+import { ItemPersistence } from "./item-persistence";
import ItemSemantics = require("./item-semantics");
declare namespace time {
type ZonedDateTime = import('@js-joda/core').ZonedDateTime;
diff --git a/types/items/items.d.ts.map b/types/items/items.d.ts.map
index 21ed5a06..b5c56550 100644
--- a/types/items/items.d.ts.map
+++ b/types/items/items.d.ts.map
@@ -1 +1 @@
-{"version":3,"file":"items.d.ts","sourceRoot":"","sources":["../../src/items/items.js"],"names":[],"mappings":"2BAoBa,OAAO,4BAA4B,EAAE,YAAY;uBAQjD,OAAO,aAAa,EAAE,QAAQ;;;;;;;;UAM7B,MAAM;;;;UACN,MAAM;;;;YACN,MAAM;;;;eACN,MAAM;;;;aACN,MAAM,EAAE;;;;WACR,MAAM,EAAE;;;;eACR,MAAM,MAAO;;;;;;;;iBAEb,MAA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,YAAY,GAAC,IAAI,CAI7B;IAED;;;;;;OAMG;IACH,mBAJW,MAAM,GAAC,MAAM,GAAC,KAAK,aAAa,GAAC,QAAQ,YAAU,QAM7D;IAED;;;;;;OAMG;IACH,8BAJW,MAAM,GAAC,MAAM,GAAC,KAAK,aAAa,GAAC,QAAQ,YAAU,GACjD,OAAO,CAUnB;IAED;;;;;;OAMG;IACH,sEAkBC;IAED;;;;OAIG;IACH,0BAKC;IAED;;;;OAIG;IACH,yBAEC;IAED;;;;;;OAMG;IACH,kBAJW,MAAM,GAAC,MAAM,GAAC,KAAK,aAAa,GAAC,QAAQ,YAAU,QAM7D;IAED;;;OAGG;IACH,2BAEC;IAED;;;OAGG;IACH,6CAIC;IAED;;;OAGG;IACH,gDAMC;IAED;;;OAGG;IACH,qBAEC;IAED;;;OAGG;IACH,qBAFc,MAAM,UAKnB;IAED;;;OAGG;IACH,wBAFc,MAAM,UAOnB;IAED,gBAEC;CACF;;;;;yBApXY,OAAO,eAAe,EAAE,aAAa"}
\ No newline at end of file
+{"version":3,"file":"items.d.ts","sourceRoot":"","sources":["../../src/items/items.js"],"names":[],"mappings":"2BAoBa,OAAO,4BAA4B,EAAE,YAAY;uBAQjD,OAAO,aAAa,EAAE,QAAQ;;;;;;;;UAM7B,MAAM;;;;UACN,MAAM;;;;YACN,MAAM;;;;eACN,MAAM;;;;aACN,MAAM,EAAE;;;;WACR,MAAM,EAAE;;;;eACR,MAAM,MAAO;;;;;;;;iBAEb,MAAM;;;;;;AAikBpB;;;;;GAKG;AACH,gCAHW,MAAM,GACJ,MAAM,CAIa;AA/DhC;;;;;GAKG;AACH,iCAHW,MAAM,GACJ,OAAO,CASnB;AAED;;;;;;GAMG;AACH,8BAJW,MAAM,kBACN,OAAO,GACL,IAAI,GAAC,IAAI,CAYrB;AAED;;;;;GAKG;AACH,4BAFa,IAAI,EAAE,CAIlB;AAzJD;;;;;;;;;;;GAWG;AACH,oCALW,UAAU,GACR,IAAI,CA+BhB;AAoHD;;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