forked from openhab/openhab-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtriggers.d.ts
More file actions
312 lines (312 loc) · 15 KB
/
triggers.d.ts
File metadata and controls
312 lines (312 loc) · 15 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
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 state: string;
readonly numericState: number;
readonly quantityState: import("./quantity").Quantity;
readonly boolState: boolean;
readonly rawState: HostState;
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;
};
};
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?: 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;
};
/**
* Creates a trigger that fires upon specific events in a channel.
*
* @example
* ChannelEventTrigger('astro:sun:local:rise#event', 'START');
*
* @memberof triggers
* @param {string} channel the name of the channel
* @param {string} event the name of the event to listen for
* @param {string} [triggerName] the optional name of the trigger to create
*
*/
export function ChannelEventTrigger(channel: string, event: string, triggerName?: string): HostTrigger;
/**
* Creates a trigger that fires upon an Item changing state.
*
* @example
* ItemStateChangeTrigger('my_item'); // changed
* ItemStateChangeTrigger('my_item', 'OFF', 'ON'); // changed from OFF to ON
* ItemStateChangeTrigger('my_item', undefined, 'ON'); // changed to ON
* ItemStateChangeTrigger('my_item', 'OFF', undefined); // changed from OFF
*
* @memberof triggers
* @param {Item|string} itemOrName the {@link Item} or the name of the Item to monitor for change
* @param {string} [oldState] the previous state of the Item
* @param {string} [newState] the new state of the Item
* @param {string} [triggerName] the optional name of the trigger to create
*/
export function ItemStateChangeTrigger(itemOrName: Item | string, oldState?: string, newState?: string, triggerName?: string): HostTrigger;
/**
* Creates a trigger that fires upon an Item receiving a state update. Note that the Item does not need to change state.
*
* @example
* ItemStateUpdateTrigger('my_item'); // received update
* ItemStateUpdateTrigger('my_item', 'OFF'); // received update OFF
*
* @memberof triggers
* @param {Item|string} itemOrName the {@link Item} or the name of the Item to monitor for change
* @param {string} [state] the new state of the Item
* @param {string} [triggerName] the optional name of the trigger to create
*/
export function ItemStateUpdateTrigger(itemOrName: Item | string, state?: string, triggerName?: string): HostTrigger;
/**
* Creates a trigger that fires upon an Item receiving a command. Note that the Item does not need to change state.
*
* @example
* ItemCommandTrigger('my_item'); // received command
* ItemCommandTrigger('my_item', 'OFF'); // received command OFF
*
* @memberof triggers
* @param {Item|string} itemOrName the {@link Item} or the name of the Item to monitor for change
* @param {string} [command] the command received
* @param {string} [triggerName] the optional name of the trigger to create
*/
export function ItemCommandTrigger(itemOrName: Item | string, command?: string, triggerName?: string): HostTrigger;
/**
* Creates a trigger that fires upon a member of a group changing state. Note that group Item does not need to change state.
*
* @example
* GroupStateChangeTrigger('my_group', 'OFF', 'ON');
*
* @memberof triggers
* @param {Item|string} groupOrName the group {@link Item} or the name of the group to monitor for change
* @param {string} [oldState] the previous state of the group
* @param {string} [newState] the new state of the group
* @param {string} [triggerName] the optional name of the trigger to create
*/
export function GroupStateChangeTrigger(groupOrName: Item | string, oldState?: string, newState?: string, triggerName?: string): HostTrigger;
/**
* Creates a trigger that fires upon a member of a group receiving a state update. Note that group Item does not need to change state.
*
* @example
* GroupStateUpdateTrigger('my_group', 'OFF');
*
* @memberof triggers
* @param {Item|string} groupOrName the group {@link Item} or the name of the group to monitor for change
* @param {string} [state] the new state of the group
* @param {string} [triggerName] the optional name of the trigger to create
*/
export function GroupStateUpdateTrigger(groupOrName: Item | string, state?: string, triggerName?: string): HostTrigger;
/**
* Creates a trigger that fires upon a member of a group receiving a command. Note that the group Item does not need to change state.
*
* @example
* GroupCommandTrigger('my_group', 'OFF');
*
* @memberof triggers
* @param {Item|string} groupOrName the group {@link Item} or the name of the group to monitor for commands
* @param {string} [command] the command received
* @param {string} [triggerName] the optional name of the trigger to create
*/
export function GroupCommandTrigger(groupOrName: Item | string, command?: string, triggerName?: string): HostTrigger;
/**
* Creates a trigger that fires upon a Thing status updating.
*
* @example
* ThingStatusUpdateTrigger('some:thing:uuid', 'OFFLINE');
*
* @memberof triggers
* @param {string} thingUID the name of the thing to monitor for a status updating
* @param {string} [status] the optional status to monitor for
* @param {string} [triggerName] the optional name of the trigger to create
*/
export function ThingStatusUpdateTrigger(thingUID: string, status?: string, triggerName?: string): HostTrigger;
/**
* Creates a trigger that fires upon a Thing status changing.
*
* @example
* ThingStatusChangeTrigger('some:thing:uuid', 'ONLINE', 'OFFLINE');
*
* @memberof triggers
* @param {string} thingUID the name of the thing to monitor for a status change
* @param {string} [status] the optional status to monitor for
* @param {string} [previousStatus] the optional previous state to monitor from
* @param {string} [triggerName] the optional name of the trigger to create
*/
export function ThingStatusChangeTrigger(thingUID: string, status?: string, previousStatus?: string, triggerName?: string): HostTrigger;
/**
* Creates a trigger that fires if a given start level is reached by the system
*
* @example
* SystemStartlevelTrigger(40) // Rules loaded
* SystemStartlevelTrigger(50) // Rule engine started
* SystemStartlevelTrigger(70) // User interfaces started
* SystemStartlevelTrigger(80) // Things initialized
* SystemStartlevelTrigger(100) // Startup Complete
*
* @memberof triggers
* @param {string|number} startlevel the system start level to be triggered on
* @param {string} [triggerName] the optional name of the trigger to create
*/
export function SystemStartlevelTrigger(startlevel: string | number, triggerName?: string): HostTrigger;
/**
* Creates a trigger that fires on a cron schedule. The supplied cron expression defines when the trigger will fire.
*
* @example
* GenericCronTrigger('0 30 16 * * ? *');
*
* @memberof triggers
* @param {string} expression the cron expression defining the triggering schedule
* @param {string} [triggerName] the optional name of the trigger to create
*/
export function GenericCronTrigger(expression: string, triggerName?: string): HostTrigger;
/**
* Creates a trigger that fires upon a matching event from the event bus.
*
* Please have a look at the {@link https://www.openhab.org/docs/developer/utils/events.html Event Bus docs} to learn about events.
*
* @example
* // Triggers when an Item is added or removed
* GenericEventTrigger('openhab/items/**', '', ['ItemAddedEvent', 'ItemRemovedEvent'])
* // Triggers when the Item "OutdoorLights" is commanded by expire
* GenericEventTrigger('openhab/items/OutdoorLights/*', 'org.openhab.core.expire', 'ItemCommandEvent')
*
*
* @memberof triggers
* @param {string} eventTopic Specifies the event topic to match, asa file-system style glob (`*` and `**` operators)
* @param {string} eventSource Specifies the event source such as `org.openhab.core.expire`,
* @param {string|string[]} eventTypes Specifies the event type(s) to match, e.g. `ItemAddedEvent`, `ItemRemovedEvent`, `ItemCommandEvent`, etc.
* @param {string} [triggerName] the optional name of the trigger to create
*/
export function GenericEventTrigger(eventTopic: string, eventSource: string, eventTypes: string | string[], triggerName?: string): HostTrigger;
/**
* Creates a trigger that fires daily at a specific time. The supplied time defines when the trigger will fire.
*
* @example
* TimeOfDayTrigger('19:00');
*
* @memberof triggers
* @param {string} time the time expression (in `HH:mm`) defining the triggering schedule
* @param {string} [triggerName] the optional name of the trigger to create
*/
export function TimeOfDayTrigger(time: string, triggerName?: string): HostTrigger;
/**
* Creates a trigger that fires at an (optional) date and time specified in a DateTime Item.
*
* @example
* DateTimeTrigger('MyDateTimeItem');
*
* @memberof triggers
* @param {Item|string} itemOrName the {@link Item} or the name of the Item to monitor for change
* @param {boolean} [timeOnly=false] Specifies whether only the time of the DateTime Item should be compared or the date and time.
* @param {number} [offset=0] The offset in seconds to add to the time of the DateTime Item
* @param {string} [triggerName] the optional name of the trigger to create
*/
export function DateTimeTrigger(itemOrName: Item | string, timeOnly?: boolean, offset?: number, triggerName?: string): HostTrigger;
/**
* Creates a trigger for the {@link https://openhab.org/addons/automation/pwm/ Pulse Width Modulation (PWM) Automation} add-on.
*
* @example
* rules.JSRule({
* name: 'PWM rule',
* triggers: [
* triggers.PWMTrigger('pwm_dimmer', 10);
* ],
* execute: (event) => {
* items.getItem('pwm_switch').sendCommand(event.receivedCommand);
* }
* });
*
* @memberof triggers
* @param {Item|string} dutycycleItemOrName the Item or name of the Item (PercentType) to read the duty cycle from
* @param {number} interval constant interval in which the output is switch ON and OFF again (in sec)
* @param {number} [minDutyCycle] any duty cycle below this value will be increased to this value
* @param {number} [maxDutyCycle] any duty cycle above this value will be decreased to this value
* @param {number} [deadManSwitch] output will be switched off, when the duty cycle is not updated within this time (in ms)
* @param {boolean} [equateMinToZero=false] whether the duty cycle below `minDutyCycle` should be set to 0
* @param {boolean} [equateMaxToHundred=true] whether the duty cycle above `maxDutyCycle` should be set to 100
* @param {string} [triggerName] the optional name of the trigger to create
*/
export function PWMTrigger(dutycycleItemOrName: Item | string, interval: number, minDutyCycle?: number, maxDutyCycle?: number, deadManSwitch?: number, equateMinToZero?: boolean, equateMaxToHundred?: boolean, triggerName?: string): HostTrigger;
/**
* Creates a trigger for the {@link https://www.openhab.org/addons/automation/pidcontroller/ PID Controller Automation} add-on.
*
* @example
* rules.JSRule({
* name: 'PID rule',
* triggers: [
* triggers.PIDTrigger('currentTemperature', 'targetTemperature', 1, 1, 1, 1, 10000, undefined, 1, 100);
* ],
* execute: (event) => {
* // Look out what the max value for your Item is!
* const command = parseInt(event.receivedCommand) > 100 ? '100' : event.receivedCommand;
* items.getItem('thermostat').sendCommand(command);
* }
* });
*
* @memberof triggers
* @param {string} inputItem name of the input Item (e.g. temperature sensor value)
* @param {string} setpointItem name of the setpoint Item (e.g. desired room temperature)
* @param {number} kp P: {@link https://www.openhab.org/addons/automation/pidcontroller/#proportional-p-gain-parameter Proportional Gain} parameter
* @param {number} ki I: {@link https://www.openhab.org/addons/automation/pidcontroller/#integral-i-gain-parameter Integral Gain} parameter
* @param {number} kd D: {@link https://www.openhab.org/addons/automation/pidcontroller/#derivative-d-gain-parameter Deritative Gain} parameter
* @param {number} kdTimeConstant D-T1: {@link https://www.openhab.org/addons/automation/pidcontroller/#derivative-time-constant-d-t1-parameter Derivative Gain Time Constant} in sec
* @param {number} loopTime The interval the output value will be updated in milliseconds. Note: the output will also be updated when the input value or the setpoint changes.
* @param {string} [commandItem] Name of the item to send a String "RESET" to reset the I- and the D-part to 0.
* @param {number} [integralMinValue] The I-part will be limited (min) to this value.
* @param {number} [integralMaxValue] The I-part will be limited (max) to this value.
* @param {string} [pInspectorItem] name of the debug Item for the current P-part
* @param {string} [iInspectorItem] name of the debug Item for the current I-part
* @param {string} [dInspectorItem] name of the debug Item for the current D-part
* @param {string} [errorInspectorItem] name of the debug Item for the current regulation difference (error)
* @param {string} [triggerName] the optional name of the trigger to create
*/
export function PIDTrigger(inputItem: string, setpointItem: string, kp?: number, ki?: number, kd?: number, kdTimeConstant?: number, loopTime?: number, commandItem?: string, integralMinValue?: number, integralMaxValue?: number, pInspectorItem?: string, iInspectorItem?: string, dInspectorItem?: string, errorInspectorItem?: string, triggerName?: string): HostTrigger;
//# sourceMappingURL=triggers.d.ts.map