Skip to content

Commit f8aa1f4

Browse files
authored
[items] Add Instant as valid parameter type for sendCommand & postUpdate (#423)
Signed-off-by: Florian Hotze <[email protected]>
1 parent b76f13e commit f8aa1f4

File tree

5 files changed

+18
-19
lines changed

5 files changed

+18
-19
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

+8-9
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ export type ItemMetadata = {
4747
value: string;
4848
configuration: any;
4949
};
50+
export type ZonedDateTime = import('@js-joda/core').ZonedDateTime;
51+
export type Instant = import('@js-joda/core').Instant;
5052
export type Quantity = import('../quantity').Quantity;
5153
/**
5254
* Helper function to ensure an Item name is valid. All invalid characters are replaced with an underscore.
@@ -240,19 +242,19 @@ export class Item {
240242
/**
241243
* Sends a command to the Item.
242244
*
243-
* @param {string|number|time.ZonedDateTime|Quantity|HostState} value the value of the command to send, such as 'ON'
245+
* @param {string|number|ZonedDateTime|Instant|Quantity|HostState} value the value of the command to send, such as 'ON'
244246
* @see sendCommandIfDifferent
245247
* @see postUpdate
246248
*/
247-
sendCommand(value: string | number | time.ZonedDateTime | Quantity | HostState): void;
249+
sendCommand(value: string | number | ZonedDateTime | Instant | Quantity | HostState): void;
248250
/**
249251
* Sends a command to the Item, but only if the current state is not what is being sent.
250252
*
251-
* @param {string|number|time.ZonedDateTime|Quantity|HostState} value the value of the command to send, such as 'ON'
253+
* @param {string|number|ZonedDateTime|Instant|Quantity|HostState} value the value of the command to send, such as 'ON'
252254
* @returns {boolean} true if the command was sent, false otherwise
253255
* @see sendCommand
254256
*/
255-
sendCommandIfDifferent(value: string | number | time.ZonedDateTime | Quantity | HostState): boolean;
257+
sendCommandIfDifferent(value: string | number | ZonedDateTime | Instant | Quantity | HostState): boolean;
256258
/**
257259
* 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.
258260
*
@@ -290,11 +292,11 @@ export class Item {
290292
/**
291293
* Posts an update to the Item.
292294
*
293-
* @param {string|number|time.ZonedDateTime|Quantity|HostState} value the value of the command to send, such as 'ON'
295+
* @param {string|number|ZonedDateTime|Instant|Quantity|HostState} value the value of the command to send, such as 'ON'
294296
* @see postToggleUpdate
295297
* @see sendCommand
296298
*/
297-
postUpdate(value: string | number | time.ZonedDateTime | Quantity | HostState): void;
299+
postUpdate(value: string | number | ZonedDateTime | Instant | Quantity | HostState): void;
298300
/**
299301
* Gets the names of the groups this Item is member of.
300302
* @returns {string[]}
@@ -331,8 +333,5 @@ import metadata = require("./metadata/metadata");
331333
import TimeSeries = require("./time-series");
332334
import ItemPersistence = require("./item-persistence");
333335
import ItemSemantics = require("./item-semantics");
334-
declare namespace time {
335-
type ZonedDateTime = import('@js-joda/core').ZonedDateTime;
336-
}
337336
export { metadata, TimeSeries };
338337
//# sourceMappingURL=items.d.ts.map

types/items/items.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

0 commit comments

Comments
 (0)