iobroker.javascript 8.9.2 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/admin/assets/{createSvgIcon-BdRvDw53.js → createSvgIcon-BQT-7-GS.js} +1 -1
- package/admin/assets/{docs-6na4NFtj.js → docs-BrInh2Pn.js} +2 -2
- package/admin/assets/index-B0RKH_iG.js +1329 -0
- package/admin/assets/index-CfuHVX2B.js +193 -0
- package/admin/assets/index-CuCs5aLs.js +5 -0
- package/admin/assets/index-tExaxF69.js +930 -0
- package/admin/assets/inheritsLoose--KnFDOw1.js +36 -0
- package/admin/assets/{useTheme-Cl1QmYFL.js → useTheme-DF6qfrtI.js} +1 -1
- package/admin/custom/assets/{Components-ChpTW7sE.js → Components-D9kRsHNY.js} +1 -1
- package/admin/custom/assets/{DefaultPropsProvider-CHpMCMgA.js → DefaultPropsProvider-9qubdy-V.js} +2 -2
- package/admin/custom/assets/{FilledInput-CtcQVKyj.js → FilledInput-BpuM_GyB.js} +1 -1
- package/admin/custom/assets/Tabs-CvEv0KOT.js +138 -0
- package/admin/custom/assets/ThemeProvider-DZTpMR8n.js +29 -0
- package/admin/custom/assets/{createSvgIcon-C_vAELFU.js → createSvgIcon-BQThUM-f.js} +1 -1
- package/admin/custom/assets/hostInit-CrAs5YZS.js +1 -1
- package/admin/custom/assets/{index-DwsbskQy.js → index-DIWNdd4a.js} +1 -1
- package/admin/custom/assets/index-DZqbj5K4.js +55 -0
- package/admin/custom/assets/{index-D5apCzjJ.js → index-Dbe-II7_.js} +6 -6
- package/admin/custom/assets/index-az76fZMP.js +904 -0
- package/admin/custom/assets/index-sawv1cUe.js +1399 -0
- package/admin/custom/assets/{virtualExposes-BPncCdUy.js → virtualExposes-BMKIjWrE.js} +2 -2
- package/admin/custom/customComponents.js +2 -2
- package/admin/custom/i18n/de.json +29 -29
- package/admin/custom/i18n/es.json +29 -29
- package/admin/custom/i18n/fr.json +29 -29
- package/admin/custom/i18n/it.json +29 -29
- package/admin/custom/i18n/nl.json +29 -29
- package/admin/custom/i18n/pl.json +29 -29
- package/admin/custom/i18n/pt.json +29 -29
- package/admin/custom/i18n/ru.json +29 -29
- package/admin/custom/i18n/uk.json +29 -29
- package/admin/custom/i18n/zh-cn.json +29 -29
- package/admin/google-blockly/blockly_compressed.js +875 -887
- package/admin/google-blockly/blocks_compressed.js +38 -41
- package/admin/google-blockly/javascript_compressed.js +19 -54
- package/admin/google-blockly/media/delete-icon.svg +1 -0
- package/admin/google-blockly/media/foldout-icon.svg +1 -0
- package/admin/google-blockly/media/resize-handle.svg +3 -0
- package/admin/jsonConfig.json +2 -0
- package/admin/mf-manifest.json +1 -1
- package/admin/remoteEntry.js +2 -2
- package/admin/tab.html +4 -4
- package/admin/vsFont/README.md +1 -1
- package/admin/vsFont/createJson.js +1 -1
- package/build-backend/lib/consts.js +346 -0
- package/build-backend/lib/consts.js.map +1 -0
- package/build-backend/lib/convert.js +120 -0
- package/build-backend/lib/convert.js.map +1 -0
- package/build-backend/lib/debug.js +163 -0
- package/build-backend/lib/debug.js.map +1 -0
- package/{lib → build-backend/lib}/debugger.js +261 -232
- package/build-backend/lib/debugger.js.map +1 -0
- package/build-backend/lib/eventObj.js +177 -0
- package/build-backend/lib/eventObj.js.map +1 -0
- package/build-backend/lib/inspect.js +728 -0
- package/build-backend/lib/inspect.js.map +1 -0
- package/build-backend/lib/javascript.d.ts +1972 -0
- package/{lib → build-backend/lib}/mirror.js +185 -182
- package/build-backend/lib/mirror.js.map +1 -0
- package/build-backend/lib/nodeModulesManagement.js +25 -0
- package/build-backend/lib/nodeModulesManagement.js.map +1 -0
- package/build-backend/lib/patternCompareFunctions.js +321 -0
- package/build-backend/lib/patternCompareFunctions.js.map +1 -0
- package/build-backend/lib/protectFs.js +477 -0
- package/build-backend/lib/protectFs.js.map +1 -0
- package/build-backend/lib/request.js +89 -0
- package/build-backend/lib/request.js.map +1 -0
- package/{lib → build-backend/lib}/sandbox.js +2046 -1852
- package/build-backend/lib/sandbox.js.map +1 -0
- package/build-backend/lib/scheduler.js +553 -0
- package/build-backend/lib/scheduler.js.map +1 -0
- package/build-backend/lib/tools.js +183 -0
- package/build-backend/lib/tools.js.map +1 -0
- package/build-backend/lib/typescriptSettings.js +39 -0
- package/build-backend/lib/typescriptSettings.js.map +1 -0
- package/build-backend/lib/typescriptTools.js +435 -0
- package/build-backend/lib/typescriptTools.js.map +1 -0
- package/build-backend/lib/utils.js +66 -0
- package/build-backend/lib/utils.js.map +1 -0
- package/{lib → build-backend/lib}/words.js +23 -30
- package/build-backend/lib/words.js.map +1 -0
- package/build-backend/main.js +2671 -0
- package/build-backend/main.js.map +1 -0
- package/build-backend/types.d.ts +742 -0
- package/docs/de/README.md +1 -1
- package/docs/en/README.md +1 -1
- package/docs/en/javascript.md +10 -6
- package/docs/ru/README.md +1 -1
- package/install/installTypings.js +34 -47
- package/io-package.json +14 -14
- package/package.json +14 -14
- package/admin/assets/index-DCkkMRRa.js +0 -1335
- package/admin/assets/index-DJfSBoBB.js +0 -192
- package/admin/assets/index-DTiA4WdK.js +0 -930
- package/admin/assets/index-qABB1JVe.js +0 -5
- package/admin/assets/inheritsLoose-BW-3V39H.js +0 -36
- package/admin/custom/assets/Tabs-C1KOyWRi.js +0 -137
- package/admin/custom/assets/ThemeProvider-Buvx5nSd.js +0 -29
- package/admin/custom/assets/index-BGCRznKh.js +0 -904
- package/admin/custom/assets/index-DfBPYXqA.js +0 -55
- package/admin/custom/assets/index-jIr6kOLK.js +0 -1398
- package/lib/adapter-config.d.ts +0 -16
- package/lib/consts.js +0 -83
- package/lib/convert.js +0 -106
- package/lib/debug.js +0 -154
- package/lib/eventObj.js +0 -201
- package/lib/inspect.js +0 -688
- package/lib/javascript.d.ts +0 -1858
- package/lib/nodeModulesManagement.js +0 -26
- package/lib/patternCompareFunctions.js +0 -391
- package/lib/protectFs.js +0 -401
- package/lib/request.js +0 -72
- package/lib/scheduler.js +0 -447
- package/lib/tools.js +0 -192
- package/lib/typescriptSettings.js +0 -44
- package/lib/typescriptTools.js +0 -529
- package/lib/utils.js +0 -87
- package/main.js +0 -2653
package/lib/javascript.d.ts
DELETED
|
@@ -1,1858 +0,0 @@
|
|
|
1
|
-
// import all modules that are available in the sandbox
|
|
2
|
-
// this has a nice side effect that we may augment the global scope
|
|
3
|
-
import * as child_process from 'child_process';
|
|
4
|
-
import * as os from 'os';
|
|
5
|
-
|
|
6
|
-
type EmptyCallback = () => void | Promise<void>;
|
|
7
|
-
type ErrorCallback = (err?: string) => void | Promise<void>;
|
|
8
|
-
type GenericCallback<T> = (err?: string | null, result?: T) => void | Promise<void>;
|
|
9
|
-
type SimpleCallback<T> = (result?: T) => void | Promise<void>;
|
|
10
|
-
type MessageCallback<T> = (data: T, callback: iobJS.MessageCallback) => void | Promise<void>;
|
|
11
|
-
type LogCallback = (msg: any) => void | Promise<void>;
|
|
12
|
-
|
|
13
|
-
type SecondParameterOf<T extends (...args: any[]) => any> = T extends (
|
|
14
|
-
arg0: any,
|
|
15
|
-
arg1: infer R,
|
|
16
|
-
...args: any[]
|
|
17
|
-
) => any
|
|
18
|
-
? R
|
|
19
|
-
: never;
|
|
20
|
-
/** Infers the return type from a callback-style API and strips out null and undefined */
|
|
21
|
-
type NonNullCallbackReturnTypeOf<T extends (...args: any[]) => any> = Exclude<
|
|
22
|
-
SecondParameterOf<T>,
|
|
23
|
-
null | undefined
|
|
24
|
-
>;
|
|
25
|
-
/** Infers the return type from a callback-style API and leaves null and undefined in */
|
|
26
|
-
type CallbackReturnTypeOf<T extends (...args: any[]) => any> = SecondParameterOf<T>;
|
|
27
|
-
|
|
28
|
-
/** Returns a type that requires at least one of the properties from the given type */
|
|
29
|
-
type AtLeastOne<T, U = { [K in keyof T]-?: T[K] }> = { [K in keyof U]: { [P in K]: U[P] } }[keyof U];
|
|
30
|
-
|
|
31
|
-
/** Returns all possible keys of a union of objects */
|
|
32
|
-
type AllKeys<T> = T extends any ? keyof T : never;
|
|
33
|
-
/** Simplifies mapped types to their basic forms */
|
|
34
|
-
type Simplify<U> = U extends infer O ? { [K in keyof O]: O[K] } : never;
|
|
35
|
-
|
|
36
|
-
/** Takes an object type and adds all missing properties from the Keys union with the type `never` */
|
|
37
|
-
type AddMissingNever<T, Keys extends string | number | symbol> = {
|
|
38
|
-
[K in Keys]: K extends keyof T ? T[K] : never;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Takes a union of objects and returns an object type
|
|
43
|
-
* which has all properties that exist on at least one of the objects.
|
|
44
|
-
*
|
|
45
|
-
* E.g. CombineObjectUnion<{a: 1} | {b: 2}> = {a: 1; b: 2};
|
|
46
|
-
*/
|
|
47
|
-
type CombineObjectUnion<
|
|
48
|
-
T,
|
|
49
|
-
Keys extends string | number | symbol = AllKeys<T>,
|
|
50
|
-
O = T extends any ? AddMissingNever<T, Keys> : never
|
|
51
|
-
> = Simplify<{ [K in Keys]: K extends keyof O ? O[K] : never }>
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Takes a union of ioBroker Object types and returns a combined object type
|
|
55
|
-
* which has all properties that could exist on at least one of the objects.
|
|
56
|
-
*
|
|
57
|
-
* Note: This is not entirely sound to work with, but better for JS and working with read objects
|
|
58
|
-
*/
|
|
59
|
-
type AnyOf<
|
|
60
|
-
T,
|
|
61
|
-
Keys extends string | number | symbol = AllKeys<T>,
|
|
62
|
-
O = T extends any ? AddMissingNever<T, Keys> : never
|
|
63
|
-
> = Simplify<{
|
|
64
|
-
[K in Keys]: K extends keyof O ? (
|
|
65
|
-
O[K] extends any[] ? O[K]
|
|
66
|
-
: O[K] extends Record<any, any> ? CombineObjectUnion<O[K]>
|
|
67
|
-
: O[K]
|
|
68
|
-
) : never;
|
|
69
|
-
}>;
|
|
70
|
-
|
|
71
|
-
// tslint:disable:no-namespace
|
|
72
|
-
declare global {
|
|
73
|
-
|
|
74
|
-
namespace iobJS {
|
|
75
|
-
|
|
76
|
-
enum StateQuality {
|
|
77
|
-
good = 0x00, // or undefined or null
|
|
78
|
-
bad = 0x01,
|
|
79
|
-
general_problem = 0x01,
|
|
80
|
-
general_device_problem = 0x41,
|
|
81
|
-
general_sensor_problem = 0x81,
|
|
82
|
-
device_not_connected = 0x42,
|
|
83
|
-
sensor_not_connected = 0x82,
|
|
84
|
-
device_reports_error = 0x44,
|
|
85
|
-
sensor_reports_error = 0x84,
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
type PrimitiveTypeStateValue = string | number | boolean;
|
|
89
|
-
type StateValue = null | PrimitiveTypeStateValue | PrimitiveTypeStateValue[] | Record<string, any>;
|
|
90
|
-
|
|
91
|
-
interface State<T extends StateValue = any> {
|
|
92
|
-
/** The value of the state. */
|
|
93
|
-
val: T;
|
|
94
|
-
|
|
95
|
-
/** Direction flag: false for desired value and true for actual value. Default: false. */
|
|
96
|
-
ack: boolean;
|
|
97
|
-
|
|
98
|
-
/** Unix timestamp. Default: current time */
|
|
99
|
-
ts: number;
|
|
100
|
-
|
|
101
|
-
/** Unix timestamp of the last time the value changed */
|
|
102
|
-
lc: number;
|
|
103
|
-
|
|
104
|
-
/** Name of the adapter instance which set the value, e.g. "system.adapter.web.0" */
|
|
105
|
-
from: string;
|
|
106
|
-
|
|
107
|
-
/** Optional time in seconds after which the state is reset to null */
|
|
108
|
-
expire?: number;
|
|
109
|
-
|
|
110
|
-
/** Optional quality of the state value */
|
|
111
|
-
q?: StateQuality;
|
|
112
|
-
|
|
113
|
-
/** Optional comment */
|
|
114
|
-
c?: string;
|
|
115
|
-
|
|
116
|
-
/** Discriminant property to switch between AbsentState and State<T> */
|
|
117
|
-
notExist: undefined;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
type SettableState = AtLeastOne<State>;
|
|
121
|
-
|
|
122
|
-
interface AbsentState {
|
|
123
|
-
val: null;
|
|
124
|
-
notExist: true;
|
|
125
|
-
|
|
126
|
-
ack: undefined;
|
|
127
|
-
ts: undefined;
|
|
128
|
-
lc: undefined;
|
|
129
|
-
from: undefined;
|
|
130
|
-
expire: undefined;
|
|
131
|
-
q: undefined;
|
|
132
|
-
c: undefined;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
type Languages = 'en' | 'de' | 'ru' | 'pt' | 'nl' | 'fr' | 'it' | 'es' | 'pl' | 'uk' | 'zh-cn';
|
|
136
|
-
type StringOrTranslated = string | { [lang in Languages]?: string; };
|
|
137
|
-
type CommonType = "number" | "string" | "boolean" | "array" | "object" | "mixed" | "file";
|
|
138
|
-
|
|
139
|
-
/** Defines access rights for a single object type */
|
|
140
|
-
interface ObjectOperationPermissions {
|
|
141
|
-
/** Whether a user may enumerate objects of this type */
|
|
142
|
-
list: boolean;
|
|
143
|
-
/** Whether a user may read objects of this type */
|
|
144
|
-
read: boolean;
|
|
145
|
-
/** Whether a user may write objects of this type */
|
|
146
|
-
write: boolean;
|
|
147
|
-
/** Whether a user may create objects of this type */
|
|
148
|
-
create: boolean;
|
|
149
|
-
/** Whether a user may delete objects of this type */
|
|
150
|
-
delete: boolean;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/** Defines the rights a user or group has to change objects */
|
|
154
|
-
interface ObjectPermissions {
|
|
155
|
-
/** The access rights for files */
|
|
156
|
-
file: ObjectOperationPermissions;
|
|
157
|
-
/** The access rights for objects */
|
|
158
|
-
object: ObjectOperationPermissions;
|
|
159
|
-
/** The access rights for users/groups */
|
|
160
|
-
users: ObjectOperationPermissions;
|
|
161
|
-
/** The access rights for states */
|
|
162
|
-
state?: ObjectOperationPermissions;
|
|
163
|
-
}
|
|
164
|
-
/** Defined the complete set of access rights a user has */
|
|
165
|
-
interface PermissionSet extends ObjectPermissions {
|
|
166
|
-
/** The name of the user this ACL is for */
|
|
167
|
-
user: string;
|
|
168
|
-
/** The name of the groups this ACL was merged from */
|
|
169
|
-
groups: string[];
|
|
170
|
-
/** The access rights for certain commands */
|
|
171
|
-
other: {
|
|
172
|
-
execute: boolean;
|
|
173
|
-
http: boolean;
|
|
174
|
-
sendto: boolean;
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
interface ObjectACL {
|
|
179
|
-
/** Full name of the user who owns this object, e.g. "system.user.admin" */
|
|
180
|
-
owner: string;
|
|
181
|
-
/** Full name of the group who owns this object, e.g. "system.group.administrator" */
|
|
182
|
-
ownerGroup: string;
|
|
183
|
-
/** Linux-type permissions defining access to this object */
|
|
184
|
-
object: number;
|
|
185
|
-
}
|
|
186
|
-
/** Defines access rights for a single state object */
|
|
187
|
-
interface StateACL extends ObjectACL {
|
|
188
|
-
/** Linux-type permissions defining access to this state */
|
|
189
|
-
state: number;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/** Defines the existing object types in ioBroker */
|
|
193
|
-
type ObjectType =
|
|
194
|
-
| 'state'
|
|
195
|
-
| 'channel'
|
|
196
|
-
| 'device'
|
|
197
|
-
| 'folder'
|
|
198
|
-
| 'enum'
|
|
199
|
-
| 'adapter'
|
|
200
|
-
| 'config'
|
|
201
|
-
| 'group'
|
|
202
|
-
| 'host'
|
|
203
|
-
| 'instance'
|
|
204
|
-
| 'meta'
|
|
205
|
-
| 'script'
|
|
206
|
-
| 'user'
|
|
207
|
-
| 'chart';
|
|
208
|
-
|
|
209
|
-
// Define the naming schemes for objects, so we can provide more specific types for get/setObject
|
|
210
|
-
namespace ObjectIDs {
|
|
211
|
-
// Guaranteed meta objects
|
|
212
|
-
type Meta =
|
|
213
|
-
| `${string}.${number}`
|
|
214
|
-
| `${string}.${"meta" | "admin"}`
|
|
215
|
-
| `${string}.meta.${string}`
|
|
216
|
-
| `${string}.${number}.meta.${string}`;
|
|
217
|
-
|
|
218
|
-
// Unsure, can be folder, device, channel or state
|
|
219
|
-
// --> We need this match to avoid matching the more specific types below
|
|
220
|
-
type Misc =
|
|
221
|
-
| `system.host.${string}.${string}`
|
|
222
|
-
| `0_userdata.0.${string}`;
|
|
223
|
-
|
|
224
|
-
// Guaranteed channel objects
|
|
225
|
-
type Channel =
|
|
226
|
-
| `script.js.${"common" | "global"}`
|
|
227
|
-
| `${string}.${number}.info`;
|
|
228
|
-
// Either script or channel object
|
|
229
|
-
type ScriptOrChannel = `script.js.${string}`;
|
|
230
|
-
// Guaranteed state objects
|
|
231
|
-
type State =
|
|
232
|
-
| `system.adapter.${string}.${number}.${string}`;
|
|
233
|
-
// Guaranteed enum objects
|
|
234
|
-
type Enum = `enum.${string}`;
|
|
235
|
-
// Guaranteed instance objects
|
|
236
|
-
type Instance = `system.adapter.${string}.${number}`;
|
|
237
|
-
// Guaranteed adapter objects
|
|
238
|
-
type Adapter = `system.adapter.${string}`;
|
|
239
|
-
// Guaranteed group objects
|
|
240
|
-
type Group = `system.group.${string}`;
|
|
241
|
-
// Guaranteed user objects
|
|
242
|
-
type User = `system.user.${string}`;
|
|
243
|
-
// Guaranteed host objects
|
|
244
|
-
type Host = `system.host.${string}`;
|
|
245
|
-
// Guaranteed config objects
|
|
246
|
-
type Config = `system.${"certificates" | "config" | "repositories"}`;
|
|
247
|
-
|
|
248
|
-
// Unsure, can be folder, device, channel or state (or whatever an adapter does)
|
|
249
|
-
type AdapterScoped =
|
|
250
|
-
| `${string}.${number}.${string}`;
|
|
251
|
-
|
|
252
|
-
/** All possible typed object IDs */
|
|
253
|
-
type Any =
|
|
254
|
-
| Meta
|
|
255
|
-
| Misc
|
|
256
|
-
| Channel
|
|
257
|
-
| ScriptOrChannel
|
|
258
|
-
| State
|
|
259
|
-
| Enum
|
|
260
|
-
| Instance
|
|
261
|
-
| Adapter
|
|
262
|
-
| Group
|
|
263
|
-
| User
|
|
264
|
-
| Host
|
|
265
|
-
| Config
|
|
266
|
-
| AdapterScoped;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
type ObjectIdToObjectType<
|
|
270
|
-
T extends string,
|
|
271
|
-
Read extends "read" | "write" = "read",
|
|
272
|
-
O =
|
|
273
|
-
// State must come before Adapter or system.adapter.admin.0.foobar will resolve to AdapterObject
|
|
274
|
-
T extends ObjectIDs.State ? StateObject :
|
|
275
|
-
// Instance and Adapter must come before meta or `system.adapter.admin` will resolve to MetaObject
|
|
276
|
-
T extends ObjectIDs.Instance ? InstanceObject :
|
|
277
|
-
T extends ObjectIDs.Adapter ? AdapterObject :
|
|
278
|
-
T extends ObjectIDs.Channel ? ChannelObject :
|
|
279
|
-
T extends ObjectIDs.Meta ? MetaObject :
|
|
280
|
-
T extends ObjectIDs.Misc ? AdapterScopedObject :
|
|
281
|
-
T extends ObjectIDs.ScriptOrChannel ? (ScriptObject | ChannelObject) :
|
|
282
|
-
T extends ObjectIDs.Enum ? EnumObject :
|
|
283
|
-
T extends ObjectIDs.Group ? GroupObject :
|
|
284
|
-
T extends ObjectIDs.User ? UserObject :
|
|
285
|
-
T extends ObjectIDs.Host ? HostObject :
|
|
286
|
-
T extends ObjectIDs.Config ? OtherObject & { type: "config" } :
|
|
287
|
-
T extends ObjectIDs.AdapterScoped ? AdapterScopedObject : iobJS.AnyObject
|
|
288
|
-
// When reading objects, we should be less strict, so working with the return type is less of a pain to work with
|
|
289
|
-
> = Read extends "read" ? AnyOf<O> : O;
|
|
290
|
-
|
|
291
|
-
interface ObjectCommon {
|
|
292
|
-
/** The name of this object as a simple string or an object with translations */
|
|
293
|
-
name: StringOrTranslated;
|
|
294
|
-
|
|
295
|
-
/** When set to true, this object may not be deleted */
|
|
296
|
-
dontDelete?: true;
|
|
297
|
-
|
|
298
|
-
/** When set to true, this object is only visible when expert mode is turned on in admin */
|
|
299
|
-
expert?: true;
|
|
300
|
-
|
|
301
|
-
// Icon and role aren't defined in SCHEMA.md,
|
|
302
|
-
// but they are being used by some adapters
|
|
303
|
-
/** Icon for this object */
|
|
304
|
-
icon?: string;
|
|
305
|
-
/** role of the object */
|
|
306
|
-
role?: string;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
interface StateCommonAlias {
|
|
310
|
-
/** The target state id or two target states used for reading and writing values */
|
|
311
|
-
id: string | { read: string; write: string };
|
|
312
|
-
/** An optional conversion function when reading, e.g. `"(val − 32) * 5/9"` */
|
|
313
|
-
read?: string;
|
|
314
|
-
/** An optional conversion function when reading, e.g. `"(val * 9/5) + 32"` */
|
|
315
|
-
write?: string;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
interface StateCommon extends ObjectCommon {
|
|
319
|
-
/** Type of this state. See https://github.com/ioBroker/ioBroker/blob/master/doc/SCHEMA.md#state-commonrole for a detailed description */
|
|
320
|
-
type?: CommonType;
|
|
321
|
-
/** minimum value */
|
|
322
|
-
min?: number;
|
|
323
|
-
/** maximum value */
|
|
324
|
-
max?: number;
|
|
325
|
-
/** the allowed interval for numeric values */
|
|
326
|
-
step?: number;
|
|
327
|
-
/** unit of the value */
|
|
328
|
-
unit?: string;
|
|
329
|
-
/** description of this state */
|
|
330
|
-
desc?: StringOrTranslated;
|
|
331
|
-
|
|
332
|
-
/** if this state is readable */
|
|
333
|
-
read: boolean;
|
|
334
|
-
/** if this state is writable */
|
|
335
|
-
write: boolean;
|
|
336
|
-
/** role of the state (used in user interfaces to indicate which widget to choose) */
|
|
337
|
-
role: string;
|
|
338
|
-
|
|
339
|
-
/** the default value */
|
|
340
|
-
def?: any;
|
|
341
|
-
/** the default status of the ack flag */
|
|
342
|
-
defAck?: boolean;
|
|
343
|
-
|
|
344
|
-
/** Configures this state as an alias for another state */
|
|
345
|
-
alias?: StateCommonAlias;
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* Dictionary of possible values for this state in the form
|
|
349
|
-
* <pre>
|
|
350
|
-
* {
|
|
351
|
-
* "internal value 1": "displayed value 1",
|
|
352
|
-
* "internal value 2": "displayed value 2",
|
|
353
|
-
* ...
|
|
354
|
-
* }
|
|
355
|
-
* </pre>
|
|
356
|
-
* In old ioBroker versions, this could also be a string of the form
|
|
357
|
-
* "val1:text1;val2:text2" (now deprecated)
|
|
358
|
-
*/
|
|
359
|
-
states?: Record<string, string> | string;
|
|
360
|
-
|
|
361
|
-
/** ID of a helper state indicating if the handler of this state is working */
|
|
362
|
-
workingID?: string;
|
|
363
|
-
|
|
364
|
-
/** attached history information */
|
|
365
|
-
history?: any;
|
|
366
|
-
|
|
367
|
-
/** Custom settings for this state */
|
|
368
|
-
custom?: Record<string, any>;
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* Settings for IOT adapters and how the state should be named in e.g., Alexa.
|
|
372
|
-
* The string "ignore" is a special case, causing the state to be ignored.
|
|
373
|
-
*/
|
|
374
|
-
smartName?: string | ({ [lang in Languages]?: string; } & {
|
|
375
|
-
/** Which kind of device this is */
|
|
376
|
-
smartType?: string | null;
|
|
377
|
-
/** Which value to set when the ON command is issued */
|
|
378
|
-
byOn?: string | null;
|
|
379
|
-
});
|
|
380
|
-
}
|
|
381
|
-
interface ChannelCommon extends ObjectCommon {
|
|
382
|
-
/** description of this channel */
|
|
383
|
-
desc?: string;
|
|
384
|
-
|
|
385
|
-
// Make it possible to narrow the object type using the custom property
|
|
386
|
-
custom?: undefined;
|
|
387
|
-
}
|
|
388
|
-
interface DeviceCommon extends ObjectCommon {
|
|
389
|
-
// TODO: any other definition for device?
|
|
390
|
-
|
|
391
|
-
// Make it possible to narrow the object type using the custom property
|
|
392
|
-
custom?: undefined;
|
|
393
|
-
}
|
|
394
|
-
interface EnumCommon extends ObjectCommon {
|
|
395
|
-
/** The IDs of the enum members */
|
|
396
|
-
members?: string[];
|
|
397
|
-
|
|
398
|
-
// Make it possible to narrow the object type using the custom property
|
|
399
|
-
custom?: undefined;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
interface MetaCommon extends ObjectCommon {
|
|
403
|
-
// Meta-objects have to additional CommonTypes
|
|
404
|
-
type: CommonType | "meta.user" | "meta.folder";
|
|
405
|
-
|
|
406
|
-
// Make it possible to narrow the object type using the custom property
|
|
407
|
-
custom?: undefined;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
type InstanceMode = 'none' | 'daemon' | 'subscribe' | 'schedule' | 'once' | 'extension';
|
|
411
|
-
interface InstanceCommon extends ObjectCommon {
|
|
412
|
-
/** The name of the host where this instance is running */
|
|
413
|
-
host: string;
|
|
414
|
-
enabled: boolean;
|
|
415
|
-
/** How and when this instance should be started */
|
|
416
|
-
mode: InstanceMode;
|
|
417
|
-
|
|
418
|
-
// Make it possible to narrow the object type using the custom property
|
|
419
|
-
custom?: undefined;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
interface HostCommon extends ObjectCommon {
|
|
423
|
-
/** The display name of this host */
|
|
424
|
-
name: string;
|
|
425
|
-
title: string;
|
|
426
|
-
installedVersion: string; // e.g. 1.2.3 (following semver)
|
|
427
|
-
/** The command line of the executable */
|
|
428
|
-
cmd: string;
|
|
429
|
-
hostname: string;
|
|
430
|
-
/** An array of IP addresses this host exposes */
|
|
431
|
-
address: string[]; // IPv4 or IPv6
|
|
432
|
-
|
|
433
|
-
type: 'js-controller';
|
|
434
|
-
platform: 'Javascript/Node.js';
|
|
435
|
-
|
|
436
|
-
// Make it possible to narrow the object type using the custom property
|
|
437
|
-
custom?: undefined;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
interface HostNative {
|
|
441
|
-
process: {
|
|
442
|
-
title: string;
|
|
443
|
-
versions: NodeJS.ProcessVersions;
|
|
444
|
-
env: Record<string, string>;
|
|
445
|
-
};
|
|
446
|
-
os: {
|
|
447
|
-
hostname: string,
|
|
448
|
-
type: ReturnType<typeof os["type"]>;
|
|
449
|
-
platform: ReturnType<typeof os["platform"]>;
|
|
450
|
-
arch: ReturnType<typeof os["arch"]>;
|
|
451
|
-
release: ReturnType<typeof os["release"]>;
|
|
452
|
-
endianness: ReturnType<typeof os["endianness"]>;
|
|
453
|
-
tmpdir: ReturnType<typeof os["tmpdir"]>;
|
|
454
|
-
};
|
|
455
|
-
hardware: {
|
|
456
|
-
cpus: ReturnType<typeof os["cpus"]>;
|
|
457
|
-
totalmem: ReturnType<typeof os["totalmem"]>;
|
|
458
|
-
networkInterfaces: ReturnType<typeof os["networkInterfaces"]>;
|
|
459
|
-
};
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
interface UserCommon extends ObjectCommon {
|
|
463
|
-
/** The username */
|
|
464
|
-
name: string;
|
|
465
|
-
/** The hashed password */
|
|
466
|
-
password: string;
|
|
467
|
-
/** Whether this user is enabled */
|
|
468
|
-
enabled: boolean;
|
|
469
|
-
|
|
470
|
-
// Make it possible to narrow the object type using the custom property
|
|
471
|
-
custom?: undefined;
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
interface GroupCommon extends ObjectCommon {
|
|
475
|
-
/** The name of this group */
|
|
476
|
-
name: string;
|
|
477
|
-
/** The users of this group */
|
|
478
|
-
members: string[]; // system.user.name, ...
|
|
479
|
-
/** The default permissions of this group */
|
|
480
|
-
acl: Omit<PermissionSet, "user" | "groups">;
|
|
481
|
-
|
|
482
|
-
// Make it possible to narrow the object type using the custom property
|
|
483
|
-
custom?: undefined;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
interface ScriptCommon extends ObjectCommon {
|
|
487
|
-
name: string;
|
|
488
|
-
/** Defines the type of the script, e.g. TypeScript/ts, JavaScript/js or Blockly */
|
|
489
|
-
engineType: string;
|
|
490
|
-
/** The instance id of the instance which executes this script */
|
|
491
|
-
engine: string;
|
|
492
|
-
/** The source code of this script */
|
|
493
|
-
source: string;
|
|
494
|
-
debug: boolean;
|
|
495
|
-
verbose: boolean;
|
|
496
|
-
/** Whether this script should be executed */
|
|
497
|
-
enabled: boolean;
|
|
498
|
-
/** Is used to determine whether a script has changed and needs to be recompiled */
|
|
499
|
-
sourceHash?: string;
|
|
500
|
-
/** If the script uses a compiled language like TypeScript, this contains the compilation output */
|
|
501
|
-
compiled?: string;
|
|
502
|
-
/** If the script uses a compiled language like TypeScript, this contains the generated declarations (global scripts only) */
|
|
503
|
-
declarations?: string;
|
|
504
|
-
|
|
505
|
-
// Make it possible to narrow the object type using the custom property
|
|
506
|
-
custom?: undefined;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
type WelcomeScreenEntry = string | {
|
|
510
|
-
link: string;
|
|
511
|
-
name: string;
|
|
512
|
-
img: string;
|
|
513
|
-
color: string;
|
|
514
|
-
};
|
|
515
|
-
|
|
516
|
-
interface AdapterCommon extends ObjectCommon {
|
|
517
|
-
/** Custom attributes to be shown in admin in the object browser */
|
|
518
|
-
adminColumns?: any[];
|
|
519
|
-
/** Settings for custom Admin Tabs */
|
|
520
|
-
adminTab?: {
|
|
521
|
-
name?: string;
|
|
522
|
-
/** Icon name for FontAwesome */
|
|
523
|
-
"fa-icon"?: string;
|
|
524
|
-
/** If true, the Tab is not reloaded when the configuration changes */
|
|
525
|
-
ignoreConfigUpdate?: boolean;
|
|
526
|
-
/** Which URL should be loaded in the tab. Supports placeholders like http://%ip%:%port% */
|
|
527
|
-
link?: string;
|
|
528
|
-
/** If true, only one instance of this tab will be created for all instances */
|
|
529
|
-
singleton?: boolean;
|
|
530
|
-
};
|
|
531
|
-
allowInit?: boolean;
|
|
532
|
-
/** Possible values for the instance mode (if more than one is possible) */
|
|
533
|
-
availableModes?: InstanceMode[];
|
|
534
|
-
/** Whether this adapter includes custom blocks for Blockly. If true, `admin/blockly.js` must exist. */
|
|
535
|
-
blockly?: boolean;
|
|
536
|
-
/** Where the adapter will get its data from. Set this together with @see dataSource */
|
|
537
|
-
connectionType?: "local" | "cloud";
|
|
538
|
-
/** If true, this adapter can be started in compact mode (in the same process as other adpaters) */
|
|
539
|
-
compact?: boolean;
|
|
540
|
-
/** The directory relative to iobroker-data where the adapter stores the data. Supports the placeholder `%INSTANCE%`. This folder will be backed up and restored automatically. */
|
|
541
|
-
dataFolder?: string;
|
|
542
|
-
/** How the adapter will mainly receive its data. Set this together with @see connectionType */
|
|
543
|
-
dataSource?: "poll" | "push" | "assumption";
|
|
544
|
-
/** A record of ioBroker adapters (including "js-controller") and version ranges which are required for this adapter. */
|
|
545
|
-
dependencies?: Array<Record<string, string>>;
|
|
546
|
-
/** Which files outside of the README.md have documentation for the adapter */
|
|
547
|
-
docs?: Partial<Record<Languages, string | string[]>>;
|
|
548
|
-
/** Whether new instances should be enabled by default. *Should* be `false`! */
|
|
549
|
-
enabled: boolean;
|
|
550
|
-
/** If true, all previous data in the target directory (web) should be deleted before uploading */
|
|
551
|
-
eraseOnUpload?: boolean;
|
|
552
|
-
/** URL of an external icon that is shown for adapters that are not installed */
|
|
553
|
-
extIcon?: string;
|
|
554
|
-
/** Whether this adapter responds to `getHistory` messages */
|
|
555
|
-
getHistory?: boolean;
|
|
556
|
-
/** Filename of the local icon which is shown for installed adapters. Should be located in the `admin` directory */
|
|
557
|
-
icon?: string;
|
|
558
|
-
/** Which version of this adapter is installed */
|
|
559
|
-
installedVersion: string;
|
|
560
|
-
keywords?: string[];
|
|
561
|
-
/** A dictionary of links to web services this adapter provides */
|
|
562
|
-
localLinks?: Record<string, string>;
|
|
563
|
-
/** @deprecated Use @see localLinks */
|
|
564
|
-
localLink?: string;
|
|
565
|
-
logLevel?: LogLevel;
|
|
566
|
-
/** Whether this adapter receives logs from other hosts and adapters (e.g., to strore them somewhere) */
|
|
567
|
-
logTransporter?: boolean;
|
|
568
|
-
/** Path to the start file of the adapter. Should be the same as in `package.json` */
|
|
569
|
-
main?: string;
|
|
570
|
-
/** Whether the admin tab is written in materialize style. Required for Admin 3+ */
|
|
571
|
-
materializeTab: boolean;
|
|
572
|
-
/** Whether the admin configuration dialog is written in materialize style. Required for Admin 3+ */
|
|
573
|
-
materialize: boolean;
|
|
574
|
-
/** If `true`, the object `system.adapter.<adaptername>.<adapterinstance>.messagebox will be created to send messages to the adapter (used for email, pushover, etc...) */
|
|
575
|
-
messagebox?: true;
|
|
576
|
-
mode: InstanceMode;
|
|
577
|
-
/** Name of the adapter (without leading `ioBroker.`) */
|
|
578
|
-
name: string;
|
|
579
|
-
/** If `true`, no configuration dialog will be shown */
|
|
580
|
-
noConfig?: true;
|
|
581
|
-
/** If `true`, this adapter's instances will not be shown in the admin overview screen. Useful for icon sets and widgets... */
|
|
582
|
-
noIntro?: true;
|
|
583
|
-
/** Set to `true` if the adapter is not available in the official ioBroker repositories. */
|
|
584
|
-
noRepository?: true;
|
|
585
|
-
/** If `true`, manual installation from GitHub is not possible */
|
|
586
|
-
nogit?: true;
|
|
587
|
-
/** If `true`, this adapter cannot be deleted or updated manually. */
|
|
588
|
-
nondeletable?: true;
|
|
589
|
-
/** If `true`, this "adapter" only contains HTML files and no main executable */
|
|
590
|
-
onlyWWW?: boolean;
|
|
591
|
-
/** Used to configure native (OS) dependencies of this adapter that need to be installed with system package manager before installing the adapter */
|
|
592
|
-
osDependencies?: {
|
|
593
|
-
/** For OSX */
|
|
594
|
-
darwin: string[];
|
|
595
|
-
/** For Linux */
|
|
596
|
-
linux: string[];
|
|
597
|
-
/** For Windows */
|
|
598
|
-
win32: string[];
|
|
599
|
-
};
|
|
600
|
-
/** Which OSes this adapter supports */
|
|
601
|
-
os?: "linux" | "darwin" | "win32" | Array<("linux" | "darwin" | "win32")>;
|
|
602
|
-
platform: "Javascript/Node.js";
|
|
603
|
-
/** The keys of common attributes (e.g. `history`) which are not deleted in a `setObject` call even if they are not present. Deletion must be done explicitly by setting them to `null`. */
|
|
604
|
-
preserveSettings?: string | string[];
|
|
605
|
-
/** Which adapters must be restarted after installing or updating this adapter. */
|
|
606
|
-
restartAdapters?: string[];
|
|
607
|
-
/** If the adapter runs in `schedule` mode, this contains the CRON */
|
|
608
|
-
schedule?: string;
|
|
609
|
-
serviceStates?: boolean | string;
|
|
610
|
-
/** Whether this adapter may only be installed once per host */
|
|
611
|
-
singletonHost?: boolean;
|
|
612
|
-
/** Whether this adapter may only be installed once in the whole system */
|
|
613
|
-
singleton?: boolean;
|
|
614
|
-
/** Whether the adapter must be stopped before an update */
|
|
615
|
-
stopBeforeUpdate?: boolean;
|
|
616
|
-
/** Overrides the default timeout that ioBroker will wait before force-stopping the adapter */
|
|
617
|
-
stopTimeout?: number;
|
|
618
|
-
subscribable?: boolean;
|
|
619
|
-
subscribe?: any; // ?
|
|
620
|
-
/** If `true`, this adapter provides custom per-state settings. Requires a `custom_m.html` file in the `admin` directory. */
|
|
621
|
-
supportCustoms?: boolean;
|
|
622
|
-
/** Whether the adapter supports the signal stopInstance via messagebox */
|
|
623
|
-
supportStopInstance?: boolean;
|
|
624
|
-
/** The translated names of this adapter to be shown in the admin UI */
|
|
625
|
-
titleLang?: Record<Languages, string>;
|
|
626
|
-
/** @deprecated The name of this adapter to be shown in the admin UI. Use @see titleLang instead. */
|
|
627
|
-
title?: string;
|
|
628
|
-
/** The type of this adapter */
|
|
629
|
-
type?: string;
|
|
630
|
-
/** If `true`, the `npm` package must be installed with the `--unsafe-perm` flag */
|
|
631
|
-
unsafePerm?: true;
|
|
632
|
-
/** The available version in the ioBroker repo. */
|
|
633
|
-
version: string;
|
|
634
|
-
/** If `true`, the adapter will be started if any value is written into `system.adapter.<name>.<instance>.wakeup. Normally, the adapter should stop after processing the event. */
|
|
635
|
-
wakeup?: boolean;
|
|
636
|
-
/** Include the adapter version in the URL of the web adapter, e.g. `http://ip:port/1.2.3/material` instead of `http://ip:port/material` */
|
|
637
|
-
webByVersion?: boolean;
|
|
638
|
-
/** Whether the web server in this adapter can be extended with plugin/extensions */
|
|
639
|
-
webExtendable?: boolean;
|
|
640
|
-
/** Relative path to a module that contains an extension for the web adapter. Use together with @see native.webInstance to configure which instances this affects */
|
|
641
|
-
webExtension?: string;
|
|
642
|
-
webPreSettings?: any; // ?
|
|
643
|
-
webservers?: any; // ?
|
|
644
|
-
/** A list of pages that should be shown on the "web" index page */
|
|
645
|
-
welcomeScreen?: WelcomeScreenEntry[];
|
|
646
|
-
/** A list of pages that should be shown on the ioBroker cloud index page */
|
|
647
|
-
welcomeScreenPro?: WelcomeScreenEntry[];
|
|
648
|
-
wwwDontUpload?: boolean;
|
|
649
|
-
|
|
650
|
-
// Make it possible to narrow the object type using the custom property
|
|
651
|
-
custom?: undefined;
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
interface OtherCommon extends ObjectCommon {
|
|
655
|
-
[propName: string]: any;
|
|
656
|
-
|
|
657
|
-
// Make it possible to narrow the object type using the custom property
|
|
658
|
-
custom?: undefined;
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
/* Base type for Objects. Should not be used directly */
|
|
662
|
-
interface BaseObject {
|
|
663
|
-
/** The ID of this object */
|
|
664
|
-
_id: string;
|
|
665
|
-
type: ObjectType; // specified in the derived interfaces
|
|
666
|
-
// Ideally we would limit this to JSON-serializable objects, but TypeScript doesn't allow this
|
|
667
|
-
// without bugging users to change their code --> https://github.com/microsoft/TypeScript/issues/15300
|
|
668
|
-
native: Record<string, any>;
|
|
669
|
-
common: Record<string, any>;
|
|
670
|
-
enums?: Record<string, string>;
|
|
671
|
-
acl?: ObjectACL;
|
|
672
|
-
from?: string;
|
|
673
|
-
/** The user who created or updated this object */
|
|
674
|
-
user?: string;
|
|
675
|
-
ts?: number;
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
interface StateObject extends BaseObject {
|
|
679
|
-
type: 'state';
|
|
680
|
-
common: StateCommon;
|
|
681
|
-
acl?: StateACL;
|
|
682
|
-
/** The IDs of enums this state is assigned to. For example ["enum.functions.Licht","enum.rooms.Garten"] */
|
|
683
|
-
enumIds?: string[];
|
|
684
|
-
/** The names of enums this state is assigned to. For example ["Licht","Garten"] */
|
|
685
|
-
enumNames?: Array<iobJS.StringOrTranslated>;
|
|
686
|
-
}
|
|
687
|
-
interface PartialStateObject extends Partial<Omit<StateObject, 'common' | 'acl'>> {
|
|
688
|
-
common?: Partial<StateCommon>;
|
|
689
|
-
acl?: Partial<StateACL>;
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
interface ChannelObject extends BaseObject {
|
|
693
|
-
type: 'channel';
|
|
694
|
-
common: ChannelCommon;
|
|
695
|
-
}
|
|
696
|
-
interface PartialChannelObject
|
|
697
|
-
extends Partial<Omit<ChannelObject, 'common'>> {
|
|
698
|
-
common?: Partial<ChannelCommon>;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
interface DeviceObject extends BaseObject {
|
|
702
|
-
type: 'device';
|
|
703
|
-
common: DeviceCommon;
|
|
704
|
-
}
|
|
705
|
-
interface PartialDeviceObject extends Partial<Omit<DeviceObject, 'common'>> {
|
|
706
|
-
common?: Partial<DeviceCommon>;
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
interface FolderObject extends BaseObject {
|
|
710
|
-
type: 'folder';
|
|
711
|
-
// Nothing is set in stone here, so start with allowing every property
|
|
712
|
-
common: OtherCommon;
|
|
713
|
-
}
|
|
714
|
-
interface PartialFolderObject extends Partial<Omit<FolderObject, 'common'>> {
|
|
715
|
-
common?: Partial<OtherCommon>;
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
interface EnumObject extends BaseObject {
|
|
719
|
-
type: 'enum';
|
|
720
|
-
common: EnumCommon;
|
|
721
|
-
}
|
|
722
|
-
interface PartialEnumObject extends Partial<Omit<EnumObject, 'common'>> {
|
|
723
|
-
common?: Partial<EnumCommon>;
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
interface MetaObject extends BaseObject {
|
|
727
|
-
type: 'meta';
|
|
728
|
-
common: MetaCommon;
|
|
729
|
-
}
|
|
730
|
-
interface PartialMetaObject extends Partial<Omit<MetaObject, 'common'>> {
|
|
731
|
-
common?: Partial<MetaCommon>;
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
interface InstanceObject extends BaseObject {
|
|
735
|
-
type: 'instance';
|
|
736
|
-
common: InstanceCommon;
|
|
737
|
-
}
|
|
738
|
-
interface PartialInstanceObject extends Partial<Omit<InstanceObject, 'common'>> {
|
|
739
|
-
common?: Partial<InstanceCommon>;
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
interface AdapterObject extends BaseObject {
|
|
743
|
-
type: 'adapter';
|
|
744
|
-
common: AdapterCommon;
|
|
745
|
-
/** An array of `native` properties which cannot be accessed from outside the defining adapter */
|
|
746
|
-
protectedNative?: string[];
|
|
747
|
-
/** Like protectedNative, but the properties are also encrypted and decrypted automatically */
|
|
748
|
-
encryptedNative?: string[];
|
|
749
|
-
}
|
|
750
|
-
interface PartialAdapterObject extends Partial<Omit<AdapterObject, 'common'>> {
|
|
751
|
-
common?: Partial<AdapterCommon>;
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
interface HostObject extends BaseObject {
|
|
755
|
-
type: 'host';
|
|
756
|
-
common: HostCommon;
|
|
757
|
-
native: HostNative;
|
|
758
|
-
}
|
|
759
|
-
interface PartialHostObject extends Partial<Omit<HostObject, 'common' | 'native'>> {
|
|
760
|
-
common?: Partial<HostCommon>;
|
|
761
|
-
native?: Partial<HostNative>;
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
interface UserObject extends BaseObject {
|
|
765
|
-
type: 'user';
|
|
766
|
-
common: UserCommon;
|
|
767
|
-
}
|
|
768
|
-
interface PartialUserObject extends Partial<Omit<UserObject, 'common'>> {
|
|
769
|
-
common?: Partial<UserCommon>;
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
interface GroupObject extends BaseObject {
|
|
773
|
-
type: 'group';
|
|
774
|
-
common: GroupCommon;
|
|
775
|
-
}
|
|
776
|
-
interface PartialGroupObject extends Partial<Omit<GroupObject, 'common'>> {
|
|
777
|
-
common?: Partial<GroupCommon>;
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
interface ScriptObject extends BaseObject {
|
|
781
|
-
type: 'script';
|
|
782
|
-
common: ScriptCommon;
|
|
783
|
-
}
|
|
784
|
-
interface PartialScriptObject extends Partial<Omit<ScriptObject, 'common'>> {
|
|
785
|
-
common?: Partial<ScriptCommon>;
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
interface OtherObject extends BaseObject {
|
|
789
|
-
type: 'config' | 'chart';
|
|
790
|
-
common: OtherCommon;
|
|
791
|
-
}
|
|
792
|
-
interface PartialOtherObject extends Partial<Omit<OtherObject, 'common'>> {
|
|
793
|
-
common?: Partial<OtherCommon>;
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
type AnyObject =
|
|
797
|
-
| StateObject
|
|
798
|
-
| ChannelObject
|
|
799
|
-
| DeviceObject
|
|
800
|
-
| FolderObject
|
|
801
|
-
| EnumObject
|
|
802
|
-
| MetaObject
|
|
803
|
-
| HostObject
|
|
804
|
-
| AdapterObject
|
|
805
|
-
| InstanceObject
|
|
806
|
-
| UserObject
|
|
807
|
-
| GroupObject
|
|
808
|
-
| ScriptObject
|
|
809
|
-
| OtherObject;
|
|
810
|
-
|
|
811
|
-
type AnyPartialObject =
|
|
812
|
-
| PartialStateObject
|
|
813
|
-
| PartialChannelObject
|
|
814
|
-
| PartialDeviceObject
|
|
815
|
-
| PartialFolderObject
|
|
816
|
-
| PartialEnumObject
|
|
817
|
-
| PartialMetaObject
|
|
818
|
-
| PartialHostObject
|
|
819
|
-
| PartialAdapterObject
|
|
820
|
-
| PartialInstanceObject
|
|
821
|
-
| PartialUserObject
|
|
822
|
-
| PartialGroupObject
|
|
823
|
-
| PartialScriptObject
|
|
824
|
-
| PartialOtherObject;
|
|
825
|
-
|
|
826
|
-
/** All objects that usually appear in an adapter scope */
|
|
827
|
-
type AdapterScopedObject = FolderObject | DeviceObject | ChannelObject | StateObject;
|
|
828
|
-
|
|
829
|
-
// For all objects that are exposed to the user we need to tone the strictness down.
|
|
830
|
-
// Otherwise, every operation on objects becomes a pain to work with
|
|
831
|
-
type Object = AnyObject;
|
|
832
|
-
|
|
833
|
-
// In set[Foreign]Object[NotExists] methods, the ID and acl of the object is optional
|
|
834
|
-
type SettableObjectWorker<T> = T extends AnyObject ? Omit<T, '_id' | 'acl'> & {
|
|
835
|
-
_id?: T['_id'];
|
|
836
|
-
acl?: T['acl'];
|
|
837
|
-
} : never;
|
|
838
|
-
// in extend[Foreign]Object, most properties are optional
|
|
839
|
-
type PartialObjectWorker<T> = T extends AnyObject ? AnyPartialObject & { type?: T["type"] } : never;
|
|
840
|
-
|
|
841
|
-
type PartialObject<T extends AnyObject = AnyObject> = PartialObjectWorker<T>;
|
|
842
|
-
|
|
843
|
-
// Convenient definitions for manually specifying settable object types
|
|
844
|
-
type SettableObject<T extends AnyObject = AnyObject> = SettableObjectWorker<T>;
|
|
845
|
-
type SettableStateObject = SettableObject<StateObject>;
|
|
846
|
-
type SettableChannelObject = SettableObject<ChannelObject>;
|
|
847
|
-
type SettableDeviceObject = SettableObject<DeviceObject>;
|
|
848
|
-
type SettableFolderObject = SettableObject<FolderObject>;
|
|
849
|
-
type SettableEnumObject = SettableObject<EnumObject>;
|
|
850
|
-
type SettableMetaObject = SettableObject<MetaObject>;
|
|
851
|
-
type SettableHostObject = SettableObject<HostObject>;
|
|
852
|
-
type SettableAdapterObject = SettableObject<AdapterObject>;
|
|
853
|
-
type SettableInstanceObject = SettableObject<InstanceObject>;
|
|
854
|
-
type SettableUserObject = SettableObject<UserObject>;
|
|
855
|
-
type SettableGroupObject = SettableObject<GroupObject>;
|
|
856
|
-
type SettableScriptObject = SettableObject<ScriptObject>;
|
|
857
|
-
type SettableOtherObject = SettableObject<OtherObject>;
|
|
858
|
-
|
|
859
|
-
/** Represents the change of a state */
|
|
860
|
-
interface ChangedStateObject<TOld extends StateValue = any, TNew extends StateValue = TOld> extends StateObject {
|
|
861
|
-
common: StateCommon;
|
|
862
|
-
native: Record<string, any>;
|
|
863
|
-
id?: string;
|
|
864
|
-
name?: string;
|
|
865
|
-
channelId?: string;
|
|
866
|
-
channelName?: string;
|
|
867
|
-
deviceId?: string;
|
|
868
|
-
deviceName?: string;
|
|
869
|
-
/** The IDs of enums this state is assigned to. For example ["enum.functions.Licht","enum.rooms.Garten"] */
|
|
870
|
-
enumIds?: string[];
|
|
871
|
-
/** The names of enums this state is assigned to. For example ["Licht","Garten"] */
|
|
872
|
-
enumNames?: Array<iobJS.StringOrTranslated>;
|
|
873
|
-
/** new state */
|
|
874
|
-
state: State<TNew>;
|
|
875
|
-
/** @deprecated Use state instead **/
|
|
876
|
-
newState: State<TNew>;
|
|
877
|
-
/** previous state */
|
|
878
|
-
oldState: State<TOld>;
|
|
879
|
-
/** Name of the adapter instance which set the value, e.g. "system.adapter.web.0" */
|
|
880
|
-
from?: string;
|
|
881
|
-
/** Unix timestamp. Default: current time */
|
|
882
|
-
ts?: number;
|
|
883
|
-
/** Unix timestamp of the last time the value changed */
|
|
884
|
-
lc?: number;
|
|
885
|
-
/** Direction flag: false for desired value and true for actual value. Default: false. */
|
|
886
|
-
ack?: boolean;
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
type GetStateCallback<T extends StateValue = any> = (err?: string | null, state?: State<T> | AbsentState) => void | Promise<void>;
|
|
890
|
-
type ExistsStateCallback = (err?: string | null, exists?: Boolean) => void | Promise<void>;
|
|
891
|
-
|
|
892
|
-
type SetStateCallback = (err?: string | null, id?: string) => void | Promise<void>;
|
|
893
|
-
type SetStatePromise = Promise<NonNullCallbackReturnTypeOf<SetStateCallback>>;
|
|
894
|
-
|
|
895
|
-
type StateChangeHandler<TOld extends StateValue = any, TNew extends TOld = any> = (obj: ChangedStateObject<TOld, TNew>) => void | Promise<void>;
|
|
896
|
-
type ObjectChangeHandler = (id: string, obj: iobJS.Object) => void | Promise<void>;
|
|
897
|
-
|
|
898
|
-
type FileChangeHandler<WithFile extends boolean> =
|
|
899
|
-
// Variant 1: WithFile is false, data/mimeType is definitely not there
|
|
900
|
-
[WithFile] extends [false] ? (id: string, fileName: string, size: number, data?: undefined, mimeType?: undefined) => void | Promise<void>
|
|
901
|
-
// Variant 2: WithFile is true, data (and mimeType?) is definitely there
|
|
902
|
-
: [WithFile] extends [true] ? (id: string, fileName: string, size: number, data: Buffer | string, mimeType?: string) => void | Promise<void>
|
|
903
|
-
// Variant 3: WithFile is not known, data/mimeType might be there
|
|
904
|
-
: (id: string, fileName: string, size: number, data?: Buffer | string, mimeType?: string) => void | Promise<void>;
|
|
905
|
-
|
|
906
|
-
type SetObjectCallback = (err?: string | null, obj?: { id: string }) => void | Promise<void>;
|
|
907
|
-
type SetObjectPromise = Promise<NonNullCallbackReturnTypeOf<SetObjectCallback>>;
|
|
908
|
-
|
|
909
|
-
type GetObjectCallback<T extends string = string> = (err?: string | null, obj?: ObjectIdToObjectType<T> | null) => void;
|
|
910
|
-
type GetObjectPromise<T extends string = string> = Promise<CallbackReturnTypeOf<GetObjectCallback<T>>>;
|
|
911
|
-
|
|
912
|
-
type LogLevel = "silly" | "debug" | "info" | "warn" | "error" | "force";
|
|
913
|
-
|
|
914
|
-
type ReadFileCallback = (err?: string | null, file?: Buffer | string, mimeType?: string) => void | Promise<void>;
|
|
915
|
-
type ReadFilePromise = Promise<NonNullCallbackReturnTypeOf<ReadFileCallback>>;
|
|
916
|
-
|
|
917
|
-
/** Callback information for a passed message */
|
|
918
|
-
interface MessageCallbackInfo {
|
|
919
|
-
/** The original message payload */
|
|
920
|
-
message: string | object;
|
|
921
|
-
/** ID of this callback */
|
|
922
|
-
id: number;
|
|
923
|
-
// ???
|
|
924
|
-
ack: boolean;
|
|
925
|
-
/** Timestamp of this message */
|
|
926
|
-
time: number;
|
|
927
|
-
}
|
|
928
|
-
type MessageCallback = (result?: any) => void | Promise<void>;
|
|
929
|
-
|
|
930
|
-
interface SendToOptions {
|
|
931
|
-
/** Method throws or calls error cb, if callback not called in time, works for single targets only */
|
|
932
|
-
timeout?: number;
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
interface Subscription {
|
|
936
|
-
name: string;
|
|
937
|
-
pattern: string | RegExp | string[] | iobJS.SubscribeOptions | iobJS.SubscribeTime | iobJS.AstroSchedule;
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
interface SubscribeOptions {
|
|
941
|
-
/** "and" or "or" logic to combine the conditions (default: "and") */
|
|
942
|
-
logic?: "and" | "or";
|
|
943
|
-
/** name is equal or matches to given one or name marches to any item in given list */
|
|
944
|
-
id?: string | string[] | SubscribeOptions[] | RegExp | RegExp[];
|
|
945
|
-
/** name is equal or matches to given one */
|
|
946
|
-
name?: string | string[] | RegExp;
|
|
947
|
-
/** type of change */
|
|
948
|
-
change?: "eq" | "ne" | "gt" | "ge" | "lt" | "le" | "any" | "*";
|
|
949
|
-
val?: StateValue;
|
|
950
|
-
/** New value must not be equal to given one */
|
|
951
|
-
valNe?: StateValue;
|
|
952
|
-
/** New value must be greater than given one */
|
|
953
|
-
valGt?: number;
|
|
954
|
-
/** New value must be greater or equal to given one */
|
|
955
|
-
valGe?: number;
|
|
956
|
-
/** New value must be smaller than given one */
|
|
957
|
-
valLt?: number;
|
|
958
|
-
/** New value must be smaller or equal to given one */
|
|
959
|
-
valLe?: number;
|
|
960
|
-
/** Acknowledged state of new value is equal to given one */
|
|
961
|
-
ack?: boolean;
|
|
962
|
-
/** Previous value must be equal to given one */
|
|
963
|
-
oldVal?: StateValue;
|
|
964
|
-
/** Previous value must be not equal to given one */
|
|
965
|
-
oldValNe?: StateValue;
|
|
966
|
-
/** Previous value must be greater than given one */
|
|
967
|
-
oldValGt?: number;
|
|
968
|
-
/** Previous value must be greater or equal given one */
|
|
969
|
-
oldValGe?: number;
|
|
970
|
-
/** Previous value must be smaller than given one */
|
|
971
|
-
oldValLt?: number;
|
|
972
|
-
/** Previous value must be smaller or equal to given one */
|
|
973
|
-
oldValLe?: number;
|
|
974
|
-
/** Acknowledged state of previous value is equal to given one */
|
|
975
|
-
oldAck?: boolean;
|
|
976
|
-
/** New value time stamp must be equal to given one (state.ts == ts) */
|
|
977
|
-
ts?: number;
|
|
978
|
-
/** New value time stamp must be not equal to the given one (state.ts != ts) */
|
|
979
|
-
tsGt?: number;
|
|
980
|
-
/** New value time stamp must be greater than given value (state.ts > ts) */
|
|
981
|
-
tsGe?: number;
|
|
982
|
-
/** New value time stamp must be greater or equal to given one (state.ts >= ts) */
|
|
983
|
-
tsLt?: number;
|
|
984
|
-
/** New value time stamp must be smaller than given one (state.ts < ts) */
|
|
985
|
-
tsLe?: number;
|
|
986
|
-
/** Previous time stamp must be equal to given one (oldState.ts == ts) */
|
|
987
|
-
oldTs?: number;
|
|
988
|
-
/** Previous time stamp must be not equal to the given one (oldState.ts != ts) */
|
|
989
|
-
oldTsGt?: number;
|
|
990
|
-
/** Previous time stamp must be greater than the given value (oldState.ts > ts) */
|
|
991
|
-
oldTsGe?: number;
|
|
992
|
-
/** Previous time stamp must be greater or equal to given one (oldState.ts >= ts) */
|
|
993
|
-
oldTsLt?: number;
|
|
994
|
-
/** Previous time stamp must be smaller than given one (oldState.ts < ts) */
|
|
995
|
-
oldTsLe?: number;
|
|
996
|
-
/** Last change time stamp must be equal to given one (state.lc == lc) */
|
|
997
|
-
lc?: number;
|
|
998
|
-
/** Last change time stamp must be not equal to the given one (state.lc != lc) */
|
|
999
|
-
lcGt?: number;
|
|
1000
|
-
/** Last change time stamp must be greater than the given value (state.lc > lc) */
|
|
1001
|
-
lcGe?: number;
|
|
1002
|
-
/** Last change time stamp must be greater or equal to given one (state.lc >= lc) */
|
|
1003
|
-
lcLt?: number;
|
|
1004
|
-
/** Last change time stamp must be smaller than given one (state.lc < lc) */
|
|
1005
|
-
lcLe?: number;
|
|
1006
|
-
/** Previous last change time stamp must be equal to given one (oldState.lc == lc) */
|
|
1007
|
-
oldLc?: number;
|
|
1008
|
-
/** Previous last change time stamp must be not equal to the given one (oldState.lc != lc) */
|
|
1009
|
-
oldLcGt?: number;
|
|
1010
|
-
/** Previous last change time stamp must be greater than the given value (oldState.lc > lc) */
|
|
1011
|
-
oldLcGe?: number;
|
|
1012
|
-
/** Previous last change time stamp must be greater or equal to given one (oldState.lc >= lc) */
|
|
1013
|
-
oldLcLt?: number;
|
|
1014
|
-
/** Previous last change time stamp must be smaller than given one (oldState.lc < lc) */
|
|
1015
|
-
oldLcLe?: number;
|
|
1016
|
-
/** Channel ID must be equal or match to given one */
|
|
1017
|
-
channelId?: string | string[] | RegExp;
|
|
1018
|
-
/** Channel name must be equal or match to given one */
|
|
1019
|
-
channelName?: string | string[] | RegExp;
|
|
1020
|
-
/** Device ID must be equal or match to given one */
|
|
1021
|
-
deviceId?: string | string[] | RegExp;
|
|
1022
|
-
/** Device name must be equal or match to given one */
|
|
1023
|
-
deviceName?: string | string[] | RegExp;
|
|
1024
|
-
/** State belongs to given enum or one enum ID of state satisfy the given regular expression */
|
|
1025
|
-
enumId?: string | string[] | RegExp;
|
|
1026
|
-
/** State belongs to given enum or one enum name of state satisfy the given regular expression */
|
|
1027
|
-
enumName?: string | string[] | RegExp;
|
|
1028
|
-
/** New value is from defined adapter */
|
|
1029
|
-
from?: string | string[] | RegExp;
|
|
1030
|
-
/** New value is not from defined adapter */
|
|
1031
|
-
fromNe?: string | string[] | RegExp;
|
|
1032
|
-
/** Old value is from defined adapter */
|
|
1033
|
-
oldFrom?: string | string[] | RegExp;
|
|
1034
|
-
/** Old value is not from defined adapter */
|
|
1035
|
-
oldFromNe?: string | string[] | RegExp;
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
interface QueryResult extends Iterable<string> {
|
|
1039
|
-
/** State-ID */
|
|
1040
|
-
[index: number]: string;
|
|
1041
|
-
/** Number of matched states */
|
|
1042
|
-
length: number;
|
|
1043
|
-
/** Contains the error if one happened */
|
|
1044
|
-
error?: string;
|
|
1045
|
-
|
|
1046
|
-
/**
|
|
1047
|
-
* Return the result as an array of state ids
|
|
1048
|
-
*/
|
|
1049
|
-
toArray(): Array<string>;
|
|
1050
|
-
|
|
1051
|
-
/**
|
|
1052
|
-
* Executes a function for each state id in the result array
|
|
1053
|
-
* The execution is canceled if a callback returns false
|
|
1054
|
-
*/
|
|
1055
|
-
each(callback?: (id: string, index: number) => boolean | void | Promise<void>): this;
|
|
1056
|
-
|
|
1057
|
-
/**
|
|
1058
|
-
* Returns the first state found by this query.
|
|
1059
|
-
* If the adapter is configured to subscribe to all states on start,
|
|
1060
|
-
* this can be called synchronously and immediately returns the state.
|
|
1061
|
-
* Otherwise, you need to provide a callback.
|
|
1062
|
-
*/
|
|
1063
|
-
getState<T extends StateValue = any>(callback: GetStateCallback<T>): void;
|
|
1064
|
-
getState<T extends StateValue = any>(): State<T> | null | undefined;
|
|
1065
|
-
getStateAsync<T extends StateValue = any>(): Promise<State<T> | null | undefined>;
|
|
1066
|
-
|
|
1067
|
-
/**
|
|
1068
|
-
* Sets all queried states to the given value.
|
|
1069
|
-
*/
|
|
1070
|
-
setState(state: State | StateValue | SettableState, ack?: boolean, callback?: SetStateCallback): this;
|
|
1071
|
-
setStateAsync(state: State | StateValue | SettableState, ack?: boolean): Promise<void>;
|
|
1072
|
-
setStateDelayed(state: any, isAck?: boolean, delay?: number, clearRunning?: boolean, callback?: SetStateCallback): this;
|
|
1073
|
-
|
|
1074
|
-
/**
|
|
1075
|
-
* Sets all queried states to the given value only if the value really changed.
|
|
1076
|
-
*/
|
|
1077
|
-
setStateChanged(state: State | StateValue | SettableState, ack?: boolean, callback?: SetStateCallback): this;
|
|
1078
|
-
setStateChangedAsync(state: State | StateValue | SettableState, ack?: boolean): Promise<void>;
|
|
1079
|
-
|
|
1080
|
-
/**
|
|
1081
|
-
* Subscribes the given callback to changes of the matched states.
|
|
1082
|
-
*/
|
|
1083
|
-
on(callback: StateChangeHandler): this;
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
/**
|
|
1087
|
-
* * "sunrise": sunrise (top edge of the sun appears on the horizon)
|
|
1088
|
-
* * "sunriseEnd": sunrise ends (bottom edge of the sun touches the horizon)
|
|
1089
|
-
* * "goldenHourEnd": morning golden hour (soft light, best time for photography) ends
|
|
1090
|
-
* * "solarNoon": solar noon (sun is in the highest position)
|
|
1091
|
-
* * "goldenHour": evening golden hour starts
|
|
1092
|
-
* * "sunsetStart": sunset starts (bottom edge of the sun touches the horizon)
|
|
1093
|
-
* * "sunset": sunset (sun disappears below the horizon, evening civil twilight starts)
|
|
1094
|
-
* * "dusk": dusk (evening nautical twilight starts)
|
|
1095
|
-
* * "nauticalDusk": nautical dusk (evening astronomical twilight starts)
|
|
1096
|
-
* * "night": night starts (dark enough for astronomical observations)
|
|
1097
|
-
* * "nightEnd": night ends (morning astronomical twilight starts)
|
|
1098
|
-
* * "nauticalDawn": nautical dawn (morning nautical twilight starts)
|
|
1099
|
-
* * "dawn": dawn (morning nautical twilight ends, morning civil twilight starts)
|
|
1100
|
-
* * "nadir": nadir (darkest moment of the night, sun is in the lowest position)
|
|
1101
|
-
*/
|
|
1102
|
-
type AstroPattern = "sunrise" | "sunriseEnd" | "goldenHourEnd" | "solarNoon" | "goldenHour" | "sunsetStart" | "sunset" | "dusk" | "nauticalDusk" | "night" | "nightEnd" | "nauticalDawn" | "dawn" | "nadir";
|
|
1103
|
-
|
|
1104
|
-
interface AstroSchedule {
|
|
1105
|
-
astro: AstroPattern;
|
|
1106
|
-
/**
|
|
1107
|
-
* Shift to the astro schedule.
|
|
1108
|
-
*/
|
|
1109
|
-
shift?: number;
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
interface AstroDate {
|
|
1113
|
-
astro: AstroPattern;
|
|
1114
|
-
/** Offset to the astro event in minutes */
|
|
1115
|
-
offset?: number;
|
|
1116
|
-
/** Date for which the astro time is wanted */
|
|
1117
|
-
date?: Date;
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
/**
|
|
1121
|
-
* from https://github.com/node-schedule/node-schedule
|
|
1122
|
-
*/
|
|
1123
|
-
interface ScheduleRule {
|
|
1124
|
-
/**
|
|
1125
|
-
* Day of the month.
|
|
1126
|
-
*/
|
|
1127
|
-
date?: number | number[] | string | string[];
|
|
1128
|
-
|
|
1129
|
-
/**
|
|
1130
|
-
* Day of the week.
|
|
1131
|
-
*/
|
|
1132
|
-
dayOfWeek?: number | number[] | string | string[];
|
|
1133
|
-
|
|
1134
|
-
/**
|
|
1135
|
-
* Hour.
|
|
1136
|
-
*/
|
|
1137
|
-
hour?: number | number[] | string | string[];
|
|
1138
|
-
|
|
1139
|
-
/**
|
|
1140
|
-
* Minute.
|
|
1141
|
-
*/
|
|
1142
|
-
minute?: number | number[] | string | string[];
|
|
1143
|
-
|
|
1144
|
-
/**
|
|
1145
|
-
* Month.
|
|
1146
|
-
*/
|
|
1147
|
-
month?: number | number[] | string | string[];
|
|
1148
|
-
|
|
1149
|
-
/**
|
|
1150
|
-
* Second.
|
|
1151
|
-
*/
|
|
1152
|
-
second?: number | number[] | string | string[];
|
|
1153
|
-
|
|
1154
|
-
/**
|
|
1155
|
-
* Year.
|
|
1156
|
-
*/
|
|
1157
|
-
year?: number | number[] | string | string[];
|
|
1158
|
-
/**
|
|
1159
|
-
* timezone which should be used
|
|
1160
|
-
* https://github.com/moment/moment-timezone
|
|
1161
|
-
*/
|
|
1162
|
-
tz?: string;
|
|
1163
|
-
}
|
|
1164
|
-
|
|
1165
|
-
/**
|
|
1166
|
-
* from https://github.com/node-schedule/node-schedule
|
|
1167
|
-
*/
|
|
1168
|
-
interface ScheduleRuleConditional {
|
|
1169
|
-
/**
|
|
1170
|
-
* set a start time for schedule
|
|
1171
|
-
* a Data object or a dateString resp a number in milliseconds which can create a Date object
|
|
1172
|
-
*/
|
|
1173
|
-
start?: Date | string | number;
|
|
1174
|
-
/**
|
|
1175
|
-
* set an end time for schedule
|
|
1176
|
-
* a Data object or a dateString resp a number in milliseconds which can create a Date object
|
|
1177
|
-
*/
|
|
1178
|
-
end?: Date | string | number;
|
|
1179
|
-
/**
|
|
1180
|
-
* timezone which should be used
|
|
1181
|
-
* https://github.com/moment/moment-timezone
|
|
1182
|
-
*/
|
|
1183
|
-
tz?: string;
|
|
1184
|
-
/**
|
|
1185
|
-
* scheduling rule
|
|
1186
|
-
* schedule rule, a Data object or a dateString resp a number in milliseconds which can create a Date object
|
|
1187
|
-
*/
|
|
1188
|
-
rule: ScheduleRule | Date | string | number;
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
|
-
interface ScheduleStatus {
|
|
1192
|
-
type: string;
|
|
1193
|
-
pattern?: string;
|
|
1194
|
-
scriptName: string;
|
|
1195
|
-
id: string;
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1198
|
-
interface LogMessage {
|
|
1199
|
-
severity: LogLevel; // severity
|
|
1200
|
-
ts: number; // timestamp as Date.now()
|
|
1201
|
-
message: string; // message
|
|
1202
|
-
from: string; // origin of the message
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
type SchedulePattern = ScheduleRule | ScheduleRuleConditional | Date | string | number;
|
|
1206
|
-
|
|
1207
|
-
interface SubscribeTime {
|
|
1208
|
-
time: SchedulePattern;
|
|
1209
|
-
}
|
|
1210
|
-
|
|
1211
|
-
interface StateTimer {
|
|
1212
|
-
id: number;
|
|
1213
|
-
left: number;
|
|
1214
|
-
delay: number;
|
|
1215
|
-
val: any;
|
|
1216
|
-
ack: boolean;
|
|
1217
|
-
}
|
|
1218
|
-
|
|
1219
|
-
type MessageSubscribeID = number;
|
|
1220
|
-
interface MessageTarget {
|
|
1221
|
-
/** Javascript Instance */
|
|
1222
|
-
instance?: string;
|
|
1223
|
-
/** Script name */
|
|
1224
|
-
script?: string;
|
|
1225
|
-
/** Message name */
|
|
1226
|
-
message: string;
|
|
1227
|
-
}
|
|
1228
|
-
|
|
1229
|
-
type LogSubscribeID = number;
|
|
1230
|
-
|
|
1231
|
-
interface HttpRequestOptions {
|
|
1232
|
-
timeout?: number;
|
|
1233
|
-
responseType?: "text" | "arraybuffer";
|
|
1234
|
-
basicAuth?: {
|
|
1235
|
-
user: string;
|
|
1236
|
-
password: string;
|
|
1237
|
-
},
|
|
1238
|
-
bearerAuth?: string;
|
|
1239
|
-
headers?: Record<string, string>;
|
|
1240
|
-
validateCertificate?: boolean;
|
|
1241
|
-
}
|
|
1242
|
-
|
|
1243
|
-
type HttpResponseCallback = (err?: string | null, response?: iobJS.httpResponse) => void | Promise<void>;
|
|
1244
|
-
interface httpResponse {
|
|
1245
|
-
statusCode: number;
|
|
1246
|
-
data: string;
|
|
1247
|
-
headers: Record<string, string>;
|
|
1248
|
-
responseTime?: number;
|
|
1249
|
-
}
|
|
1250
|
-
} // end namespace iobJS
|
|
1251
|
-
|
|
1252
|
-
// =======================================================
|
|
1253
|
-
// available functions in the sandbox
|
|
1254
|
-
// =======================================================
|
|
1255
|
-
|
|
1256
|
-
/**
|
|
1257
|
-
* The instance number of the JavaScript adapter this script runs in
|
|
1258
|
-
*/
|
|
1259
|
-
const instance: number;
|
|
1260
|
-
/**
|
|
1261
|
-
* The name of the current script
|
|
1262
|
-
*/
|
|
1263
|
-
// @ts-ignore We need this variable, although it conflicts with lib.es6
|
|
1264
|
-
const name: string;
|
|
1265
|
-
/**
|
|
1266
|
-
* The name of the current script
|
|
1267
|
-
*/
|
|
1268
|
-
const scriptName: string;
|
|
1269
|
-
|
|
1270
|
-
/**
|
|
1271
|
-
* Absolute path to iobroker-data directory in file system
|
|
1272
|
-
*/
|
|
1273
|
-
const defaultDataDir: string;
|
|
1274
|
-
|
|
1275
|
-
/**
|
|
1276
|
-
* Status of verbose mode
|
|
1277
|
-
*/
|
|
1278
|
-
const verbose: boolean;
|
|
1279
|
-
|
|
1280
|
-
/**
|
|
1281
|
-
* Queries all states with the given selector
|
|
1282
|
-
* @param selector See @link{https://github.com/ioBroker/ioBroker.javascript#---selector} for a description
|
|
1283
|
-
*/
|
|
1284
|
-
// @ts-ignore We need this function, although it conflicts with vue
|
|
1285
|
-
function $(selector: string): iobJS.QueryResult;
|
|
1286
|
-
|
|
1287
|
-
/**
|
|
1288
|
-
* Prints a message in the ioBroker log
|
|
1289
|
-
* @param message The message to print
|
|
1290
|
-
* @param severity (optional) severity of the message. default = "info"
|
|
1291
|
-
*/
|
|
1292
|
-
function log(message: any, severity?: iobJS.LogLevel): void;
|
|
1293
|
-
|
|
1294
|
-
// console functions
|
|
1295
|
-
// @ts-ignore We need this variable, although it conflicts with the node typings
|
|
1296
|
-
namespace console {
|
|
1297
|
-
/** log a message with info level */
|
|
1298
|
-
function log(message: any): void;
|
|
1299
|
-
/** log a message with debug level */
|
|
1300
|
-
function debug(message: any): void;
|
|
1301
|
-
/** log a message with info level (default output level for all adapters) */
|
|
1302
|
-
function info(message: any): void;
|
|
1303
|
-
/** log a message with warning severity */
|
|
1304
|
-
function warn(message: any): void;
|
|
1305
|
-
/** log a message with error severity */
|
|
1306
|
-
function error(message: any): void;
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
/**
|
|
1310
|
-
* Executes a system command
|
|
1311
|
-
*/
|
|
1312
|
-
const exec: typeof import("child_process").exec;
|
|
1313
|
-
|
|
1314
|
-
/**
|
|
1315
|
-
* Sends an email using the email adapter.
|
|
1316
|
-
* See the adapter documentation for a description of the msg parameter.
|
|
1317
|
-
*
|
|
1318
|
-
* @deprecated Use @see sendTo
|
|
1319
|
-
*/
|
|
1320
|
-
function email(msg: any): void;
|
|
1321
|
-
|
|
1322
|
-
/**
|
|
1323
|
-
* Sends a pushover message using the pushover adapter.
|
|
1324
|
-
* See the adapter documentation for a description of the msg parameter.
|
|
1325
|
-
*
|
|
1326
|
-
* @deprecated Use @see sendTo
|
|
1327
|
-
*/
|
|
1328
|
-
function pushover(msg: any): void;
|
|
1329
|
-
|
|
1330
|
-
function httpGet(url: string, callback: iobJS.HttpResponseCallback): void;
|
|
1331
|
-
function httpGet(url: string, options: iobJS.HttpRequestOptions, callback: iobJS.HttpResponseCallback): void;
|
|
1332
|
-
|
|
1333
|
-
function httpGetAsync(url: string): Promise<iobJS.httpResponse>;
|
|
1334
|
-
function httpGetAsync(url: string, options: iobJS.HttpRequestOptions): Promise<iobJS.httpResponse>;
|
|
1335
|
-
|
|
1336
|
-
function httpPost(url: string, data: object | string, callback: iobJS.HttpResponseCallback): void;
|
|
1337
|
-
function httpPost(url: string, data: object | string, options: iobJS.HttpRequestOptions, callback: iobJS.HttpResponseCallback): void;
|
|
1338
|
-
|
|
1339
|
-
function httpPostAsync(url: string, data: object | string): Promise<iobJS.httpResponse>;
|
|
1340
|
-
function httpPostAsync(url: string, data: object | string, options: iobJS.HttpRequestOptions): Promise<iobJS.httpResponse>;
|
|
1341
|
-
|
|
1342
|
-
/**
|
|
1343
|
-
* Creates a temp directory for the current script and saves a new file with given content
|
|
1344
|
-
*/
|
|
1345
|
-
function createTempFile(fileName: string, data: string | ArrayBuffer) : string;
|
|
1346
|
-
|
|
1347
|
-
/**
|
|
1348
|
-
* Subscribe to the changes of the matched states.
|
|
1349
|
-
*/
|
|
1350
|
-
function on(pattern: string | RegExp | string[], handler: iobJS.StateChangeHandler): any;
|
|
1351
|
-
function on(
|
|
1352
|
-
astroOrScheduleOrOptions: iobJS.AstroSchedule | iobJS.SubscribeTime | iobJS.SubscribeOptions,
|
|
1353
|
-
handler: iobJS.StateChangeHandler
|
|
1354
|
-
): any;
|
|
1355
|
-
/**
|
|
1356
|
-
* Subscribe to the changes of the matched states.
|
|
1357
|
-
*/
|
|
1358
|
-
function subscribe(pattern: string | RegExp | string[], handler: iobJS.StateChangeHandler): any;
|
|
1359
|
-
function subscribe(
|
|
1360
|
-
astroOrScheduleOrOptions: iobJS.AstroSchedule | iobJS.SubscribeTime | iobJS.SubscribeOptions,
|
|
1361
|
-
handler: iobJS.StateChangeHandler
|
|
1362
|
-
): any;
|
|
1363
|
-
|
|
1364
|
-
/**
|
|
1365
|
-
* Subscribe to all members of an enum (even if the enum changes over time)
|
|
1366
|
-
*/
|
|
1367
|
-
function onEnumMembers(id: string, handler: iobJS.StateChangeHandler): void;
|
|
1368
|
-
|
|
1369
|
-
/**
|
|
1370
|
-
* Subscribe to the changes of the matched files.
|
|
1371
|
-
* The return value can be used for offFile later
|
|
1372
|
-
* @param id ID of meta-object, like `vis.0`
|
|
1373
|
-
* @param filePattern File name or file pattern, like `main/*`
|
|
1374
|
-
* @param withFile If the content of the file must be returned in callback (high usage of memory)
|
|
1375
|
-
* @param handler Callback: function (id, fileName, size, data, mimeType) {}
|
|
1376
|
-
*/
|
|
1377
|
-
function onFile<WithFile extends boolean>(id: string, filePattern: string | string[], withFile: WithFile, handler: iobJS.FileChangeHandler<WithFile>): any;
|
|
1378
|
-
function onFile(id: string, filePattern: string | string[], handler: iobJS.FileChangeHandler<false>): any;
|
|
1379
|
-
|
|
1380
|
-
/**
|
|
1381
|
-
* Un-subscribe from the changes of the matched files.
|
|
1382
|
-
* @param id ID of meta-object, like `vis.0`. You can provide here can be a returned object from onFile. In this case, no filePattern required.
|
|
1383
|
-
* @param filePattern File name or file pattern, like `main/*`
|
|
1384
|
-
*/
|
|
1385
|
-
function offFile(id: string | any, filePattern?: string | string[]): boolean;
|
|
1386
|
-
|
|
1387
|
-
/**
|
|
1388
|
-
* Registers a one-time subscription which automatically unsubscribes after the first invocation
|
|
1389
|
-
*/
|
|
1390
|
-
function once(
|
|
1391
|
-
pattern: string | RegExp | string[] | iobJS.AstroSchedule | iobJS.SubscribeTime | iobJS.SubscribeOptions,
|
|
1392
|
-
handler: iobJS.StateChangeHandler
|
|
1393
|
-
): any;
|
|
1394
|
-
function once(
|
|
1395
|
-
pattern: string | RegExp | string[] | iobJS.AstroSchedule | iobJS.SubscribeTime | iobJS.SubscribeOptions
|
|
1396
|
-
): Promise<iobJS.ChangedStateObject>;
|
|
1397
|
-
|
|
1398
|
-
/**
|
|
1399
|
-
* Causes all changes of the state with id1 to the state with id2.
|
|
1400
|
-
* The return value can be used to unsubscribe later
|
|
1401
|
-
*/
|
|
1402
|
-
function on(id1: string, id2: string): any;
|
|
1403
|
-
/**
|
|
1404
|
-
* Watches the state with id1 for changes and overwrites the state with id2 with value2 when any occur.
|
|
1405
|
-
* @param id1 The state to watch for changes
|
|
1406
|
-
* @param id2 The state to update when changes occur
|
|
1407
|
-
* @param value2 The value to write into state `id2` when `id1` gets changed
|
|
1408
|
-
*/
|
|
1409
|
-
function on(id1: string, id2: string, value2: any): any;
|
|
1410
|
-
|
|
1411
|
-
/**
|
|
1412
|
-
* Causes all changes of the state with id1 to the state with id2
|
|
1413
|
-
*/
|
|
1414
|
-
function subscribe(id1: string, id2: string): any;
|
|
1415
|
-
/**
|
|
1416
|
-
* Watches the state with id1 for changes and overwrites the state with id2 with value2 when any occur.
|
|
1417
|
-
* @param id1 The state to watch for changes
|
|
1418
|
-
* @param id2 The state to update when changes occur
|
|
1419
|
-
* @param value2 The value to write into state `id2` when `id1` gets changed
|
|
1420
|
-
*/
|
|
1421
|
-
function subscribe(id1: string, id2: string, value2: any): any;
|
|
1422
|
-
|
|
1423
|
-
/**
|
|
1424
|
-
* Returns the list of all active subscriptions
|
|
1425
|
-
*/
|
|
1426
|
-
function getSubscriptions(): { [id: string]: iobJS.Subscription[] };
|
|
1427
|
-
|
|
1428
|
-
/**
|
|
1429
|
-
* Returns the list of all active file subscriptions
|
|
1430
|
-
*/
|
|
1431
|
-
function getFileSubscriptions(): { [id: string]: iobJS.Subscription[] };
|
|
1432
|
-
|
|
1433
|
-
/**
|
|
1434
|
-
* Unsubscribe from changes of the given object ID(s) or handler(s)
|
|
1435
|
-
*/
|
|
1436
|
-
function unsubscribe(id: string | string[]): boolean;
|
|
1437
|
-
function unsubscribe(handler: any | any[]): boolean;
|
|
1438
|
-
|
|
1439
|
-
function adapterSubscribe(id: string): void;
|
|
1440
|
-
function adapterUnsubscribe(id: string): void;
|
|
1441
|
-
|
|
1442
|
-
/**
|
|
1443
|
-
* Schedules a function to be executed on a defined schedule.
|
|
1444
|
-
* The return value can be used to clear the schedule later.
|
|
1445
|
-
*/
|
|
1446
|
-
function schedule(pattern: string | iobJS.SchedulePattern, callback: EmptyCallback): any;
|
|
1447
|
-
function schedule(date: Date, callback: EmptyCallback): any;
|
|
1448
|
-
function schedule(astro: iobJS.AstroSchedule, callback: EmptyCallback): any;
|
|
1449
|
-
|
|
1450
|
-
/**
|
|
1451
|
-
* [{"type":"cron","pattern":"0 15 13 * * *","scriptName":"script.js.scheduleById","id":"cron_1704187467197_22756"}]
|
|
1452
|
-
*
|
|
1453
|
-
* @param allScripts Return all registered schedules of all running scripts
|
|
1454
|
-
*/
|
|
1455
|
-
function getSchedules(allScripts?: boolean): Array<iobJS.ScheduleStatus>;
|
|
1456
|
-
|
|
1457
|
-
/**
|
|
1458
|
-
* Creates a schedule based on the state value (e.g. 12:53:09)
|
|
1459
|
-
* Schedule will be updated if the state value changes
|
|
1460
|
-
*/
|
|
1461
|
-
function scheduleById(id: string, callback: EmptyCallback): any;
|
|
1462
|
-
function scheduleById(id: string, ack: boolean, callback: EmptyCallback): any;
|
|
1463
|
-
|
|
1464
|
-
/**
|
|
1465
|
-
* Clears a schedule. Returns true if it was successful.
|
|
1466
|
-
*/
|
|
1467
|
-
function clearSchedule(schedule: any): boolean;
|
|
1468
|
-
|
|
1469
|
-
/**
|
|
1470
|
-
* Calculates the astro time which corresponds to the given pattern.
|
|
1471
|
-
* For valid patterns, see @link{https://github.com/ioBroker/ioBroker.javascript/blob/master/docs/en/javascript.md#astro-function}
|
|
1472
|
-
* @param pattern One of predefined patterns, like: sunrise, sunriseEnd, ...
|
|
1473
|
-
* @param date (optional) The date for which the astro time should be calculated. Default = today
|
|
1474
|
-
* @param offsetMinutes (optional) The number of minutes to be added to the return value.
|
|
1475
|
-
*/
|
|
1476
|
-
function getAstroDate(pattern: string, date?: Date | number, offsetMinutes?: number): Date;
|
|
1477
|
-
|
|
1478
|
-
/**
|
|
1479
|
-
* Determines if now is between sunrise and sunset.
|
|
1480
|
-
*/
|
|
1481
|
-
function isAstroDay(): boolean;
|
|
1482
|
-
|
|
1483
|
-
/**
|
|
1484
|
-
* Sets a state to the given value
|
|
1485
|
-
* @param id The ID of the state to be set
|
|
1486
|
-
*/
|
|
1487
|
-
function setState(id: string, state: iobJS.State | iobJS.StateValue | iobJS.SettableState, callback?: iobJS.SetStateCallback): void;
|
|
1488
|
-
function setState(id: string, state: iobJS.State | iobJS.StateValue | iobJS.SettableState, ack: boolean, callback?: iobJS.SetStateCallback): void;
|
|
1489
|
-
|
|
1490
|
-
function setStateAsync(id: string, state: iobJS.State | iobJS.StateValue | iobJS.SettableState, ack?: boolean): iobJS.SetStatePromise;
|
|
1491
|
-
|
|
1492
|
-
/**
|
|
1493
|
-
* Sets a state to the given value only if the value really changed.
|
|
1494
|
-
* @param id The ID of the state to be set
|
|
1495
|
-
*/
|
|
1496
|
-
function setStateChanged(id: string, state: iobJS.State | iobJS.StateValue | iobJS.SettableState, callback?: iobJS.SetStateCallback): void;
|
|
1497
|
-
function setStateChanged(id: string, state: iobJS.State | iobJS.StateValue | iobJS.SettableState, ack: boolean, callback?: iobJS.SetStateCallback): void;
|
|
1498
|
-
|
|
1499
|
-
function setStateChangedAsync(id: string, state: iobJS.State | iobJS.StateValue | iobJS.SettableState, ack?: boolean): iobJS.SetStatePromise;
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
/**
|
|
1503
|
-
* Sets a state to the given value after a timeout has passed.
|
|
1504
|
-
* Returns the timer, so it can be manually cleared with clearStateDelayed
|
|
1505
|
-
* @param id The ID of the state to be set
|
|
1506
|
-
* @param delay The delay in milliseconds
|
|
1507
|
-
* @param clearRunning (optional) Whether an existing timeout for this state should be cleared
|
|
1508
|
-
* @returns If a delayed setState was scheduled, this returns the timer id, otherwise null.
|
|
1509
|
-
*/
|
|
1510
|
-
function setStateDelayed(id: string, state: iobJS.State | iobJS.StateValue | iobJS.SettableState, delay: number, clearRunning: boolean, callback?: iobJS.SetStateCallback): number | null;
|
|
1511
|
-
function setStateDelayed(id: string, state: iobJS.State | iobJS.StateValue | iobJS.SettableState, ack: boolean, clearRunning: boolean, callback?: iobJS.SetStateCallback): number | null;
|
|
1512
|
-
function setStateDelayed(id: string, state: iobJS.State | iobJS.StateValue | iobJS.SettableState, ack: boolean, delay: number, callback?: iobJS.SetStateCallback): number | null;
|
|
1513
|
-
function setStateDelayed(id: string, state: iobJS.State | iobJS.StateValue | iobJS.SettableState, delay: number, callback?: iobJS.SetStateCallback): number | null;
|
|
1514
|
-
function setStateDelayed(id: string, state: iobJS.State | iobJS.StateValue | iobJS.SettableState, callback?: iobJS.SetStateCallback): number | null;
|
|
1515
|
-
function setStateDelayed(id: string, state: iobJS.State | iobJS.StateValue | iobJS.SettableState, ack: boolean, delay: number, clearRunning: boolean, callback?: iobJS.SetStateCallback): number | null;
|
|
1516
|
-
|
|
1517
|
-
/**
|
|
1518
|
-
* Clears a timer created by setStateDelayed
|
|
1519
|
-
* @param id The state id for which the timer should be cleared
|
|
1520
|
-
* @param timerID (optional) ID of the specific timer to clear. If none is given, all timers are cleared.
|
|
1521
|
-
*/
|
|
1522
|
-
function clearStateDelayed(id: string, timerID?: number): boolean;
|
|
1523
|
-
|
|
1524
|
-
/**
|
|
1525
|
-
* Returns information about a specific timer created with `setStateDelayed`.
|
|
1526
|
-
* @param timerId The timer id that was returned by `setStateDelayed`.
|
|
1527
|
-
*/
|
|
1528
|
-
function getStateDelayed(timerId: number): iobJS.StateTimer | null;
|
|
1529
|
-
/**
|
|
1530
|
-
* Returns a list of all timers created with `setStateDelayed`. Can be limited to a specific state id.
|
|
1531
|
-
* @param id The state id for which the timers should be.
|
|
1532
|
-
*/
|
|
1533
|
-
function getStateDelayed(id?: string): iobJS.StateTimer[];
|
|
1534
|
-
|
|
1535
|
-
/**
|
|
1536
|
-
* Returns the state with the given ID.
|
|
1537
|
-
* If the adapter is configured to subscribe to all states on start,
|
|
1538
|
-
* this can be called synchronously and immediately returns the state.
|
|
1539
|
-
* Otherwise, you need to provide a callback.
|
|
1540
|
-
*/
|
|
1541
|
-
function getState<T extends iobJS.StateValue = any>(id: string, callback: iobJS.GetStateCallback<T>): void;
|
|
1542
|
-
function getState<T extends iobJS.StateValue = any>(id: string): iobJS.State<T> | iobJS.AbsentState;
|
|
1543
|
-
function getStateAsync<T extends iobJS.StateValue = any>(id: string): Promise<iobJS.State<T>>;
|
|
1544
|
-
|
|
1545
|
-
/**
|
|
1546
|
-
* Checks if the state with the given ID exists
|
|
1547
|
-
*/
|
|
1548
|
-
function existsState(id: string, callback: iobJS.ExistsStateCallback): void;
|
|
1549
|
-
function existsState(id: string): boolean;
|
|
1550
|
-
function existsStateAsync(id: string): Promise<boolean>;
|
|
1551
|
-
/**
|
|
1552
|
-
* Checks if the object with the given ID exists
|
|
1553
|
-
*/
|
|
1554
|
-
function existsObject(id: string): boolean;
|
|
1555
|
-
function existsObjectAsync(id: string): Promise<boolean>;
|
|
1556
|
-
|
|
1557
|
-
/**
|
|
1558
|
-
* Returns the IDs of the states with the given name
|
|
1559
|
-
* @param name Name of the state
|
|
1560
|
-
* @param forceArray (optional) Ensures that the return value is always an array, even if only one ID was found.
|
|
1561
|
-
*/
|
|
1562
|
-
function getIdByName(name: string, forceArray?: boolean): string | string[];
|
|
1563
|
-
|
|
1564
|
-
/**
|
|
1565
|
-
* Reads an object from the object db.
|
|
1566
|
-
* @param enumName Which enum should be included in the returned object. `true` to return all enums.
|
|
1567
|
-
*/
|
|
1568
|
-
function getObject<T extends string>(id: T, enumName?: string | true): iobJS.ObjectIdToObjectType<T, "read">;
|
|
1569
|
-
function getObject<T extends string>(id: T, callback: iobJS.GetObjectCallback<T>): void;
|
|
1570
|
-
function getObject<T extends string>(id: T, enumName: string | true, callback: iobJS.GetObjectCallback<T>): void;
|
|
1571
|
-
function getObjectAsync<T extends string>(id: T, enumName?: string | true): iobJS.GetObjectPromise<T>;
|
|
1572
|
-
|
|
1573
|
-
/** Creates or overwrites an object in the object db */
|
|
1574
|
-
function setObject(id: string, obj: iobJS.SettableObject, callback?: iobJS.SetObjectCallback): void;
|
|
1575
|
-
function setObjectAsync(id: string, obj: iobJS.SettableObject): iobJS.SetObjectPromise;
|
|
1576
|
-
/** Extend an object and create it if it might not exist */
|
|
1577
|
-
function extendObject(id: string, objPart: iobJS.PartialObject, callback?: iobJS.SetObjectCallback): void;
|
|
1578
|
-
function extendObjectAsync(id: string, objPart: iobJS.PartialObject): iobJS.SetObjectPromise;
|
|
1579
|
-
|
|
1580
|
-
/** Deletes an object in the object db */
|
|
1581
|
-
function deleteObject(id: string, callback?: ErrorCallback): void;
|
|
1582
|
-
function deleteObject(id: string, recursive: boolean, callback?: ErrorCallback): void;
|
|
1583
|
-
function deleteObjectAsync(id: string, recursive?: boolean): Promise<void>;
|
|
1584
|
-
|
|
1585
|
-
function getEnums(enumName?: string): any;
|
|
1586
|
-
|
|
1587
|
-
/**
|
|
1588
|
-
* Creates a state and the corresponding object under the javascript namespace.
|
|
1589
|
-
* @param name The name of the state without the namespace
|
|
1590
|
-
* @param initValue (optional) Initial value of the state
|
|
1591
|
-
* @param forceCreation (optional) Override the state if it already exists
|
|
1592
|
-
* @param common (optional) Common part of the state object
|
|
1593
|
-
* @param native (optional) Native part of the state object
|
|
1594
|
-
* @param callback (optional) Called after the state was created
|
|
1595
|
-
*/
|
|
1596
|
-
function createState(name: string, callback?: iobJS.SetStateCallback): void;
|
|
1597
|
-
function createState(name: string, initValue: iobJS.StateValue, callback?: iobJS.SetStateCallback): void;
|
|
1598
|
-
function createState(name: string, initValue: iobJS.StateValue, forceCreation: boolean, callback?: iobJS.SetStateCallback): void;
|
|
1599
|
-
function createState(name: string, initValue: iobJS.StateValue, forceCreation: boolean, common: Partial<iobJS.StateCommon>, callback?: iobJS.SetStateCallback): void;
|
|
1600
|
-
function createState(name: string, initValue: iobJS.StateValue, forceCreation: boolean, common: Partial<iobJS.StateCommon>, native: any, callback?: iobJS.SetStateCallback): void;
|
|
1601
|
-
function createState(name: string, common: Partial<iobJS.StateCommon>, callback?: iobJS.SetStateCallback): void;
|
|
1602
|
-
function createState(name: string, initValue: iobJS.StateValue, common: Partial<iobJS.StateCommon>, callback?: iobJS.SetStateCallback): void;
|
|
1603
|
-
function createState(name: string, common: Partial<iobJS.StateCommon>, native: any, callback?: iobJS.SetStateCallback): void;
|
|
1604
|
-
function createState(name: string, initValue: iobJS.StateValue, common: Partial<iobJS.StateCommon>, native: any, callback?: iobJS.SetStateCallback): void;
|
|
1605
|
-
|
|
1606
|
-
function createStateAsync(name: string, initValue?: iobJS.StateValue, forceCreation?: boolean, common?: Partial<iobJS.StateCommon>, native?: any): iobJS.SetStatePromise;
|
|
1607
|
-
function createStateAsync(name: string, common: Partial<iobJS.StateCommon>): iobJS.SetStatePromise;
|
|
1608
|
-
function createStateAsync(name: string, common: Partial<iobJS.StateCommon>, native?: any): iobJS.SetStatePromise;
|
|
1609
|
-
function createStateAsync(name: string, initValue: iobJS.StateValue, common: Partial<iobJS.StateCommon>): iobJS.SetStatePromise;
|
|
1610
|
-
function createStateAsync(name: string, initValue: iobJS.StateValue, common: Partial<iobJS.StateCommon>, native?: any): iobJS.SetStatePromise;
|
|
1611
|
-
|
|
1612
|
-
function createAlias(name: string, alias: string | iobJS.StateCommonAlias, callback?: iobJS.SetStateCallback): void;
|
|
1613
|
-
function createAlias(name: string, alias: string | iobJS.StateCommonAlias, forceCreation: boolean, callback?: iobJS.SetStateCallback): void;
|
|
1614
|
-
function createAlias(name: string, alias: string | iobJS.StateCommonAlias, forceCreation: boolean, common: Partial<iobJS.StateCommon>, callback?: iobJS.SetStateCallback): void;
|
|
1615
|
-
function createAlias(name: string, alias: string | iobJS.StateCommonAlias, forceCreation: boolean, common: Partial<iobJS.StateCommon>, native: any, callback?: iobJS.SetStateCallback): void;
|
|
1616
|
-
function createAlias(name: string, alias: string | iobJS.StateCommonAlias, common: Partial<iobJS.StateCommon>, callback?: iobJS.SetStateCallback): void;
|
|
1617
|
-
function createAlias(name: string, alias: string | iobJS.StateCommonAlias, common: Partial<iobJS.StateCommon>, native: any, callback?: iobJS.SetStateCallback): void;
|
|
1618
|
-
|
|
1619
|
-
function createAliasAsync(name: string, alias: string | iobJS.StateCommonAlias, forceCreation?: boolean, common?: Partial<iobJS.StateCommon>, native?: any): iobJS.SetStatePromise;
|
|
1620
|
-
function createAliasAsync(name: string, alias: string | iobJS.StateCommonAlias, common: Partial<iobJS.StateCommon>): iobJS.SetStatePromise;
|
|
1621
|
-
function createAliasAsync(name: string, alias: string | iobJS.StateCommonAlias, common: Partial<iobJS.StateCommon>, native?: any): iobJS.SetStatePromise;
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
/**
|
|
1626
|
-
* Deletes the state with the given ID
|
|
1627
|
-
* @param callback (optional) Is called after the state was deleted (or not).
|
|
1628
|
-
*/
|
|
1629
|
-
function deleteState(id: string, callback?: GenericCallback<boolean>): void;
|
|
1630
|
-
function deleteStateAsync(id: string): Promise<boolean>;
|
|
1631
|
-
|
|
1632
|
-
/**
|
|
1633
|
-
* Sends a message to a specific instance or all instances of some specific adapter.
|
|
1634
|
-
* @param instanceName The instance to send this message to.
|
|
1635
|
-
* If the ID of an instance is given (e.g. "admin.0"), only this instance will receive the message.
|
|
1636
|
-
* If the name of an adapter is given (e.g. "admin"), all instances of this adapter will receive it.
|
|
1637
|
-
* @param command (optional) Command name of the target instance. Default: "send"
|
|
1638
|
-
* @param message The message (e.g., params) to send.
|
|
1639
|
-
*/
|
|
1640
|
-
function sendTo(instanceName: string, command: string, message: string | object, options: iobJS.SendToOptions, callback?: iobJS.MessageCallback | iobJS.MessageCallbackInfo): void;
|
|
1641
|
-
function sendTo(instanceName: string, command: string, message: string | object, callback?: iobJS.MessageCallback | iobJS.MessageCallbackInfo): void;
|
|
1642
|
-
function sendTo(instanceName: string, message: string | object, callback?: iobJS.MessageCallback | iobJS.MessageCallbackInfo): void;
|
|
1643
|
-
function sendToAsync(instanceName: string, message: string | object): Promise<iobJS.MessageCallback | iobJS.MessageCallbackInfo>;
|
|
1644
|
-
function sendToAsync(instanceName: string, command: string, message: string | object): Promise<iobJS.MessageCallback | iobJS.MessageCallbackInfo>;
|
|
1645
|
-
function sendToAsync(instanceName: string, command: string, message: string | object, options: iobJS.SendToOptions): Promise<iobJS.MessageCallback | iobJS.MessageCallbackInfo>;
|
|
1646
|
-
|
|
1647
|
-
/**
|
|
1648
|
-
* Sends a message to a specific instance or all instances of some specific adapter.
|
|
1649
|
-
* @param host Host name.
|
|
1650
|
-
* @param command Command name for the target host.
|
|
1651
|
-
* @param message The message (e.g., params) to send.
|
|
1652
|
-
*/
|
|
1653
|
-
function sendToHost(host: string, command: string, message: string | object, callback?: iobJS.MessageCallback | iobJS.MessageCallbackInfo): void;
|
|
1654
|
-
function sendToHostAsync(host: string, command: string, message: string | object): Promise<iobJS.MessageCallback | iobJS.MessageCallbackInfo>;
|
|
1655
|
-
|
|
1656
|
-
/**
|
|
1657
|
-
* Creates a new notification (visible in admin adpter)
|
|
1658
|
-
* @param msg Message text
|
|
1659
|
-
*/
|
|
1660
|
-
function registerNotification(msg: string): void;
|
|
1661
|
-
function registerNotification(msg: string, isAlert: boolean): void;
|
|
1662
|
-
|
|
1663
|
-
function setTimeout(callback: (args: void) => void, ms?: number): NodeJS.Timeout;
|
|
1664
|
-
function clearTimeout(timeoutId: NodeJS.Timeout | string | number | undefined): void;
|
|
1665
|
-
function setInterval(callback: (args: void) => void, ms?: number): NodeJS.Timeout;
|
|
1666
|
-
function clearInterval(intervalId: NodeJS.Timeout | string | number | undefined): void;
|
|
1667
|
-
function setImmediate(callback: (args: void) => void): NodeJS.Immediate;
|
|
1668
|
-
|
|
1669
|
-
type CompareTimeOperations =
|
|
1670
|
-
"between" | "not between" |
|
|
1671
|
-
">" | ">=" | "<" | "<=" | "==" | "<>"
|
|
1672
|
-
;
|
|
1673
|
-
|
|
1674
|
-
/**
|
|
1675
|
-
* Compares two or more times
|
|
1676
|
-
* @param timeToCompare - The time to compare with startTime and/or endTime. If none is given, the current time is used
|
|
1677
|
-
*/
|
|
1678
|
-
function compareTime(
|
|
1679
|
-
startTime: string | number | Date | iobJS.AstroDate,
|
|
1680
|
-
endTime: string | number | Date | iobJS.AstroDate,
|
|
1681
|
-
operation: CompareTimeOperations,
|
|
1682
|
-
timeToCompare?: string | number | Date | iobJS.AstroDate,
|
|
1683
|
-
): boolean;
|
|
1684
|
-
|
|
1685
|
-
/** Sets up a callback which is called when the script stops */
|
|
1686
|
-
function onStop(callback: (cb?: EmptyCallback) => void, timeout?: number): void;
|
|
1687
|
-
|
|
1688
|
-
function formatValue(value: number | string, format?: any): string;
|
|
1689
|
-
function formatValue(value: number | string, decimals: number, format?: any): string;
|
|
1690
|
-
function formatDate(dateObj: string | Date | number, format: string, language?: string): string;
|
|
1691
|
-
function formatDate(dateObj: string | Date | number, isDuration: boolean | string, format: string, language?: string): string;
|
|
1692
|
-
function formatTimeDiff(diff: number): string;
|
|
1693
|
-
function formatTimeDiff(diff: number, format: string): string;
|
|
1694
|
-
|
|
1695
|
-
function getDateObject(date?: number | string | Date): Date;
|
|
1696
|
-
|
|
1697
|
-
/**
|
|
1698
|
-
* Writes a file.
|
|
1699
|
-
* @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0"
|
|
1700
|
-
* @param name File name
|
|
1701
|
-
* @param data Contents of the file
|
|
1702
|
-
* @param callback Is called when the operation has finished (successfully or not)
|
|
1703
|
-
*/
|
|
1704
|
-
function writeFile(id: string, name: string, data: Buffer | string, callback: ErrorCallback): void;
|
|
1705
|
-
function writeFileAsync(id: string, name: string, data: Buffer | string): Promise<void>;
|
|
1706
|
-
|
|
1707
|
-
/**
|
|
1708
|
-
* Reads a file.
|
|
1709
|
-
* @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0"
|
|
1710
|
-
* @param name File name
|
|
1711
|
-
* @param callback Is called when the operation has finished (successfully or not)
|
|
1712
|
-
*/
|
|
1713
|
-
function readFile(id: string, name: string, callback: iobJS.ReadFileCallback): void;
|
|
1714
|
-
function readFileAsync(id: string, name: string): iobJS.ReadFilePromise;
|
|
1715
|
-
|
|
1716
|
-
/**
|
|
1717
|
-
* Deletes a file.
|
|
1718
|
-
* @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0"
|
|
1719
|
-
* @param name File name
|
|
1720
|
-
* @param callback Is called when the operation has finished (successfully or not)
|
|
1721
|
-
*/
|
|
1722
|
-
function unlink(id: string, name: string, callback: ErrorCallback): void;
|
|
1723
|
-
function unlinkAsync(id: string, name: string): Promise<void>;
|
|
1724
|
-
|
|
1725
|
-
/**
|
|
1726
|
-
* Deletes a file.
|
|
1727
|
-
* @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0"
|
|
1728
|
-
* @param name File name
|
|
1729
|
-
* @param callback Is called when the operation has finished (successfully or not)
|
|
1730
|
-
*/
|
|
1731
|
-
function delFile(id: string, name: string, callback: ErrorCallback): void;
|
|
1732
|
-
function delFileAsync(id: string, name: string): Promise<void>;
|
|
1733
|
-
|
|
1734
|
-
/**
|
|
1735
|
-
* Renames a file.
|
|
1736
|
-
* @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0"
|
|
1737
|
-
* @param oldName Current file name
|
|
1738
|
-
* @param newName New file name
|
|
1739
|
-
* @param callback Is called when the operation has finished (successfully or not)
|
|
1740
|
-
*/
|
|
1741
|
-
function rename(id: string, oldName: string, newName: string, callback: ErrorCallback): void;
|
|
1742
|
-
function renameAsync(id: string, oldName: string, newName: string): Promise<void>;
|
|
1743
|
-
|
|
1744
|
-
/**
|
|
1745
|
-
* Renames a file.
|
|
1746
|
-
* @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0"
|
|
1747
|
-
* @param oldName Current file name
|
|
1748
|
-
* @param newName New file name
|
|
1749
|
-
* @param callback Is called when the operation has finished (successfully or not)
|
|
1750
|
-
*/
|
|
1751
|
-
function renameFile(id: string, oldName: string, newName: string, callback: ErrorCallback): void;
|
|
1752
|
-
function renameFileAsync(id: string, oldName: string, newName: string): Promise<void>;
|
|
1753
|
-
|
|
1754
|
-
function getHistory(instance: any, options: any, callback: any): any;
|
|
1755
|
-
function getHistoryAsync(instance: any, options: any): Promise<any>;
|
|
1756
|
-
|
|
1757
|
-
/**
|
|
1758
|
-
* Starts or restarts a script by name
|
|
1759
|
-
* @param scriptName (optional) Name of the script. If none is given, the current script is (re)started.
|
|
1760
|
-
*/
|
|
1761
|
-
function runScript(scriptName?: string, callback?: ErrorCallback): boolean;
|
|
1762
|
-
function runScriptAsync(scriptName?: string): Promise<void>;
|
|
1763
|
-
|
|
1764
|
-
/**
|
|
1765
|
-
* Starts or restarts a script by name
|
|
1766
|
-
* @param scriptName (optional) Name of the script. If none is given, the current script is (re)started.
|
|
1767
|
-
* @param ignoreIfStarted If set to true, running scripts will not be restarted.
|
|
1768
|
-
* @param callback (optional) Is called when the script has finished (successfully or not)
|
|
1769
|
-
*/
|
|
1770
|
-
function startScript(scriptName: string | undefined, ignoreIfStarted: boolean, callback?: GenericCallback<boolean>): boolean;
|
|
1771
|
-
function startScriptAsync(scriptName?: string | undefined, ignoreIfStarted?: boolean): Promise<void>;
|
|
1772
|
-
|
|
1773
|
-
/**
|
|
1774
|
-
* Starts or restarts a script by name
|
|
1775
|
-
* @param scriptName (optional) Name of the script. If none is given, the current script is (re)started.
|
|
1776
|
-
* @param callback (optional) Is called when the script has finished (successfully or not)
|
|
1777
|
-
*/
|
|
1778
|
-
function startScript(scriptName?: string, callback?: GenericCallback<boolean>): boolean;
|
|
1779
|
-
/**
|
|
1780
|
-
* Stops a script by name
|
|
1781
|
-
* @param scriptName (optional) Name of the script. If none is given, the current script is stopped.
|
|
1782
|
-
*/
|
|
1783
|
-
function stopScript(scriptName: string | undefined, callback?: GenericCallback<boolean>): boolean;
|
|
1784
|
-
function stopScriptAsync(scriptName?: string): Promise<void>;
|
|
1785
|
-
|
|
1786
|
-
function isScriptActive(scriptName: string): boolean;
|
|
1787
|
-
|
|
1788
|
-
function startInstanceAsync(instanceName: string): Promise<boolean>;
|
|
1789
|
-
function restartInstanceAsync(instanceName: string): Promise<boolean>;
|
|
1790
|
-
function stopInstanceAsync(instanceName: string): Promise<boolean>;
|
|
1791
|
-
|
|
1792
|
-
/** Converts a value to an integer */
|
|
1793
|
-
function toInt(val: any): number;
|
|
1794
|
-
/** Converts a value to a floating point number */
|
|
1795
|
-
function toFloat(val: any): number;
|
|
1796
|
-
/** Converts a value to a boolean */
|
|
1797
|
-
function toBoolean(val: any): boolean;
|
|
1798
|
-
|
|
1799
|
-
/**
|
|
1800
|
-
* Digs in an object for the property value at the given path.
|
|
1801
|
-
* @param obj The object to dig in
|
|
1802
|
-
* @param path The path of the property to dig for in the given object
|
|
1803
|
-
*/
|
|
1804
|
-
function getAttr(obj: string | Record<string, any>, path: string | string[]): any;
|
|
1805
|
-
|
|
1806
|
-
/**
|
|
1807
|
-
* Sends a message to another script.
|
|
1808
|
-
* @param target Message name or target object
|
|
1809
|
-
* @param data Any data, that should be sent to message bus
|
|
1810
|
-
* @param options Actually only {timeout: X} is supported as option
|
|
1811
|
-
* @param callback Callback to get the result from other script
|
|
1812
|
-
* @return ID of the subscription. It could be used for un-subscribe.
|
|
1813
|
-
*/
|
|
1814
|
-
function messageTo(target: iobJS.MessageTarget | string, data: any, options?: any, callback?: SimpleCallback<any>): iobJS.MessageSubscribeID;
|
|
1815
|
-
function messageToAsync(target: iobJS.MessageTarget | string, data: any, options?: any): Promise<iobJS.MessageCallback | iobJS.MessageCallbackInfo>;
|
|
1816
|
-
|
|
1817
|
-
/**
|
|
1818
|
-
* Process message from another script.
|
|
1819
|
-
* @param message Message name
|
|
1820
|
-
* @param callback Callback to send the result to another script
|
|
1821
|
-
*/
|
|
1822
|
-
function onMessage(message: string, callback?: MessageCallback<any>): void;
|
|
1823
|
-
|
|
1824
|
-
/**
|
|
1825
|
-
* Unregister onmessage handler
|
|
1826
|
-
* @param id Message subscription id from onMessage or by message name
|
|
1827
|
-
* @return true if subscription exists and was deleted.
|
|
1828
|
-
*/
|
|
1829
|
-
function onMessageUnregister(id: iobJS.MessageSubscribeID | string): boolean;
|
|
1830
|
-
|
|
1831
|
-
function jsonataExpression(data: any, expression: string): Promise<any>;
|
|
1832
|
-
|
|
1833
|
-
function onObject(pattern: string, callback: iobJS.ObjectChangeHandler): void;
|
|
1834
|
-
function subscribeObject(pattern: string, callback: iobJS.ObjectChangeHandler): void;
|
|
1835
|
-
|
|
1836
|
-
function unsubscribeObject(id: string): void;
|
|
1837
|
-
|
|
1838
|
-
/**
|
|
1839
|
-
* Receives logs of specified severity level in a script.
|
|
1840
|
-
* @param severity Severity level
|
|
1841
|
-
* @param callback Callback to send the result to another script
|
|
1842
|
-
*/
|
|
1843
|
-
function onLog(severity: iobJS.LogLevel | "*", callback: SimpleCallback<iobJS.LogMessage>): iobJS.LogSubscribeID;
|
|
1844
|
-
|
|
1845
|
-
/**
|
|
1846
|
-
* Unsubscribe log handler.
|
|
1847
|
-
* @param idOrCallbackOrSeverity Message subscription id from onLog or by callback function
|
|
1848
|
-
* @return true if subscription exists and was deleted.
|
|
1849
|
-
*/
|
|
1850
|
-
function onLogUnregister(idOrCallbackOrSeverity: iobJS.LogSubscribeID | SimpleCallback<iobJS.LogMessage> | iobJS.LogLevel | "*"): boolean;
|
|
1851
|
-
// TODO: More signatures for other types than number
|
|
1852
|
-
|
|
1853
|
-
/** `await` this method to pause for the given number of milliseconds */
|
|
1854
|
-
function wait(ms: number): Promise<void>;
|
|
1855
|
-
|
|
1856
|
-
/** `await` this method to pause for the given number of milliseconds */
|
|
1857
|
-
function sleep(ms: number): Promise<void>;
|
|
1858
|
-
}
|