Skip to content

Commit a933038

Browse files
committed
[items] Add Instant as valid parameter type for sendCommand & postUpdate
Signed-off-by: Florian Hotze <[email protected]>
1 parent b76f13e commit a933038

9 files changed

+38
-20
lines changed

src/items/items.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ const itemBuilderFactory = osgi.getService('org.openhab.core.items.ItemBuilderFa
3838
* @private
3939
*/
4040
/**
41-
* @typedef {import('@js-joda/core').ZonedDateTime} time.ZonedDateTime
41+
* @typedef {import('@js-joda/core').ZonedDateTime} ZonedDateTime
42+
* @private
43+
*/
44+
/**
45+
* @typedef {import('@js-joda/core').Instant} Instant
4246
* @private
4347
*/
4448
/**
@@ -231,7 +235,7 @@ class Item {
231235
/**
232236
* Sends a command to the Item.
233237
*
234-
* @param {string|number|time.ZonedDateTime|Quantity|HostState} value the value of the command to send, such as 'ON'
238+
* @param {string|number|ZonedDateTime|Instant|Quantity|HostState} value the value of the command to send, such as 'ON'
235239
* @see sendCommandIfDifferent
236240
* @see postUpdate
237241
*/
@@ -242,7 +246,7 @@ class Item {
242246
/**
243247
* Sends a command to the Item, but only if the current state is not what is being sent.
244248
*
245-
* @param {string|number|time.ZonedDateTime|Quantity|HostState} value the value of the command to send, such as 'ON'
249+
* @param {string|number|ZonedDateTime|Instant|Quantity|HostState} value the value of the command to send, such as 'ON'
246250
* @returns {boolean} true if the command was sent, false otherwise
247251
* @see sendCommand
248252
*/
@@ -388,7 +392,7 @@ class Item {
388392
/**
389393
* Posts an update to the Item.
390394
*
391-
* @param {string|number|time.ZonedDateTime|Quantity|HostState} value the value of the command to send, such as 'ON'
395+
* @param {string|number|ZonedDateTime|Instant|Quantity|HostState} value the value of the command to send, such as 'ON'
392396
* @see postToggleUpdate
393397
* @see sendCommand
394398
*/

types/items/items.d.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -240,19 +240,19 @@ export class Item {
240240
/**
241241
* Sends a command to the Item.
242242
*
243-
* @param {string|number|time.ZonedDateTime|Quantity|HostState} value the value of the command to send, such as 'ON'
243+
* @param {string|number|time.ZonedDateTime|time.Instant|Quantity|HostState} value the value of the command to send, such as 'ON'
244244
* @see sendCommandIfDifferent
245245
* @see postUpdate
246246
*/
247-
sendCommand(value: string | number | time.ZonedDateTime | Quantity | HostState): void;
247+
sendCommand(value: string | number | time.ZonedDateTime | time.Instant | Quantity | HostState): void;
248248
/**
249249
* Sends a command to the Item, but only if the current state is not what is being sent.
250250
*
251-
* @param {string|number|time.ZonedDateTime|Quantity|HostState} value the value of the command to send, such as 'ON'
251+
* @param {string|number|time.ZonedDateTime|time.Instant|Quantity|HostState} value the value of the command to send, such as 'ON'
252252
* @returns {boolean} true if the command was sent, false otherwise
253253
* @see sendCommand
254254
*/
255-
sendCommandIfDifferent(value: string | number | time.ZonedDateTime | Quantity | HostState): boolean;
255+
sendCommandIfDifferent(value: string | number | time.ZonedDateTime | time.Instant | Quantity | HostState): boolean;
256256
/**
257257
* Increase the value of this Item to the given value by sending a command, but only if the current state is less than that value.
258258
*
@@ -290,11 +290,11 @@ export class Item {
290290
/**
291291
* Posts an update to the Item.
292292
*
293-
* @param {string|number|time.ZonedDateTime|Quantity|HostState} value the value of the command to send, such as 'ON'
293+
* @param {string|number|time.ZonedDateTime|time.Instant|Quantity|HostState} value the value of the command to send, such as 'ON'
294294
* @see postToggleUpdate
295295
* @see sendCommand
296296
*/
297-
postUpdate(value: string | number | time.ZonedDateTime | Quantity | HostState): void;
297+
postUpdate(value: string | number | time.ZonedDateTime | time.Instant | Quantity | HostState): void;
298298
/**
299299
* Gets the names of the groups this Item is member of.
300300
* @returns {string[]}
@@ -333,6 +333,7 @@ import ItemPersistence = require("./item-persistence");
333333
import ItemSemantics = require("./item-semantics");
334334
declare namespace time {
335335
type ZonedDateTime = import('@js-joda/core').ZonedDateTime;
336+
type Instant = import('@js-joda/core').Instant;
336337
}
337338
export { metadata, TimeSeries };
338339
//# sourceMappingURL=items.d.ts.map

types/items/items.d.ts.map

+1-1
Original file line numberDiff line numberDiff line change

types/items/metadata/metadata.d.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,17 @@ export type Item = {
55
readonly type: string;
66
readonly name: string;
77
readonly label: string;
8-
readonly state: string;
8+
readonly state: string; /**
9+
* Updates or adds metadata of a single namespace to an Item.
10+
*
11+
* @see items.Item.replaceMetadata
12+
* @memberof items.metadata
13+
* @param {Item|string} itemOrName {@link Item} or the name of the Item * @param {string} namespace name of the metadata
14+
* @param {string} namespace name of the metadata
15+
* @param {string} value value for this metadata
16+
* @param {object} [configuration] optional metadata configuration
17+
* @returns {ItemMetadata|null} old metadata or `null` if the Item has no metadata with the given name
18+
*/
919
readonly numericState: number;
1020
readonly quantityState: import("../../quantity").Quantity;
1121
readonly rawState: HostState;

types/items/metadata/metadata.d.ts.map

+1-1
Original file line numberDiff line numberDiff line change

types/quantity.d.ts

-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
export type Item = {
22
rawItem: HostItem;
33
persistence: import("./items/item-persistence");
4-
/**
5-
* QuantityError is thrown when {@link Quantity} creation or operation fails.
6-
* It is used to wrap the underlying Java Exceptions and add some additional information and a JS stacktrace to it.
7-
*/
84
semantics: import("./items/item-semantics");
95
readonly type: string;
106
readonly name: string;

types/quantity.d.ts.map

+1-1
Original file line numberDiff line numberDiff line change

types/rules/operation-builder.d.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ export type Item = {
99
readonly numericState: number;
1010
readonly quantityState: import("../quantity").Quantity;
1111
readonly rawState: HostState;
12-
readonly members: any[];
12+
readonly members: any[]; /**
13+
* Build this rule
14+
*
15+
* @param {string} [name] of the rule
16+
* @param {string} [description] of the rule
17+
* @param {Array<String>} [tags] of the rule
18+
* @param {string} [id] of the rule
19+
*/
1320
readonly descendents: any[];
1421
readonly isUninitialized: boolean;
1522
getMetadata(namespace?: string): {

types/rules/operation-builder.d.ts.map

+1-1
Original file line numberDiff line numberDiff line change

0 commit comments

Comments
 (0)