@iobroker/socket-classes 0.5.3 → 0.5.4
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 +817 -0
- package/lib/socketCommands.js +192 -14
- package/lib/socketCommandsAdmin.js +135 -37
- package/lib/socketCommon.js +1 -1
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -63,12 +63,829 @@ io.start(server.server, ws, {userKey: 'connect.sid', checkUser, store, secret: a
|
|
|
63
63
|
io.close();
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
+
## Web Methods
|
|
67
|
+
<!-- WEB_METHODS_START -->
|
|
68
|
+
### List of commands
|
|
69
|
+
* [authenticate](#authenticate_w)
|
|
70
|
+
* [error](#error_w)
|
|
71
|
+
* [log](#log_w)
|
|
72
|
+
* [getHistory](#gethistory_w)
|
|
73
|
+
* [httpGet](#httpget_w)
|
|
74
|
+
* [sendTo](#sendto_w)
|
|
75
|
+
* [sendToHost](#sendtohost_w)
|
|
76
|
+
* [authEnabled](#authenabled_w)
|
|
77
|
+
* [logout](#logout_w)
|
|
78
|
+
* [listPermissions](#listpermissions_w)
|
|
79
|
+
* [getUserPermissions](#getuserpermissions_w)
|
|
80
|
+
* [getVersion](#getversion_w)
|
|
81
|
+
* [getAdapterName](#getadaptername_w)
|
|
82
|
+
* [getObject](#getobject_w)
|
|
83
|
+
* [getObjects](#getobjects_w)
|
|
84
|
+
* [subscribeObjects](#subscribeobjects_w)
|
|
85
|
+
* [unsubscribeObjects](#unsubscribeobjects_w)
|
|
86
|
+
* [getObjectView](#getobjectview_w)
|
|
87
|
+
* [setObject](#setobject_w)
|
|
88
|
+
* [getStates](#getstates_w)
|
|
89
|
+
* [delObject](#delobject_w)
|
|
90
|
+
* [getState](#getstate_w)
|
|
91
|
+
* [setState](#setstate_w)
|
|
92
|
+
* [getBinaryState](#getbinarystate_w)
|
|
93
|
+
* [setBinaryState](#setbinarystate_w)
|
|
94
|
+
* [subscribe](#subscribe_w)
|
|
95
|
+
* [subscribeStates](#subscribestates_w)
|
|
96
|
+
* [unsubscribe](#unsubscribe_w)
|
|
97
|
+
* [unsubscribeStates](#unsubscribestates_w)
|
|
98
|
+
* [readFile](#readfile_w)
|
|
99
|
+
* [readFile64](#readfile64_w)
|
|
100
|
+
* [writeFile64](#writefile64_w)
|
|
101
|
+
* [writeFile](#writefile_w)
|
|
102
|
+
* [unlink](#unlink_w)
|
|
103
|
+
* [deleteFile](#deletefile_w)
|
|
104
|
+
* [deleteFolder](#deletefolder_w)
|
|
105
|
+
* [renameFile](#renamefile_w)
|
|
106
|
+
* [rename](#rename_w)
|
|
107
|
+
* [mkdir](#mkdir_w)
|
|
108
|
+
* [readDir](#readdir_w)
|
|
109
|
+
* [chmodFile](#chmodfile_w)
|
|
110
|
+
* [chownFile](#chownfile_w)
|
|
111
|
+
* [fileExists](#fileexists_w)
|
|
112
|
+
* [subscribeFiles](#subscribefiles_w)
|
|
113
|
+
* [unsubscribeFiles](#unsubscribefiles_w)
|
|
114
|
+
* [getAdapterInstances](#getadapterinstances_w)
|
|
115
|
+
### <a name="authenticate_w"></a>authenticate(user, pass, callback)
|
|
116
|
+
Authenticate user by login and password
|
|
117
|
+
* user *(string)*: user name
|
|
118
|
+
* pass *(string)*: password
|
|
119
|
+
* callback *(function)*: `function (isUserAuthenticated, isAuthenticationUsed)`
|
|
120
|
+
|
|
121
|
+
### <a name="error_w"></a>error(error)
|
|
122
|
+
Write error into ioBroker log
|
|
123
|
+
* error *(string)*: error text
|
|
124
|
+
|
|
125
|
+
### <a name="log_w"></a>log(text, level)
|
|
126
|
+
Write log entry into ioBroker log
|
|
127
|
+
* text *(string)*: log text
|
|
128
|
+
* level *(string)*: one of `['silly', 'debug', 'info', 'warn', 'error']`. Default is 'debug'.
|
|
129
|
+
|
|
130
|
+
### <a name="gethistory_w"></a>getHistory(id, options, callback)
|
|
131
|
+
Get history data from specific instance
|
|
132
|
+
* id *(string)*: object ID
|
|
133
|
+
* options *(object)*: See object description here: https://github.com/ioBroker/ioBroker.history/blob/master/docs/en/README.md#access-values-from-javascript-adapter
|
|
134
|
+
* callback *(function)*: `function (error, result)`
|
|
135
|
+
|
|
136
|
+
### <a name="httpget_w"></a>httpGet(url, callback)
|
|
137
|
+
Read content of HTTP(S) page server-side (without CORS and stuff)
|
|
138
|
+
* url *(string)*: Page URL
|
|
139
|
+
* callback *(function)*: `function (error, {status, statusText}, body)`
|
|
140
|
+
|
|
141
|
+
### <a name="sendto_w"></a>sendTo(adapterInstance, command, message, callback)
|
|
142
|
+
Send message to specific instance
|
|
143
|
+
* adapterInstance *(string)*: instance name, e.g. `history.0`
|
|
144
|
+
* command *(string)*: command name
|
|
145
|
+
* message *(object)*: message is instance dependent
|
|
146
|
+
* callback *(function)*: `function (result)`
|
|
147
|
+
|
|
148
|
+
### <a name="sendtohost_w"></a>sendToHost(host, command, message, callback)
|
|
149
|
+
Send message to specific host.
|
|
150
|
+
Host can answer following commands: `cmdExec, getRepository, getInstalled, getInstalledAdapter, getVersion, getDiagData, getLocationOnDisk, getDevList, getLogs, getHostInfo, delLogs, readDirAsZip, writeDirAsZip, readObjectsAsZip, writeObjectsAsZip, checkLogging, updateMultihost`.
|
|
151
|
+
* host *(string)*: instance name, e.g. `history.0`
|
|
152
|
+
* command *(string)*: command name
|
|
153
|
+
* message *(object)*: message is command specific
|
|
154
|
+
* callback *(function)*: `function (result)`
|
|
155
|
+
|
|
156
|
+
### <a name="authenabled_w"></a>authEnabled(callback)
|
|
157
|
+
Ask server is authentication enabled and if the user authenticated
|
|
158
|
+
* callback *(function)*: `function (isAuthenticationUsed, userName)`
|
|
159
|
+
|
|
160
|
+
### <a name="logout_w"></a>logout(callback)
|
|
161
|
+
Logout user
|
|
162
|
+
* callback *(function)*: function (error)
|
|
163
|
+
|
|
164
|
+
### <a name="listpermissions_w"></a>listPermissions(callback)
|
|
165
|
+
List commands and permissions
|
|
166
|
+
* callback *(function)*: `function (permissions)`
|
|
167
|
+
|
|
168
|
+
### <a name="getuserpermissions_w"></a>getUserPermissions(callback)
|
|
169
|
+
Get user permissions
|
|
170
|
+
* callback *(function)*: `function (error, permissions)`
|
|
171
|
+
|
|
172
|
+
### <a name="getversion_w"></a>getVersion(callback)
|
|
173
|
+
Get adapter version. Not the socket-classes version!
|
|
174
|
+
* callback *(function)*: `function (error, adapterVersion, adapterName)`
|
|
175
|
+
|
|
176
|
+
### <a name="getadaptername_w"></a>getAdapterName(callback)
|
|
177
|
+
Get adapter name. Not the socket-classes version!
|
|
178
|
+
* callback *(function)*: `function (error, adapterVersion)`
|
|
179
|
+
|
|
180
|
+
### <a name="getobject_w"></a>getObject(id, callback)
|
|
181
|
+
Get one object
|
|
182
|
+
* id *(string)*: object ID.
|
|
183
|
+
* callback *(function)*: `function (error, obj)`
|
|
184
|
+
|
|
185
|
+
### <a name="getobjects_w"></a>getObjects(callback)
|
|
186
|
+
Get all objects that are relevant for web: all states and enums with rooms
|
|
187
|
+
* id *(string)*: object ID.
|
|
188
|
+
* callback *(function)*: `function (error, obj)`
|
|
189
|
+
|
|
190
|
+
### <a name="subscribeobjects_w"></a>subscribeObjects(pattern, callback)
|
|
191
|
+
Subscribe on object changes by pattern. The events will come as 'objectChange' events to the socket.
|
|
192
|
+
* pattern *(string)*: pattern like 'system.adapter.*' or array of IDs like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
|
|
193
|
+
* callback *(function)*: `function (error)`
|
|
194
|
+
|
|
195
|
+
### <a name="unsubscribeobjects_w"></a>unsubscribeObjects(pattern, callback)
|
|
196
|
+
Unsubscribe on object changes by pattern.
|
|
197
|
+
* pattern *(string)*: pattern like 'system.adapter.*' or array of IDs like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
|
|
198
|
+
* callback *(function)*: `function (error)`
|
|
199
|
+
|
|
200
|
+
### <a name="getobjectview_w"></a>getObjectView(design, search, params, callback)
|
|
201
|
+
Make a query to the object database.
|
|
202
|
+
* design *(string)*: 'system' or other designs like `custom`, but it must exist object `_design/custom`. Too 99,9% use `system`.
|
|
203
|
+
* search *(string)*: object type, like `state`, `instance`, `adapter`, `host`, ...
|
|
204
|
+
* params *(string)*: parameters for the query in form `{startkey: 'system.adapter.', endkey: 'system.adapter.\u9999'}`
|
|
205
|
+
* callback *(function)*: `function (error)`
|
|
206
|
+
|
|
207
|
+
### <a name="setobject_w"></a>setObject(id, obj, callback)
|
|
208
|
+
Set object.
|
|
209
|
+
* id *(string)*: object ID
|
|
210
|
+
* obj *(object)*: object itself
|
|
211
|
+
* callback *(function)*: `function (error)`
|
|
212
|
+
|
|
213
|
+
### <a name="getstates_w"></a>getStates(pattern, callback)
|
|
214
|
+
Read states by pattern
|
|
215
|
+
* pattern *(string)*: optional pattern, like `system.adapter.*` or array of state IDs
|
|
216
|
+
* callback *(function)*: `function (error, states)`, where `states` is an object like `{'system.adapter.history.0': {_id: 'system.adapter.history.0', common: {name: 'history', ...}, native: {...}, 'system.adapter.history.1': {...}}}`
|
|
217
|
+
|
|
218
|
+
### <a name="delobject_w"></a>delObject(id, options, callback)
|
|
219
|
+
Delete object. Only deletion of flot objects is allowed
|
|
220
|
+
* id *(string)*: Object ID like, 'flot.0.myChart'
|
|
221
|
+
* options *(string)*: ignored
|
|
222
|
+
* callback *(function)*: `function (error)`
|
|
223
|
+
|
|
224
|
+
### <a name="getstate_w"></a>getState(id, callback)
|
|
225
|
+
Read one state.
|
|
226
|
+
* id *(string)*: State ID like, 'system.adapter.admin.0.memRss'
|
|
227
|
+
* callback *(function)*: `function (error, state)`, where `state` is an object like `{val: 123, ts: 1663915537418, ack: true, from: 'system.adapter.admin.0', q: 0, lc: 1663915537418, c: 'javascript.0'}`
|
|
228
|
+
|
|
229
|
+
### <a name="setstate_w"></a>setState(id, state, callback)
|
|
230
|
+
Write one state.
|
|
231
|
+
* id *(string)*: State ID like, 'system.adapter.admin.0.memRss'
|
|
232
|
+
* state *(any)*: value or object like `{val: 123, ack: true}`
|
|
233
|
+
* callback *(function)*: `function (error, state)`, where `state` is an object like `{val: 123, ts: 1663915537418, ack: true, from: 'system.adapter.admin.0', q: 0, lc: 1663915537418, c: 'javascript.0'}`
|
|
234
|
+
|
|
235
|
+
### <a name="getbinarystate_w"></a>getBinaryState(id, callback)
|
|
236
|
+
Read one binary state.
|
|
237
|
+
* id *(string)*: State ID like, 'javascript.0.binary'
|
|
238
|
+
* callback *(function)*: `function (error, base64)`
|
|
239
|
+
|
|
240
|
+
### <a name="setbinarystate_w"></a>setBinaryState(id, base64, callback)
|
|
241
|
+
Write one binary state.
|
|
242
|
+
* id *(string)*: State ID like, 'javascript.0.binary'
|
|
243
|
+
* base64 *(string)*: State value as base64 string. Binary states has no acknowledge flag.
|
|
244
|
+
* callback *(function)*: `function (error)`
|
|
245
|
+
|
|
246
|
+
### <a name="subscribe_w"></a>subscribe(pattern, callback)
|
|
247
|
+
Subscribe on state changes by pattern. The events will come as 'stateChange' events to the socket.
|
|
248
|
+
* pattern *(string)*: pattern like 'system.adapter.*' or array of states like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
|
|
249
|
+
* callback *(function)*: `function (error)`
|
|
250
|
+
|
|
251
|
+
### <a name="subscribestates_w"></a>subscribeStates(pattern, callback)
|
|
252
|
+
Subscribe on state changes by pattern. Same as `subscribe`. The events will come as 'stateChange' events to the socket.
|
|
253
|
+
* pattern *(string)*: pattern like 'system.adapter.*' or array of states like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
|
|
254
|
+
* callback *(function)*: `function (error)`
|
|
255
|
+
|
|
256
|
+
### <a name="unsubscribe_w"></a>unsubscribe(pattern, callback)
|
|
257
|
+
Unsubscribe from state changes by pattern.
|
|
258
|
+
* pattern *(string)*: pattern like 'system.adapter.*' or array of states like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
|
|
259
|
+
* callback *(function)*: `function (error)`
|
|
260
|
+
|
|
261
|
+
### <a name="unsubscribestates_w"></a>unsubscribeStates(pattern, callback)
|
|
262
|
+
Unsubscribe from state changes by pattern. Same as `unsubscribe`.
|
|
263
|
+
* pattern *(string)*: pattern like 'system.adapter.*' or array of states like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
|
|
264
|
+
* callback *(function)*: `function (error)`
|
|
265
|
+
|
|
266
|
+
### <a name="readfile_w"></a>readFile(_adapter, fileName, callback)
|
|
267
|
+
Read file from ioBroker DB
|
|
268
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
269
|
+
* fileName *(string)*: file name, e.g `main/vis-views.json`
|
|
270
|
+
* callback *(function)*: `function (error, data, mimeType)`
|
|
271
|
+
|
|
272
|
+
### <a name="readfile64_w"></a>readFile64(_adapter, fileName, callback)
|
|
273
|
+
Read file from ioBroker DB as base64 string
|
|
274
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
275
|
+
* fileName *(string)*: file name, e.g `main/vis-views.json`
|
|
276
|
+
* callback *(function)*: `function (error, base64, mimeType)`
|
|
277
|
+
|
|
278
|
+
### <a name="writefile64_w"></a>writeFile64(_adapter, fileName, data64, options, callback)
|
|
279
|
+
Write file into ioBroker DB as base64 string
|
|
280
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
281
|
+
* fileName *(string)*: file name, e.g `main/vis-views.json`
|
|
282
|
+
* data64 *(string)*: file content as base64 string
|
|
283
|
+
* options *(object)*: optional `{mode: 0x0644}`
|
|
284
|
+
* callback *(function)*: `function (error)`
|
|
285
|
+
|
|
286
|
+
### <a name="writefile_w"></a>writeFile(_adapter, fileName, data, options, callback)
|
|
287
|
+
Write file into ioBroker DB as text **DEPRECATED**
|
|
288
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
289
|
+
* fileName *(string)*: file name, e.g `main/vis-views.json`
|
|
290
|
+
* data64 *(string)*: file content as base64 string
|
|
291
|
+
* options *(object)*: optional `{mode: 0x644}`
|
|
292
|
+
* callback *(function)*: `function (error)`
|
|
293
|
+
|
|
294
|
+
### <a name="unlink_w"></a>unlink(_adapter, name, callback)
|
|
295
|
+
Delete file in ioBroker DB
|
|
296
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
297
|
+
* name *(string)*: file name, e.g `main/vis-views.json`
|
|
298
|
+
* callback *(function)*: `function (error)`
|
|
299
|
+
|
|
300
|
+
### <a name="deletefile_w"></a>deleteFile(_adapter, name, callback)
|
|
301
|
+
Delete file in ioBroker DB (same as unlink, but only for files)
|
|
302
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
303
|
+
* name *(string)*: file name, e.g `main/vis-views.json`
|
|
304
|
+
* callback *(function)*: `function (error)`
|
|
305
|
+
|
|
306
|
+
### <a name="deletefolder_w"></a>deleteFolder(_adapter, name, callback)
|
|
307
|
+
Delete file in ioBroker DB (same as unlink, but only for folders)
|
|
308
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
309
|
+
* name *(string)*: folder name, e.g `main`
|
|
310
|
+
* callback *(function)*: `function (error)`
|
|
311
|
+
|
|
312
|
+
### <a name="renamefile_w"></a>renameFile(_adapter, oldName, newName, callback)
|
|
313
|
+
Rename file in ioBroker DB
|
|
314
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
315
|
+
* oldName *(string)*: current file name, e.g `main/vis-views.json`
|
|
316
|
+
* newName *(string)*: new file name, e.g `main/vis-views-new.json`
|
|
317
|
+
* callback *(function)*: `function (error)`
|
|
318
|
+
|
|
319
|
+
### <a name="rename_w"></a>rename(_adapter, oldName, newName, callback)
|
|
320
|
+
Rename file or folder in ioBroker DB
|
|
321
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
322
|
+
* oldName *(string)*: current file name, e.g `main/vis-views.json`
|
|
323
|
+
* newName *(string)*: new file name, e.g `main/vis-views-new.json`
|
|
324
|
+
* callback *(function)*: `function (error)`
|
|
325
|
+
|
|
326
|
+
### <a name="mkdir_w"></a>mkdir(_adapter, dirName, callback)
|
|
327
|
+
Create folder in ioBroker DB
|
|
328
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
329
|
+
* dirName *(string)*: desired folder name, e.g `main`
|
|
330
|
+
* callback *(function)*: `function (error)`
|
|
331
|
+
|
|
332
|
+
### <a name="readdir_w"></a>readDir(_adapter, dirName, options, callback)
|
|
333
|
+
Read content of folder in ioBroker DB
|
|
334
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
335
|
+
* dirName *(string)*: folder name, e.g `main`
|
|
336
|
+
* options *(object)*: optional `{filter: '*'}` or `{filter: '*.json'}`
|
|
337
|
+
* callback *(function)*: `function (error, files)` where `files` is an array of objects, like `{file: 'vis-views.json', isDir: false, stats: {size: 123}, modifiedAt: 1661336290090, acl: {owner: 'system.user.admin', ownerGroup: 'system.group.administrator', permissions: 1632, read: true, write: true}`
|
|
338
|
+
|
|
339
|
+
### <a name="chmodfile_w"></a>chmodFile(_adapter, fileName, options, callback)
|
|
340
|
+
Change file mode in ioBroker DB
|
|
341
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
342
|
+
* fileName *(string)*: file name, e.g `main/vis-views.json`
|
|
343
|
+
* options *(object)*: `{mode: 0x644}` or 0x644. First digit is user, second group, third others. Bit 1 is `execute`, bit 2 is `write`, bit 3 is `read`
|
|
344
|
+
* callback *(function)*: `function (error)`
|
|
345
|
+
|
|
346
|
+
### <a name="chownfile_w"></a>chownFile(_adapter, fileName, options, callback)
|
|
347
|
+
Change file owner in ioBroker DB
|
|
348
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
349
|
+
* fileName *(string)*: file name, e.g `main/vis-views.json`
|
|
350
|
+
* options *(object)*: `{owner: 'system.user.user', ownerGroup: ''system.group.administrator'}` or 'system.user.user'. If ownerGroup is not defined, it will be taken from owner.
|
|
351
|
+
* callback *(function)*: `function (error)`
|
|
352
|
+
|
|
353
|
+
### <a name="fileexists_w"></a>fileExists(_adapter, fileName, callback)
|
|
354
|
+
Checks if the file or folder exists in ioBroker DB
|
|
355
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
356
|
+
* fileName *(string)*: file name, e.g `main/vis-views.json`
|
|
357
|
+
* callback *(function)*: `function (error, isExist)`
|
|
358
|
+
|
|
359
|
+
### <a name="subscribefiles_w"></a>subscribeFiles(id, pattern, callback)
|
|
360
|
+
Subscribe on file changes in ioBroker DB
|
|
361
|
+
* id *(string)*: instance name, e.g. `vis.0` or any object ID of type `meta`. `id` could have wildcards `*` too.
|
|
362
|
+
* pattern *(string)*: file name pattern, e.g `main/*.json`
|
|
363
|
+
* callback *(function)*: `function (error)`
|
|
364
|
+
|
|
365
|
+
### <a name="unsubscribefiles_w"></a>unsubscribeFiles(id, pattern, callback)
|
|
366
|
+
Unsubscribe on file changes in ioBroker DB
|
|
367
|
+
* id *(string)*: instance name, e.g. `vis.0` or any object ID of type `meta`. `id` could have wildcards `*` too.
|
|
368
|
+
* pattern *(string)*: file name pattern, e.g `main/*.json`
|
|
369
|
+
* callback *(function)*: `function (error)`
|
|
370
|
+
|
|
371
|
+
### <a name="getadapterinstances_w"></a>getAdapterInstances(adapterName, callback)
|
|
372
|
+
Read all instances of the given adapter, or all instances of all adapters if adapterName is not defined
|
|
373
|
+
* adapterName *(string)*: optional adapter name, e.g `history`.
|
|
374
|
+
* callback *(function)*: `function (error, instanceList)`, where instanceList is an array of instance objects, e.g. `{_id: 'system.adapter.history.0', common: {name: 'history', ...}, native: {...}}`
|
|
375
|
+
|
|
376
|
+
<!-- WEB_METHODS_END -->
|
|
377
|
+
|
|
378
|
+
## Admin Methods
|
|
379
|
+
<!-- ADMIN_METHODS_START -->
|
|
380
|
+
### List of commands
|
|
381
|
+
* [authenticate](#authenticate_a)
|
|
382
|
+
* [error](#error_a)
|
|
383
|
+
* [log](#log_a)
|
|
384
|
+
* [getHistory](#gethistory_a)
|
|
385
|
+
* [httpGet](#httpget_a)
|
|
386
|
+
* [sendTo](#sendto_a)
|
|
387
|
+
* [sendToHost](#sendtohost_a)
|
|
388
|
+
* [authEnabled](#authenabled_a)
|
|
389
|
+
* [logout](#logout_a)
|
|
390
|
+
* [listPermissions](#listpermissions_a)
|
|
391
|
+
* [getUserPermissions](#getuserpermissions_a)
|
|
392
|
+
* [getVersion](#getversion_a)
|
|
393
|
+
* [getAdapterName](#getadaptername_a)
|
|
394
|
+
* [getHostByIp](#gethostbyip_a)
|
|
395
|
+
* [requireLog](#requirelog_a)
|
|
396
|
+
* [readLogs](#readlogs_a)
|
|
397
|
+
* [delState](#delstate_a)
|
|
398
|
+
* [cmdExec](#cmdexec_a)
|
|
399
|
+
* [eventsThreshold](#eventsthreshold_a)
|
|
400
|
+
* [getRatings](#getratings_a)
|
|
401
|
+
* [getCurrentInstance](#getcurrentinstance_a)
|
|
402
|
+
* [checkFeatureSupported](#checkfeaturesupported_a)
|
|
403
|
+
* [decrypt](#decrypt_a)
|
|
404
|
+
* [encrypt](#encrypt_a)
|
|
405
|
+
* [getIsEasyModeStrict](#getiseasymodestrict_a)
|
|
406
|
+
* [getEasyMode](#geteasymode_a)
|
|
407
|
+
* [getAdapters](#getadapters_a)
|
|
408
|
+
* [updateLicenses](#updatelicenses_a)
|
|
409
|
+
* [getCompactInstances](#getcompactinstances_a)
|
|
410
|
+
* [getCompactAdapters](#getcompactadapters_a)
|
|
411
|
+
* [getCompactInstalled](#getcompactinstalled_a)
|
|
412
|
+
* [getCompactSystemConfig](#getcompactsystemconfig_a)
|
|
413
|
+
* [getCompactSystemRepositories](#getcompactsystemrepositories_a)
|
|
414
|
+
* [getCompactRepository](#getcompactrepository_a)
|
|
415
|
+
* [getCompactHosts](#getcompacthosts_a)
|
|
416
|
+
* [addUser](#adduser_a)
|
|
417
|
+
* [delUser](#deluser_a)
|
|
418
|
+
* [addGroup](#addgroup_a)
|
|
419
|
+
* [delGroup](#delgroup_a)
|
|
420
|
+
* [changePassword](#changepassword_a)
|
|
421
|
+
* [getObject](#getobject_a)
|
|
422
|
+
* [getObjects](#getobjects_a)
|
|
423
|
+
* [subscribeObjects](#subscribeobjects_a)
|
|
424
|
+
* [unsubscribeObjects](#unsubscribeobjects_a)
|
|
425
|
+
* [getObjectView](#getobjectview_a)
|
|
426
|
+
* [setObject](#setobject_a)
|
|
427
|
+
* [getAllObjects](#getallobjects_a)
|
|
428
|
+
* [extendObject](#extendobject_a)
|
|
429
|
+
* [getForeignObjects](#getforeignobjects_a)
|
|
430
|
+
* [delObject](#delobject_a)
|
|
431
|
+
* [delObjects](#delobjects_a)
|
|
432
|
+
* [getStates](#getstates_a)
|
|
433
|
+
* [getState](#getstate_a)
|
|
434
|
+
* [setState](#setstate_a)
|
|
435
|
+
* [getBinaryState](#getbinarystate_a)
|
|
436
|
+
* [setBinaryState](#setbinarystate_a)
|
|
437
|
+
* [subscribe](#subscribe_a)
|
|
438
|
+
* [subscribeStates](#subscribestates_a)
|
|
439
|
+
* [unsubscribe](#unsubscribe_a)
|
|
440
|
+
* [unsubscribeStates](#unsubscribestates_a)
|
|
441
|
+
* [getForeignStates](#getforeignstates_a)
|
|
442
|
+
* [readFile](#readfile_a)
|
|
443
|
+
* [readFile64](#readfile64_a)
|
|
444
|
+
* [writeFile64](#writefile64_a)
|
|
445
|
+
* [writeFile](#writefile_a)
|
|
446
|
+
* [unlink](#unlink_a)
|
|
447
|
+
* [deleteFile](#deletefile_a)
|
|
448
|
+
* [deleteFolder](#deletefolder_a)
|
|
449
|
+
* [renameFile](#renamefile_a)
|
|
450
|
+
* [rename](#rename_a)
|
|
451
|
+
* [mkdir](#mkdir_a)
|
|
452
|
+
* [readDir](#readdir_a)
|
|
453
|
+
* [chmodFile](#chmodfile_a)
|
|
454
|
+
* [chownFile](#chownfile_a)
|
|
455
|
+
* [fileExists](#fileexists_a)
|
|
456
|
+
* [subscribeFiles](#subscribefiles_a)
|
|
457
|
+
* [unsubscribeFiles](#unsubscribefiles_a)
|
|
458
|
+
* [getAdapterInstances](#getadapterinstances_a)
|
|
459
|
+
### <a name="authenticate_a"></a>authenticate(user, pass, callback)
|
|
460
|
+
Authenticate user by login and password
|
|
461
|
+
* user *(string)*: user name
|
|
462
|
+
* pass *(string)*: password
|
|
463
|
+
* callback *(function)*: `function (isUserAuthenticated, isAuthenticationUsed)`
|
|
464
|
+
|
|
465
|
+
### <a name="error_a"></a>error(error)
|
|
466
|
+
Write error into ioBroker log
|
|
467
|
+
* error *(string)*: error text
|
|
468
|
+
|
|
469
|
+
### <a name="log_a"></a>log(text, level)
|
|
470
|
+
Write log entry into ioBroker log
|
|
471
|
+
* text *(string)*: log text
|
|
472
|
+
* level *(string)*: one of `['silly', 'debug', 'info', 'warn', 'error']`. Default is 'debug'.
|
|
473
|
+
|
|
474
|
+
### <a name="gethistory_a"></a>getHistory(id, options, callback)
|
|
475
|
+
Get history data from specific instance
|
|
476
|
+
* id *(string)*: object ID
|
|
477
|
+
* options *(object)*: See object description here: https://github.com/ioBroker/ioBroker.history/blob/master/docs/en/README.md#access-values-from-javascript-adapter
|
|
478
|
+
* callback *(function)*: `function (error, result)`
|
|
479
|
+
|
|
480
|
+
### <a name="httpget_a"></a>httpGet(url, callback)
|
|
481
|
+
Read content of HTTP(S) page server-side (without CORS and stuff)
|
|
482
|
+
* url *(string)*: Page URL
|
|
483
|
+
* callback *(function)*: `function (error, {status, statusText}, body)`
|
|
484
|
+
|
|
485
|
+
### <a name="sendto_a"></a>sendTo(adapterInstance, command, message, callback)
|
|
486
|
+
Send message to specific instance
|
|
487
|
+
* adapterInstance *(string)*: instance name, e.g. `history.0`
|
|
488
|
+
* command *(string)*: command name
|
|
489
|
+
* message *(object)*: message is instance dependent
|
|
490
|
+
* callback *(function)*: `function (result)`
|
|
491
|
+
|
|
492
|
+
### <a name="sendtohost_a"></a>sendToHost(host, command, message, callback)
|
|
493
|
+
Send message to specific host.
|
|
494
|
+
Host can answer following commands: `cmdExec, getRepository, getInstalled, getInstalledAdapter, getVersion, getDiagData, getLocationOnDisk, getDevList, getLogs, getHostInfo, delLogs, readDirAsZip, writeDirAsZip, readObjectsAsZip, writeObjectsAsZip, checkLogging, updateMultihost`.
|
|
495
|
+
* host *(string)*: instance name, e.g. `history.0`
|
|
496
|
+
* command *(string)*: command name
|
|
497
|
+
* message *(object)*: message is command specific
|
|
498
|
+
* callback *(function)*: `function (result)`
|
|
499
|
+
|
|
500
|
+
### <a name="authenabled_a"></a>authEnabled(callback)
|
|
501
|
+
Ask server is authentication enabled and if the user authenticated
|
|
502
|
+
* callback *(function)*: `function (isAuthenticationUsed, userName)`
|
|
503
|
+
|
|
504
|
+
### <a name="logout_a"></a>logout(callback)
|
|
505
|
+
Logout user
|
|
506
|
+
* callback *(function)*: function (error)
|
|
507
|
+
|
|
508
|
+
### <a name="listpermissions_a"></a>listPermissions(callback)
|
|
509
|
+
List commands and permissions
|
|
510
|
+
* callback *(function)*: `function (permissions)`
|
|
511
|
+
|
|
512
|
+
### <a name="getuserpermissions_a"></a>getUserPermissions(callback)
|
|
513
|
+
Get user permissions
|
|
514
|
+
* callback *(function)*: `function (error, permissions)`
|
|
515
|
+
|
|
516
|
+
### <a name="getversion_a"></a>getVersion(callback)
|
|
517
|
+
Get adapter version. Not the socket-classes version!
|
|
518
|
+
* callback *(function)*: `function (error, adapterVersion, adapterName)`
|
|
519
|
+
|
|
520
|
+
### <a name="getadaptername_a"></a>getAdapterName(callback)
|
|
521
|
+
Get adapter name. Not the socket-classes version!
|
|
522
|
+
* callback *(function)*: `function (error, adapterVersion)`
|
|
523
|
+
|
|
524
|
+
### <a name="gethostbyip_a"></a>getHostByIp(ip, callback)
|
|
525
|
+
Read host object by IP address
|
|
526
|
+
* ip *(string)*: ip address. IPv4 or IPv6
|
|
527
|
+
* callback *(function)*: `function (ip, obj)`. If host not found, obj is null
|
|
528
|
+
|
|
529
|
+
### <a name="requirelog_a"></a>requireLog(isEnabled, callback)
|
|
530
|
+
Activate or deactivate logging events. Events will be sent to the socket as `log` event. Adapter must have `common.logTransporter = true`
|
|
531
|
+
* isEnabled *(boolean)*: is logging enabled
|
|
532
|
+
* callback *(function)*: `function (error)`
|
|
533
|
+
|
|
534
|
+
### <a name="readlogs_a"></a>readLogs(host, callback)
|
|
535
|
+
Get logs file from given host
|
|
536
|
+
* host *(string)*: host id, like 'system.host.raspberrypi'
|
|
537
|
+
* callback *(function)*: `function (error, files)`, where `files` is array of `{fileName: `log/hostname/transport/file`, size: 123}`
|
|
538
|
+
|
|
539
|
+
### <a name="delstate_a"></a>delState(id, callback)
|
|
540
|
+
Delete state. Corresponding object will be deleted too.
|
|
541
|
+
* id *(string)*: state ID
|
|
542
|
+
* callback *(function)*: `function (error)`
|
|
543
|
+
|
|
544
|
+
### <a name="cmdexec_a"></a>cmdExec(host, id, cmd, callback)
|
|
545
|
+
Execute shell command on host/controller. Following response commands are expected: ´cmdStdout, cmdStderr, cmdExit´
|
|
546
|
+
* host *(string)*: host name, like 'system.host.raspberrypi'
|
|
547
|
+
* id *(string)*: session ID, like `Date.now()´. This session ID will come in events `cmdStdout, cmdStderr, cmdExit`
|
|
548
|
+
* cmd *(string)*: command
|
|
549
|
+
* callback *(function)*: `function (error)`
|
|
550
|
+
|
|
551
|
+
### <a name="eventsthreshold_a"></a>eventsThreshold(isActive)
|
|
552
|
+
Used only for admin to limit number of events to front-end.
|
|
553
|
+
* isActive *(boolean)*: if true, then events will be limited
|
|
554
|
+
|
|
555
|
+
### <a name="getratings_a"></a>getRatings(update, callback)
|
|
556
|
+
Read ratings of adapters
|
|
557
|
+
* update *(boolean)*: if true, the ratings will be read from central server, if false from local cache
|
|
558
|
+
* callback *(function)*: `function (error, ratings)`, where `ratings` is object like `{accuweather: {rating: {r: 3.33, c: 3}, 1.2.1: {r: 3, c: 1}},…}`
|
|
559
|
+
|
|
560
|
+
### <a name="getcurrentinstance_a"></a>getCurrentInstance(callback)
|
|
561
|
+
Return current instance name like `admin.0`
|
|
562
|
+
* callback *(function)*: `function (error, namespace)`
|
|
563
|
+
|
|
564
|
+
### <a name="checkfeaturesupported_a"></a>checkFeatureSupported(feature, callback)
|
|
565
|
+
Checks if same feature is supported by current js-controller
|
|
566
|
+
* feature *(string)*: feature name like `CONTROLLER_LICENSE_MANAGER`
|
|
567
|
+
* callback *(function)*: `function (error, isSupported)`
|
|
568
|
+
|
|
569
|
+
### <a name="decrypt_a"></a>decrypt(encryptedText, callback)
|
|
570
|
+
Decrypts text with system secret key
|
|
571
|
+
* encryptedText *(string)*: encrypted text
|
|
572
|
+
* callback *(function)*: `function (error, decryptedText)`
|
|
573
|
+
|
|
574
|
+
### <a name="encrypt_a"></a>encrypt(plainText, callback)
|
|
575
|
+
Encrypts text with system secret key
|
|
576
|
+
* plainText *(string)*: normal text
|
|
577
|
+
* callback *(function)*: `function (error, encryptedText)`
|
|
578
|
+
|
|
579
|
+
### <a name="getiseasymodestrict_a"></a>getIsEasyModeStrict(callback)
|
|
580
|
+
Returns if admin has easy mode enabled
|
|
581
|
+
* callback *(function)*: `function (error, isEasyModeStrict)`
|
|
582
|
+
|
|
583
|
+
### <a name="geteasymode_a"></a>getEasyMode(callback)
|
|
584
|
+
Get easy mode configuration
|
|
585
|
+
* callback *(function)*: `function (error, easyModeConfig)`, where `easyModeConfig` is object like `{strict: true, configs: [{_id: 'system.adapter.javascript.0', common: {...}}, {...}]}`
|
|
586
|
+
|
|
587
|
+
### <a name="getadapters_a"></a>getAdapters(adapterName, callback)
|
|
588
|
+
Read all adapters objects
|
|
589
|
+
* adapterName *(string)*: optional adapter name
|
|
590
|
+
* callback *(function)*: `function (error, results)`, where `results` is array of objects like `{_id: 'system.adapter.javascript', common: {...}}`
|
|
591
|
+
|
|
592
|
+
### <a name="updatelicenses_a"></a>updateLicenses(login, password, callback)
|
|
593
|
+
Read software licenses (vis, knx, ...) from ioBroker.net cloud for given user
|
|
594
|
+
* login *(string)*: cloud login
|
|
595
|
+
* password *(string)*: cloud password
|
|
596
|
+
* callback *(function)*: `function (error, results)`, where `results` is array of objects like `[{"json":"xxx","id":"ab","email":"dogafox@gmail.com","product":"iobroker.knx.year","version":"2","invoice":"Pxx","uuid":"uuid","time":"2021-11-16T19:53:02.000Z","validTill":"2022-11-16T22:59:59.000Z","datapoints":1000}]`
|
|
597
|
+
|
|
598
|
+
### <a name="getcompactinstances_a"></a>getCompactInstances(callback)
|
|
599
|
+
Read all instances in short form to save bandwidth
|
|
600
|
+
* callback *(function)*: `function (error, results)`, where `results` is an object like `{'system.adapter.javascript.0': {adminTab, name, icon, enabled}}`
|
|
601
|
+
|
|
602
|
+
### <a name="getcompactadapters_a"></a>getCompactAdapters(callback)
|
|
603
|
+
Read all adapters in short for to save bandwidth
|
|
604
|
+
* callback *(function)*: `function (error, results)`, where `results` is an object like `{'javascript': {icon, v: '1.0.1', iv: 'ignoredVersion}}`
|
|
605
|
+
|
|
606
|
+
### <a name="getcompactinstalled_a"></a>getCompactInstalled(host, callback)
|
|
607
|
+
Read all installed adapters in short form to save bandwidth
|
|
608
|
+
* callback *(function)*: `function (error, results)`, where `results` is an object like `{'javascript': {version: '1.0.1'}}``
|
|
609
|
+
|
|
610
|
+
### <a name="getcompactsystemconfig_a"></a>getCompactSystemConfig(callback)
|
|
611
|
+
Read system config in short form to save bandwidth
|
|
612
|
+
* callback *(function)*: `function (error, systemConfig)`, where `systemConfig` is an object like `{common: {...}, native: {secret: 'aaa'}}`
|
|
613
|
+
|
|
614
|
+
### <a name="getcompactsystemrepositories_a"></a>getCompactSystemRepositories(callback)
|
|
615
|
+
Read repositories from cache in short form to save bandwidth
|
|
616
|
+
* callback *(function)*: `function (error, repositories)`, where `repositories` is an object like `{_id: 'system.repositories', common: {...}, native: {repositories: {default: {json: {_repoInfo: {...}}}}}}`
|
|
617
|
+
|
|
618
|
+
### <a name="getcompactrepository_a"></a>getCompactRepository(host, callback)
|
|
619
|
+
Read current repository in short form to save bandwidth
|
|
620
|
+
* callback *(function)*: `function (error, repository)`, where `repository` is an object like `{'javascript': {version: '1.0.1', icon}, 'admin': {version: '1.0.1', icon}}`
|
|
621
|
+
|
|
622
|
+
### <a name="getcompacthosts_a"></a>getCompactHosts(callback)
|
|
623
|
+
Read all hosts in short form to save bandwidth
|
|
624
|
+
* callback *(function)*: `function (error, hosts)`, where `hosts` is an array of objects like `[{_id:'system.host.raspi',common:{name:'raspi',icon:'icon',color:'blue',installedVersion:'2.1.0'},native:{hardware:{networkInterfaces:[...]}}}]`
|
|
625
|
+
|
|
626
|
+
### <a name="adduser_a"></a>addUser(user, pass, callback)
|
|
627
|
+
Add new user
|
|
628
|
+
* user *(string)*: user name, like `benjamin`
|
|
629
|
+
* pass *(string)*: user password
|
|
630
|
+
* callback *(function)*: `function (error)`
|
|
631
|
+
|
|
632
|
+
### <a name="deluser_a"></a>delUser(user, callback)
|
|
633
|
+
Delete existing user. Admin cannot be deleted.
|
|
634
|
+
* user *(string)*: user name, like 'benjamin
|
|
635
|
+
* callback *(function)*: `function (error)`
|
|
636
|
+
|
|
637
|
+
### <a name="addgroup_a"></a>addGroup(group, desc, acl, callback)
|
|
638
|
+
Add new group.
|
|
639
|
+
* group *(string)*: user name, like 'benjamin
|
|
640
|
+
* desc *(string)*: optional description
|
|
641
|
+
* acl *(object)*: optional access control list object, like `{"object":{"list":true,"read":true,"write":false,"delete":false},"state":{"list":true,"read":true,"write":true,"create":true,"delete":false},"users":{"list":true,"read":true,"write":false,"create":false,"delete":false},"other":{"execute":false,"http":true,"sendto":false},"file":{"list":true,"read":true,"write":false,"create":false,"delete":false}}`
|
|
642
|
+
* callback *(function)*: `function (error)`
|
|
643
|
+
|
|
644
|
+
### <a name="delgroup_a"></a>delGroup(group, callback)
|
|
645
|
+
Delete existing group. Administrator group cannot be deleted.
|
|
646
|
+
* group *(string)*: group name, like 'users`
|
|
647
|
+
* callback *(function)*: `function (error)`
|
|
648
|
+
|
|
649
|
+
### <a name="changepassword_a"></a>changePassword(user, pass, callback)
|
|
650
|
+
Change user password
|
|
651
|
+
* user *(string)*: user name, like 'benjamin`
|
|
652
|
+
* pass *(string)*: new password
|
|
653
|
+
* callback *(function)*: `function (error)`
|
|
654
|
+
|
|
655
|
+
### <a name="getobject_a"></a>getObject(id, callback)
|
|
656
|
+
Get one object
|
|
657
|
+
* id *(string)*: object ID.
|
|
658
|
+
* callback *(function)*: `function (error, obj)`
|
|
659
|
+
|
|
660
|
+
### <a name="getobjects_a"></a>getObjects(callback)
|
|
661
|
+
Read absolutely all objects. Same as `getAllObjects`.
|
|
662
|
+
* callback *(function)*: `function (error, objects)`, where `objects` is an object like `{'system.adapter.admin.0': {...}, 'system.adapter.web.0': {...}}`
|
|
663
|
+
|
|
664
|
+
### <a name="subscribeobjects_a"></a>subscribeObjects(pattern, callback)
|
|
665
|
+
Subscribe on object changes by pattern. The events will come as 'objectChange' events to the socket.
|
|
666
|
+
* pattern *(string)*: pattern like 'system.adapter.*' or array of IDs like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
|
|
667
|
+
* callback *(function)*: `function (error)`
|
|
668
|
+
|
|
669
|
+
### <a name="unsubscribeobjects_a"></a>unsubscribeObjects(pattern, callback)
|
|
670
|
+
Unsubscribe on object changes by pattern.
|
|
671
|
+
* pattern *(string)*: pattern like 'system.adapter.*' or array of IDs like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
|
|
672
|
+
* callback *(function)*: `function (error)`
|
|
673
|
+
|
|
674
|
+
### <a name="getobjectview_a"></a>getObjectView(design, search, params, callback)
|
|
675
|
+
Make a query to the object database.
|
|
676
|
+
* design *(string)*: 'system' or other designs like `custom`, but it must exist object `_design/custom`. Too 99,9% use `system`.
|
|
677
|
+
* search *(string)*: object type, like `state`, `instance`, `adapter`, `host`, ...
|
|
678
|
+
* params *(string)*: parameters for the query in form `{startkey: 'system.adapter.', endkey: 'system.adapter.\u9999'}`
|
|
679
|
+
* callback *(function)*: `function (error)`
|
|
680
|
+
|
|
681
|
+
### <a name="setobject_a"></a>setObject(id, obj, callback)
|
|
682
|
+
Set object.
|
|
683
|
+
* id *(string)*: object ID
|
|
684
|
+
* obj *(object)*: object itself
|
|
685
|
+
* callback *(function)*: `function (error)`
|
|
686
|
+
|
|
687
|
+
### <a name="getallobjects_a"></a>getAllObjects(callback)
|
|
688
|
+
Read absolutely all objects
|
|
689
|
+
* callback *(function)*: `function (error, objects)`, where `objects` is an object like `{'system.adapter.admin.0': {...}, 'system.adapter.web.0': {...}}`
|
|
690
|
+
|
|
691
|
+
### <a name="extendobject_a"></a>extendObject(id, obj, callback)
|
|
692
|
+
Extend existing object
|
|
693
|
+
* id *(string)*: object ID
|
|
694
|
+
* obj *(object)*: new parts of the object, like `{common: {name: 'new name'}}`
|
|
695
|
+
* callback *(function)*: `function (error)`
|
|
696
|
+
|
|
697
|
+
### <a name="getforeignobjects_a"></a>getForeignObjects(pattern, type, callback)
|
|
698
|
+
Read objects by pattern
|
|
699
|
+
* pattern *(string)*: pattern like `system.adapter.admin.0.*`
|
|
700
|
+
* type *(string)*: type of objects to delete, like `state`, `channel`, `device`, `host`, `adapter`. Default - `state`
|
|
701
|
+
* callback *(function)*: `function (error, objects)`, where `objects` is an object like `{'system.adapter.admin.0': {...}, 'system.adapter.web.0': {...}}`
|
|
702
|
+
|
|
703
|
+
### <a name="delobject_a"></a>delObject(id, options, callback)
|
|
704
|
+
Delete object. Only deletion of flot objects is allowed
|
|
705
|
+
* id *(string)*: Object ID like, 'flot.0.myChart'
|
|
706
|
+
* options *(string)*: ignored
|
|
707
|
+
* callback *(function)*: `function (error)`
|
|
708
|
+
|
|
709
|
+
### <a name="delobjects_a"></a>delObjects(id, options, callback)
|
|
710
|
+
Delete objects recursively. Objects with `dontDelete` cannot be deleted. Same as `delObject` but with `recursive: true`.
|
|
711
|
+
* id *(string)*: Object ID like, 'adapterName.0.channel'
|
|
712
|
+
* options *(string)*: optional
|
|
713
|
+
* callback *(function)*: `function (error)`
|
|
714
|
+
|
|
715
|
+
### <a name="getstates_a"></a>getStates(pattern, callback)
|
|
716
|
+
Read states by pattern
|
|
717
|
+
* pattern *(string)*: optional pattern, like `system.adapter.*` or array of state IDs
|
|
718
|
+
* callback *(function)*: `function (error, states)`, where `states` is an object like `{'system.adapter.history.0': {_id: 'system.adapter.history.0', common: {name: 'history', ...}, native: {...}, 'system.adapter.history.1': {...}}}`
|
|
719
|
+
|
|
720
|
+
### <a name="getstate_a"></a>getState(id, callback)
|
|
721
|
+
Read one state.
|
|
722
|
+
* id *(string)*: State ID like, 'system.adapter.admin.0.memRss'
|
|
723
|
+
* callback *(function)*: `function (error, state)`, where `state` is an object like `{val: 123, ts: 1663915537418, ack: true, from: 'system.adapter.admin.0', q: 0, lc: 1663915537418, c: 'javascript.0'}`
|
|
724
|
+
|
|
725
|
+
### <a name="setstate_a"></a>setState(id, state, callback)
|
|
726
|
+
Write one state.
|
|
727
|
+
* id *(string)*: State ID like, 'system.adapter.admin.0.memRss'
|
|
728
|
+
* state *(any)*: value or object like `{val: 123, ack: true}`
|
|
729
|
+
* callback *(function)*: `function (error, state)`, where `state` is an object like `{val: 123, ts: 1663915537418, ack: true, from: 'system.adapter.admin.0', q: 0, lc: 1663915537418, c: 'javascript.0'}`
|
|
730
|
+
|
|
731
|
+
### <a name="getbinarystate_a"></a>getBinaryState(id, callback)
|
|
732
|
+
Read one binary state.
|
|
733
|
+
* id *(string)*: State ID like, 'javascript.0.binary'
|
|
734
|
+
* callback *(function)*: `function (error, base64)`
|
|
735
|
+
|
|
736
|
+
### <a name="setbinarystate_a"></a>setBinaryState(id, base64, callback)
|
|
737
|
+
Write one binary state.
|
|
738
|
+
* id *(string)*: State ID like, 'javascript.0.binary'
|
|
739
|
+
* base64 *(string)*: State value as base64 string. Binary states has no acknowledge flag.
|
|
740
|
+
* callback *(function)*: `function (error)`
|
|
741
|
+
|
|
742
|
+
### <a name="subscribe_a"></a>subscribe(pattern, callback)
|
|
743
|
+
Subscribe on state changes by pattern. The events will come as 'stateChange' events to the socket.
|
|
744
|
+
* pattern *(string)*: pattern like 'system.adapter.*' or array of states like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
|
|
745
|
+
* callback *(function)*: `function (error)`
|
|
746
|
+
|
|
747
|
+
### <a name="subscribestates_a"></a>subscribeStates(pattern, callback)
|
|
748
|
+
Subscribe on state changes by pattern. Same as `subscribe`. The events will come as 'stateChange' events to the socket.
|
|
749
|
+
* pattern *(string)*: pattern like 'system.adapter.*' or array of states like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
|
|
750
|
+
* callback *(function)*: `function (error)`
|
|
751
|
+
|
|
752
|
+
### <a name="unsubscribe_a"></a>unsubscribe(pattern, callback)
|
|
753
|
+
Unsubscribe from state changes by pattern.
|
|
754
|
+
* pattern *(string)*: pattern like 'system.adapter.*' or array of states like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
|
|
755
|
+
* callback *(function)*: `function (error)`
|
|
756
|
+
|
|
757
|
+
### <a name="unsubscribestates_a"></a>unsubscribeStates(pattern, callback)
|
|
758
|
+
Unsubscribe from state changes by pattern. Same as `unsubscribe`.
|
|
759
|
+
* pattern *(string)*: pattern like 'system.adapter.*' or array of states like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
|
|
760
|
+
* callback *(function)*: `function (error)`
|
|
761
|
+
|
|
762
|
+
### <a name="getforeignstates_a"></a>getForeignStates(pattern, callback)
|
|
763
|
+
Change user password
|
|
764
|
+
* user *(string)*: user name, like 'benjamin`
|
|
765
|
+
* pass *(string)*: new password
|
|
766
|
+
* callback *(function)*: `function (error)`
|
|
767
|
+
|
|
768
|
+
### <a name="readfile_a"></a>readFile(_adapter, fileName, callback)
|
|
769
|
+
Read file from ioBroker DB
|
|
770
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
771
|
+
* fileName *(string)*: file name, e.g `main/vis-views.json`
|
|
772
|
+
* callback *(function)*: `function (error, data, mimeType)`
|
|
773
|
+
|
|
774
|
+
### <a name="readfile64_a"></a>readFile64(_adapter, fileName, callback)
|
|
775
|
+
Read file from ioBroker DB as base64 string
|
|
776
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
777
|
+
* fileName *(string)*: file name, e.g `main/vis-views.json`
|
|
778
|
+
* callback *(function)*: `function (error, base64, mimeType)`
|
|
779
|
+
|
|
780
|
+
### <a name="writefile64_a"></a>writeFile64(_adapter, fileName, data64, options, callback)
|
|
781
|
+
Write file into ioBroker DB as base64 string
|
|
782
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
783
|
+
* fileName *(string)*: file name, e.g `main/vis-views.json`
|
|
784
|
+
* data64 *(string)*: file content as base64 string
|
|
785
|
+
* options *(object)*: optional `{mode: 0x0644}`
|
|
786
|
+
* callback *(function)*: `function (error)`
|
|
787
|
+
|
|
788
|
+
### <a name="writefile_a"></a>writeFile(_adapter, fileName, data64, options, callback)
|
|
789
|
+
Write file into ioBroker DB as base64 string
|
|
790
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
791
|
+
* fileName *(string)*: file name, e.g `main/vis-views.json`
|
|
792
|
+
* data64 *(string)*: file content as base64 string
|
|
793
|
+
* options *(object)*: optional `{mode: 0x0644}`
|
|
794
|
+
* callback *(function)*: `function (error)`
|
|
795
|
+
|
|
796
|
+
### <a name="unlink_a"></a>unlink(_adapter, name, callback)
|
|
797
|
+
Delete file in ioBroker DB
|
|
798
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
799
|
+
* name *(string)*: file name, e.g `main/vis-views.json`
|
|
800
|
+
* callback *(function)*: `function (error)`
|
|
801
|
+
|
|
802
|
+
### <a name="deletefile_a"></a>deleteFile(_adapter, name, callback)
|
|
803
|
+
Delete file in ioBroker DB (same as unlink, but only for files)
|
|
804
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
805
|
+
* name *(string)*: file name, e.g `main/vis-views.json`
|
|
806
|
+
* callback *(function)*: `function (error)`
|
|
807
|
+
|
|
808
|
+
### <a name="deletefolder_a"></a>deleteFolder(_adapter, name, callback)
|
|
809
|
+
Delete file in ioBroker DB (same as unlink, but only for folders)
|
|
810
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
811
|
+
* name *(string)*: folder name, e.g `main`
|
|
812
|
+
* callback *(function)*: `function (error)`
|
|
813
|
+
|
|
814
|
+
### <a name="renamefile_a"></a>renameFile(_adapter, oldName, newName, callback)
|
|
815
|
+
Rename file in ioBroker DB
|
|
816
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
817
|
+
* oldName *(string)*: current file name, e.g `main/vis-views.json`
|
|
818
|
+
* newName *(string)*: new file name, e.g `main/vis-views-new.json`
|
|
819
|
+
* callback *(function)*: `function (error)`
|
|
820
|
+
|
|
821
|
+
### <a name="rename_a"></a>rename(_adapter, oldName, newName, callback)
|
|
822
|
+
Rename file or folder in ioBroker DB
|
|
823
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
824
|
+
* oldName *(string)*: current file name, e.g `main/vis-views.json`
|
|
825
|
+
* newName *(string)*: new file name, e.g `main/vis-views-new.json`
|
|
826
|
+
* callback *(function)*: `function (error)`
|
|
827
|
+
|
|
828
|
+
### <a name="mkdir_a"></a>mkdir(_adapter, dirName, callback)
|
|
829
|
+
Create folder in ioBroker DB
|
|
830
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
831
|
+
* dirName *(string)*: desired folder name, e.g `main`
|
|
832
|
+
* callback *(function)*: `function (error)`
|
|
833
|
+
|
|
834
|
+
### <a name="readdir_a"></a>readDir(_adapter, dirName, options, callback)
|
|
835
|
+
Read content of folder in ioBroker DB
|
|
836
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
837
|
+
* dirName *(string)*: folder name, e.g `main`
|
|
838
|
+
* options *(object)*: optional `{filter: '*'}` or `{filter: '*.json'}`
|
|
839
|
+
* callback *(function)*: `function (error, files)` where `files` is an array of objects, like `{file: 'vis-views.json', isDir: false, stats: {size: 123}, modifiedAt: 1661336290090, acl: {owner: 'system.user.admin', ownerGroup: 'system.group.administrator', permissions: 1632, read: true, write: true}`
|
|
840
|
+
|
|
841
|
+
### <a name="chmodfile_a"></a>chmodFile(_adapter, fileName, options, callback)
|
|
842
|
+
Change file mode in ioBroker DB
|
|
843
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
844
|
+
* fileName *(string)*: file name, e.g `main/vis-views.json`
|
|
845
|
+
* options *(object)*: `{mode: 0x644}` or 0x644. First digit is user, second group, third others. Bit 1 is `execute`, bit 2 is `write`, bit 3 is `read`
|
|
846
|
+
* callback *(function)*: `function (error)`
|
|
847
|
+
|
|
848
|
+
### <a name="chownfile_a"></a>chownFile(_adapter, fileName, options, callback)
|
|
849
|
+
Change file owner in ioBroker DB
|
|
850
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
851
|
+
* fileName *(string)*: file name, e.g `main/vis-views.json`
|
|
852
|
+
* options *(object)*: `{owner: 'system.user.user', ownerGroup: ''system.group.administrator'}` or 'system.user.user'. If ownerGroup is not defined, it will be taken from owner.
|
|
853
|
+
* callback *(function)*: `function (error)`
|
|
854
|
+
|
|
855
|
+
### <a name="fileexists_a"></a>fileExists(_adapter, fileName, callback)
|
|
856
|
+
Checks if the file or folder exists in ioBroker DB
|
|
857
|
+
* _adapter *(string)*: instance name, e.g. `vis.0`
|
|
858
|
+
* fileName *(string)*: file name, e.g `main/vis-views.json`
|
|
859
|
+
* callback *(function)*: `function (error, isExist)`
|
|
860
|
+
|
|
861
|
+
### <a name="subscribefiles_a"></a>subscribeFiles(id, pattern, callback)
|
|
862
|
+
Subscribe on file changes in ioBroker DB
|
|
863
|
+
* id *(string)*: instance name, e.g. `vis.0` or any object ID of type `meta`. `id` could have wildcards `*` too.
|
|
864
|
+
* pattern *(string)*: file name pattern, e.g `main/*.json`
|
|
865
|
+
* callback *(function)*: `function (error)`
|
|
866
|
+
|
|
867
|
+
### <a name="unsubscribefiles_a"></a>unsubscribeFiles(id, pattern, callback)
|
|
868
|
+
Unsubscribe on file changes in ioBroker DB
|
|
869
|
+
* id *(string)*: instance name, e.g. `vis.0` or any object ID of type `meta`. `id` could have wildcards `*` too.
|
|
870
|
+
* pattern *(string)*: file name pattern, e.g `main/*.json`
|
|
871
|
+
* callback *(function)*: `function (error)`
|
|
872
|
+
|
|
873
|
+
### <a name="getadapterinstances_a"></a>getAdapterInstances(adapterName, callback)
|
|
874
|
+
Read all instances of the given adapter, or all instances of all adapters if adapterName is not defined
|
|
875
|
+
* adapterName *(string)*: optional adapter name, e.g `history`.
|
|
876
|
+
* callback *(function)*: `function (error, instanceList)`, where instanceList is an array of instance objects, e.g. `{_id: 'system.adapter.history.0', common: {name: 'history', ...}, native: {...}}`
|
|
877
|
+
|
|
878
|
+
<!-- ADMIN_METHODS_END -->
|
|
879
|
+
|
|
66
880
|
<!--
|
|
67
881
|
Placeholder for the next version (at the beginning of the line):
|
|
68
882
|
### **WORK IN PROGRESS**
|
|
69
883
|
-->
|
|
70
884
|
|
|
71
885
|
## Changelog
|
|
886
|
+
### 0.5.4 (2022-09-23)
|
|
887
|
+
* (bluefox) Fixed error in `delObjects` method
|
|
888
|
+
|
|
72
889
|
### 0.5.3 (2022-08-24)
|
|
73
890
|
* (bluefox) Caught error by subscribe
|
|
74
891
|
|