forked from openhab/openhab-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperation-builder.d.ts
More file actions
355 lines (355 loc) · 10.7 KB
/
operation-builder.d.ts
File metadata and controls
355 lines (355 loc) · 10.7 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
export type Item = {
rawItem: HostItem;
persistence: import("../items/item-persistence");
semantics: import("../items/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): {
rawMetadata: any;
readonly value: string;
readonly configuration: any;
toString(): any;
} | {
namespace: {
rawMetadata: any;
readonly value: string;
readonly configuration: any;
toString(): any;
};
};
/** @private */
replaceMetadata(namespace: string, value: string, configuration?: any): {
rawMetadata: any;
readonly value: string;
readonly configuration: any;
toString(): any;
};
removeMetadata(namespace?: string): {
rawMetadata: any;
readonly value: string;
readonly configuration: any;
toString(): any;
};
sendCommand(value: any, expire?: time.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;
};
export type Quantity = import('../quantity').Quantity;
/**
* Sends a command or update to an item
*
* @memberof OperationBuilder
* @extends OperationConfig
* @hideconstructor
*/
export class SendCommandOrUpdateOperation extends OperationConfig {
constructor(operationBuilder: any, dataOrSupplier: any, isCommand: boolean, optionalDesc: any);
/** @private */
private isCommand;
dataFn: any;
dataDesc: any;
/**
* Send command to multiple items
*
* @param {Item[] | string[]} itemsOrNames the items to send a command to
* @returns {SendCommandOrUpdateOperation} this
*/
toItems(itemsOrNames: Item[] | string[]): SendCommandOrUpdateOperation;
toItemNames: any[] | string[];
/**
* Send command to an item
*
* @param {Item | string} itemOrName the item to send a command to
* @returns {SendCommandOrUpdateOperation} this
*/
toItem(itemOrName: Item | string): SendCommandOrUpdateOperation;
/**
* Send another command
* @param {*} next
* @returns {SendCommandOrUpdateOperation} this
*/
and(next: any): SendCommandOrUpdateOperation;
next: any;
/** @private */
private _run;
/** @private */
private _complete;
/** @private */
private describe;
}
/**
* Timing Item state
*
* @memberof OperationBuilder
* @extends OperationConfig
* @hideconstructor
*/
export class TimingItemStateOperation extends OperationConfig {
constructor(operationBuilder: any, itemChangedTriggerConfig: any, duration: any);
/** @private */
private item_changed_trigger_config;
/** @private */
private duration_ms;
/** @private */
private _complete;
/** @private */
private describe;
/** @private */
private _toOHTriggers;
/** @private */
private _executeHook;
/** @private */
private _startWait;
current_wait: NodeJS.Timeout;
_cancelWait(): void;
}
/**
* Toggles the state of an item
*
* @memberof OperationBuilder
* @extends OperationConfig
* @hideconstructor
*/
export class ToggleOperation extends OperationConfig {
/** @private */
private next;
/** @type {function} */
toItem: Function;
/** @type {function} */
and: Function;
/** @private */
private _run;
/** @private */
private _complete;
/** @private */
private describe;
/**
* Toggle the state of an item
*
* @returns {SendCommandOrUpdateOperation} this
*/
doToggle(): SendCommandOrUpdateOperation;
}
/**
* Copies state from one item to another item
*
* @memberof OperationBuilder
* @extends OperationConfig
* @hideconstructor
*/
export class CopyStateOperation extends OperationConfig {
/**
* Creates a new operation. Don't use constructor directly.
*
* @param {boolean} send whether to send (or post update) the state
* @hideconstructor
*/
constructor(operationBuilder: any, send: boolean);
send: boolean;
/**
* Sets the item to copy the state from
*
* @param {string} itemName the item to copy state from
* @returns {CopyStateOperation} this
*/
fromItem(itemName: string): CopyStateOperation;
from_item: string;
/**
* Sets the item to copy the state to
*
* @param {string} itemName the item to copy state to
* @returns {CopyStateOperation} this
*/
toItem(itemName: string): CopyStateOperation;
to_item: string;
/**
* Appends another operation to execute when the rule fires
* @returns {CopyStateOperation} this
*/
and(): CopyStateOperation;
next: OperationBuilder;
/**
* Runs the operation. Don't call directly.
*
* @private
* @param {object} args rule firing args
*/
private _run;
/**
* Checks that the operation configuration is complete. Don't call directly.
*
* @private
* @returns true only if the operation is ready to run
*/
private _complete;
/**
* Describes the operation.
*
* @private
* @returns a description of the operation
*/
private describe;
}
/**
* @typedef { import("../items/items").Item } Item
* @private
*/
/**
* @typedef {import('../quantity').Quantity} Quantity
* @private
*/
/**
* Operation to execute as part of a rule
* @hideconstructor
*/
export class OperationBuilder {
constructor(builder: any, fn: any);
/** @private */
private _builder;
/** @private */
private _fn;
/** @private */
private _finishErr;
/** @private */
private _then;
/**
* Build this rule
*
* @param {string} [name] of the rule
* @param {string} [description] of the rule
* @param {Array<String>} [tags] of the rule
* @param {string} [id] of the rule
*/
build(name?: string, description?: string, tags?: Array<string>, id?: string): void;
/**
* Specify the rule group for this rule
*
* @param {string} group the group this rule belongs to.
* @returns {OperationBuilder} this
*/
inGroup(group: string): OperationBuilder;
group: string;
/**
* Specifies that a command should be sent as a result of this rule firing.
*
* @param {string|number|time.ZonedDateTime|Quantity|HostState} command the command to send
* @returns {SendCommandOrUpdateOperation} the operation
*/
send(command: string | number | time.ZonedDateTime | Quantity | HostState): SendCommandOrUpdateOperation;
/**
* Specifies that an update should be posted as a result of this rule firing.
*
* @param {string} update the update to send
* @returns {SendCommandOrUpdateOperation} the operation
*/
postUpdate(update: string): SendCommandOrUpdateOperation;
/**
* Specifies the command 'ON' should be sent as a result of this rule firing.
*
* @returns {SendCommandOrUpdateOperation} the operation
*/
sendOn(): SendCommandOrUpdateOperation;
/**
* Specifies the command 'OFF' should be sent as a result of this rule firing.
*
* @returns {SendCommandOrUpdateOperation} the operation
*/
sendOff(): SendCommandOrUpdateOperation;
/**
* Specifies a command should be sent to toggle the state of the target object
* as a result of this rule firing.
*
* @returns {ToggleOperation} the operation
*/
sendToggle(): ToggleOperation;
/**
* Specifies a command should be forwarded to the state of the target object
* as a result of this rule firing. This relies on the trigger being the result
* of a command itself.
*
* @returns {SendCommandOrUpdateOperation} the operation
*/
sendIt(): SendCommandOrUpdateOperation;
/**
* Specifies a command state should be posted to the target object
* as a result of this rule firing. This relies on the trigger being the result
* of a command itself.
*
* @returns {SendCommandOrUpdateOperation} the operation
*/
postIt(): SendCommandOrUpdateOperation;
/**
* Copies the state from one item to another. Can be used to proxy item state. State is updated, not
* sent as a command.
*
* @returns {CopyStateOperation} the operation config
*/
copyState(): CopyStateOperation;
/**
* Sends the state from one item to another. Can be used to proxy item state. State is
* sent as a command.
*
* @returns {CopyStateOperation} the operation config
*/
copyAndSendState(): CopyStateOperation;
}
import time = require("@js-joda/core");
/**
* {RuleBuilder} RuleBuilder triggers
* @memberof OperationBuilder
*/
declare class OperationConfig {
constructor(operationBuilder: any);
operationBuilder: any;
/**
* Specify the rule group for this rule
*
* @param {string} group the group this rule belongs to.
* @returns {OperationBuilder} this
*/
inGroup(group: string): OperationBuilder;
group: string;
/**
* Build this rule
*
* @param {string} [name] of the rule
* @param {string} [description] of the rule
* @param {Array<String>} [tags] of the rule
* @param {string} [id] of the rule
*/
build(name?: string, description?: string, tags?: Array<string>, id?: string): void;
}
export {};
//# sourceMappingURL=operation-builder.d.ts.map