forked from openhab/openhab-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetadata.d.ts
More file actions
152 lines (152 loc) · 6.46 KB
/
metadata.d.ts
File metadata and controls
152 lines (152 loc) · 6.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
export type Item = {
rawItem: HostItem;
persistence: import("./item-persistence");
semantics: import("./item-semantics");
readonly type: string;
readonly groupType: string;
readonly name: string;
readonly label: string;
readonly category: string;
readonly state: string;
readonly numericState: number;
readonly quantityState: import("../quantity").Quantity;
readonly boolState: boolean;
readonly rawState: any;
readonly previousState: string;
readonly previousNumericState: number;
readonly previousQuantityState: import("../quantity").Quantity;
readonly previousRawState: any;
readonly lastStateUpdateTimestamp: any;
readonly lastStateUpdateInstant: any;
readonly lastStateChangeTimestamp: any;
readonly lastStateChangeInstant: any;
readonly members: any[];
readonly descendents: any[];
readonly isInitialized: boolean;
readonly isUninitialized: boolean;
getMetadata(namespace?: string): ItemMetadata | {
namespace: ItemMetadata;
};
replaceMetadata(namespace: string, value: string, configuration?: any): ItemMetadata;
removeMetadata(namespace?: string): ItemMetadata;
sendCommand(value: any, expire?: JSJoda.Duration, onExpire?: any): void;
sendCommandIfDifferent(value: any): boolean;
sendIncreaseCommand(value: any): boolean;
sendDecreaseCommand(value: any): boolean;
getToggleState(): "OPEN" | "PLAY" | "ON" | "PAUSE" | "CLOSED" | "OFF";
sendToggleCommand(): void;
postToggleUpdate(): void;
postUpdate(value: any): void;
readonly groupNames: string[];
addGroups(...groupNamesOrItems: any[]): void;
removeGroups(...groupNamesOrItems: any[]): void;
readonly tags: string[];
addTags(...tagNames: string[]): void;
removeTags(...tagNames: string[]): void;
toString(): any;
};
/**
* Gets metadata of a single namespace or of all namespaces from a given Item.
*
* @example
* // Get metadata of ALL namespaces
* var meta = items.metadata.getMetadata(items.Hallway_Light);
* var namespaces = Object.keys(meta); // Get metadata namespaces
* // Get metadata of a single namespace
* meta = items.metadata.getMetadata(items.Hallway_Light, 'expire');
*
* @see items.Item.getMetadata
* @memberOf items.metadata
* @param {Item|string} itemOrName {@link Item} or the name of the Item
* @param {string} [namespace] name of the metadata: if provided, only metadata of this namespace is returned, else all metadata is returned
* @returns {{ namespace: ItemMetadata }|ItemMetadata|null} all metadata as an object with the namespaces as properties OR metadata of a single
* namespace or `null` if that namespace doesn't exist; the metadata itself is of type {@link ItemMetadata}
*/
export function getMetadata(itemOrName: Item | string, namespace?: string): {
namespace: ItemMetadata;
} | ItemMetadata | null;
/**
* Adds metadata of a single namespace to an Item.
*
* If this is called from file-based scripts, the metadata is registered with the ScriptedMetadataProvider and shares the same lifecycle as the script.
* You can still persist the metadata permanently in this case by setting the `persist` parameter to `true`.
* If this is called from UI-based scripts, the metadata is stored to the ManagedMetadataProvider and independent of the script's lifecycle.
*
* @memberof items.metadata
* @param {Item|string} itemOrName {@link Item} or the name of the Item
* @param {string} namespace name of the metadata
* @param {string} value value for this metadata
* @param {object} [configuration] optional metadata configuration
* @param {boolean} [persist=false] whether to persist the metadata permanently (only respected for file-based scripts)
* @returns {ItemMetadata} the added metadata
* @throws {Error} if the Item already has metadata of the given namespace
*/
export function addMetadata(itemOrName: Item | string, namespace: string, value: string, configuration?: object, persist?: boolean): ItemMetadata;
/**
* Updates or adds metadata of a single namespace to an Item.
* When using file-based scripts, it is recommended to use {@link items.metadata.addMetadata} instead.
*
* If metadata is not provided by this script or the ManagedMetadataProvider, it is not editable and a warning is logged.
*
* @see items.Item.replaceMetadata
* @memberof items.metadata
* @param {Item|string} itemOrName {@link Item} or the name of the Item
* @param {string} namespace name of the metadata
* @param {string} value value for this metadata
* @param {object} [configuration] optional metadata configuration
* @returns {ItemMetadata|null} old metadata or `null` if the Item had no metadata with the given name
*/
export function replaceMetadata(itemOrName: Item | string, namespace: string, value: string, configuration?: object): ItemMetadata | null;
/**
* Removes metadata of a single namespace or of all namespaces from a given Item.
*
* @see items.Item.removeMetadata
* @memberof items.metadata
* @param {Item|string} itemOrName {@link Item} or the name of the Item
* @param {string} [namespace] name of the metadata: if provided, only metadata of this namespace is removed, else all metadata is removed
* @returns {ItemMetadata|null} removed metadata OR `null` if the Item has no metadata under the given namespace, or it cannot be removed or all metadata was removed
*/
export function removeMetadata(itemOrName: Item | string, namespace?: string): ItemMetadata | null;
/**
* Item metadata namespace.
* This namespace provides access to Item metadata.
*
* @namespace items.metadata
*/
/**
* @typedef {import('./items').Item} Item
* @private
*/
/**
* Class representing openHAB Item metadata.
*
* @memberof items.metadata
* @hideconstructor
*/
export class ItemMetadata {
/**
* Create an ItemMetadata instance, wrapping native openHAB Item metadata.
* @param {*} rawMetadata {@link https://www.openhab.org/javadoc/latest/org/openhab/core/items/metadata org.openhab.core.items.Metadata}
*/
constructor(rawMetadata: any);
/**
* raw Java {@link https://www.openhab.org/javadoc/latest/org/openhab/core/items/metadata org.openhab.core.items.Metadata}
* @type {*}
*/
rawMetadata: any;
/**
* The Metadata value.
* @type {string}
*/
get value(): string;
/**
* The metadata configuration.
* @type {object}
*/
get configuration(): any;
toString(): any;
}
export declare namespace itemChannelLink {
function get(): typeof import("./itemchannellink");
}
//# sourceMappingURL=metadata.d.ts.map