@iobroker/socket-classes 1.1.5 → 1.3.1

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 CHANGED
@@ -63,6 +63,59 @@ io.start(server.server, ws, {userKey: 'connect.sid', checkUser, store, secret: a
63
63
  io.close();
64
64
  ```
65
65
 
66
+ ## GUI subscribes
67
+ GUI client can send to desired instance the `subscribe` message
68
+ ```
69
+ socket.emit('clientSubscribe', 'cameras.0', 'startCamera', {width: 640, height: 480}, result => console.log('Started: ' + result));
70
+ ```
71
+
72
+ The instance 'cameras.0' will receive message `clientSubscribe` with information who want to receive messages.
73
+ ```
74
+ adapter.on('message', obj => {
75
+ if (obj?.command === 'clientSubscribe') {
76
+ if (obj?.message.type && obj.message.type.startsWith('startCamera/')) {
77
+ const [, camera] = obj.message.type.split('/');
78
+ // start camera with obj.message.data
79
+ // ...
80
+
81
+ // inform GUI that camera is started
82
+ adapter.sendTo(obj.from, obj.command, {result: true}, obj.callback);
83
+ this.subscribes = this.subscribes || [];
84
+ this.subscribes.push({sid: obj.message.sid, from: obj.from, type: obj.message.type, camera});
85
+ }
86
+ } else
87
+ if (obj?.command === 'clientUnsubscribe' || obj?.command === 'clientSubscribeError') {
88
+ if (obj?.message.type && obj.message.type.startsWith('startCamera/')) {
89
+ const [, camera] = obj.message.type.split('/');
90
+ if (this.subscribes) {
91
+ const pos = this.subscribes.findIndex(s => s.sid === obj.message.sid && s.from === obj.from && s.type === obj.message.type);
92
+ if (pos !== -1) {
93
+ this.subscribes.splice(pos, 1);
94
+
95
+ // stop camera
96
+ // ...
97
+ }
98
+ }
99
+ }
100
+ }
101
+ });
102
+ ```
103
+
104
+ and after that client will receive messages from instance
105
+
106
+ ```
107
+ function sendImage(camera, data) {
108
+ this.subscribes.forEach(it => {
109
+ if (it.camera !== camera) {
110
+ return;
111
+ }
112
+ // send image to GUI
113
+ adapter.sendTo(it.from, 'im', {m: it.type, s: it.sid, d: data});
114
+ });
115
+ }
116
+ ```
117
+
118
+
66
119
  ## Web Methods
67
120
  <!-- WEB_METHODS_START -->
68
121
  ### List of commands
@@ -86,6 +139,8 @@ io.close();
86
139
  * [getObjectView](#getobjectview_w)
87
140
  * [setObject](#setobject_w)
88
141
  * [delObject](#delobject_w)
142
+ * [clientSubscribe](#clientsubscribe_w)
143
+ * [clientUnsubscribe](#clientunsubscribe_w)
89
144
  * [getStates](#getstates_w)
90
145
  * [getForeignStates](#getforeignstates_w)
91
146
  * [getState](#getstate_w)
@@ -140,22 +195,22 @@ Read content of HTTP(S) page server-side (without CORS and stuff)
140
195
  * callback *(function)*: `function (error, {status, statusText}, body)`
141
196
 
142
197
  ### <a name="sendto_w"></a>sendTo(adapterInstance, command, message, callback)
143
- Send message to specific instance
198
+ Send the message to specific instance
144
199
  * adapterInstance *(string)*: instance name, e.g. `history.0`
145
200
  * command *(string)*: command name
146
- * message *(object)*: message is instance dependent
201
+ * message *(object)*: the message is instance dependent
147
202
  * callback *(function)*: `function (result)`
148
203
 
149
204
  ### <a name="sendtohost_w"></a>sendToHost(host, command, message, callback)
150
- Send message to specific host.
151
- Host can answer following commands: `cmdExec, getRepository, getInstalled, getInstalledAdapter, getVersion, getDiagData, getLocationOnDisk, getDevList, getLogs, getHostInfo, delLogs, readDirAsZip, writeDirAsZip, readObjectsAsZip, writeObjectsAsZip, checkLogging, updateMultihost`.
205
+ Send a message to the specific host.
206
+ Host can answer to the following commands: `cmdExec, getRepository, getInstalled, getInstalledAdapter, getVersion, getDiagData, getLocationOnDisk, getDevList, getLogs, getHostInfo, delLogs, readDirAsZip, writeDirAsZip, readObjectsAsZip, writeObjectsAsZip, checkLogging, updateMultihost`.
152
207
  * host *(string)*: instance name, e.g. `history.0`
153
208
  * command *(string)*: command name
154
- * message *(object)*: message is command specific
209
+ * message *(object)*: the message is command-specific
155
210
  * callback *(function)*: `function (result)`
156
211
 
157
212
  ### <a name="authenabled_w"></a>authEnabled(callback)
158
- Ask server is authentication enabled and if the user authenticated
213
+ Ask server is authentication enabled, and if the user authenticated
159
214
  * callback *(function)*: `function (isAuthenticationUsed, userName)`
160
215
 
161
216
  ### <a name="logout_w"></a>logout(callback)
@@ -171,7 +226,7 @@ Get user permissions
171
226
  * callback *(function)*: `function (error, permissions)`
172
227
 
173
228
  ### <a name="getversion_w"></a>getVersion(callback)
174
- Get adapter version. Not the socket-classes version!
229
+ Get the adapter version. Not the socket-classes version!
175
230
  * callback *(function)*: `function (error, adapterVersion, adapterName)`
176
231
 
177
232
  ### <a name="getadaptername_w"></a>getAdapterName(callback)
@@ -183,18 +238,19 @@ Get one object
183
238
  * id *(string)*: object ID.
184
239
  * callback *(function)*: `function (error, obj)`
185
240
 
186
- ### <a name="getobjects_w"></a>getObjects(callback)
241
+ ### <a name="getobjects_w"></a>getObjects(list, callback)
187
242
  Get all objects that are relevant for web: all states and enums with rooms
188
243
  * id *(string)*: object ID.
244
+ * list *(string[])*: optional list of IDs.
189
245
  * callback *(function)*: `function (error, obj)`
190
246
 
191
247
  ### <a name="subscribeobjects_w"></a>subscribeObjects(pattern, callback)
192
- Subscribe on object changes by pattern. The events will come as 'objectChange' events to the socket.
248
+ Subscribe to object changes by pattern. The events will come as 'objectChange' events to the socket.
193
249
  * pattern *(string)*: pattern like 'system.adapter.*' or array of IDs like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
194
250
  * callback *(function)*: `function (error)`
195
251
 
196
252
  ### <a name="unsubscribeobjects_w"></a>unsubscribeObjects(pattern, callback)
197
- Unsubscribe on object changes by pattern.
253
+ Unsubscribe from object changes by pattern.
198
254
  * pattern *(string)*: pattern like 'system.adapter.*' or array of IDs like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
199
255
  * callback *(function)*: `function (error)`
200
256
 
@@ -217,6 +273,19 @@ Delete object. Only deletion of flot objects is allowed
217
273
  * options *(string)*: ignored
218
274
  * callback *(function)*: `function (error)`
219
275
 
276
+ ### <a name="clientsubscribe_w"></a>clientSubscribe(targetInstance, messageType, data, callback)
277
+ Client informs specific instance about subscription on its messages. After subscription the socket will receive "im" messages from desired instance
278
+ * targetInstance *(string)*: instance name, e.g. "cameras.0"
279
+ * messageType *(string)*: message type, e.g. "startRecording/cam1"
280
+ * data *(object)*: optional data object, e.g. {width: 640, height: 480}
281
+ * callback *(function)*: `function (error, result)`, target instance MUST acknowledge the subscription and return some object as result
282
+
283
+ ### <a name="clientunsubscribe_w"></a>clientUnsubscribe(targetInstance, messageType, callback)
284
+ Client unsubscribes from specific instance's messages
285
+ * targetInstance *(string)*: instance name, e.g. "cameras.0"
286
+ * messageType *(string)*: message type, e.g. "startRecording/cam1"
287
+ * callback *(function)*: `function (error, wasSubscribed)`, target instance MUST NOT acknowledge the un-subscription
288
+
220
289
  ### <a name="getstates_w"></a>getStates(pattern, callback)
221
290
  Read states by pattern
222
291
  * pattern *(string)*: optional pattern, like `system.adapter.*` or array of state IDs
@@ -224,7 +293,7 @@ Read states by pattern
224
293
 
225
294
  ### <a name="getforeignstates_w"></a>getForeignStates(pattern, callback)
226
295
  Read all states (which might not belong to this adapter) which match the given pattern
227
- * pattern *(string)*: pattern like
296
+ * pattern *(string)*: pattern like `system.adapter.*` or array of state IDs
228
297
  * callback *(function)*: `function (error)`
229
298
 
230
299
  ### <a name="getstate_w"></a>getState(id, callback)
@@ -246,16 +315,16 @@ Read one binary state.
246
315
  ### <a name="setbinarystate_w"></a>setBinaryState(id, base64, callback)
247
316
  Write one binary state.
248
317
  * id *(string)*: State ID like, 'javascript.0.binary'
249
- * base64 *(string)*: State value as base64 string. Binary states has no acknowledge flag.
318
+ * base64 *(string)*: State value as base64 string. Binary states have no acknowledged flag.
250
319
  * callback *(function)*: `function (error)`
251
320
 
252
321
  ### <a name="subscribe_w"></a>subscribe(pattern, callback)
253
- Subscribe on state changes by pattern. The events will come as 'stateChange' events to the socket.
322
+ Subscribe to state changes by pattern. The events will come as 'stateChange' events to the socket.
254
323
  * pattern *(string)*: pattern like 'system.adapter.*' or array of states like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
255
324
  * callback *(function)*: `function (error)`
256
325
 
257
326
  ### <a name="subscribestates_w"></a>subscribeStates(pattern, callback)
258
- Subscribe on state changes by pattern. Same as `subscribe`. The events will come as 'stateChange' events to the socket.
327
+ Subscribe to state changes by pattern. Same as `subscribe`. The events will come as 'stateChange' events to the socket.
259
328
  * pattern *(string)*: pattern like 'system.adapter.*' or array of states like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
260
329
  * callback *(function)*: `function (error)`
261
330
 
@@ -272,19 +341,19 @@ Unsubscribe from state changes by pattern. Same as `unsubscribe`.
272
341
  ### <a name="readfile_w"></a>readFile(_adapter, fileName, callback)
273
342
  Read file from ioBroker DB
274
343
  * _adapter *(string)*: instance name, e.g. `vis.0`
275
- * fileName *(string)*: file name, e.g `main/vis-views.json`
344
+ * fileName *(string)*: file name, e.g. `main/vis-views.json`
276
345
  * callback *(function)*: `function (error, data, mimeType)`
277
346
 
278
347
  ### <a name="readfile64_w"></a>readFile64(_adapter, fileName, callback)
279
348
  Read file from ioBroker DB as base64 string
280
349
  * _adapter *(string)*: instance name, e.g. `vis.0`
281
- * fileName *(string)*: file name, e.g `main/vis-views.json`
350
+ * fileName *(string)*: file name, e.g. `main/vis-views.json`
282
351
  * callback *(function)*: `function (error, base64, mimeType)`
283
352
 
284
353
  ### <a name="writefile64_w"></a>writeFile64(_adapter, fileName, data64, options, callback)
285
354
  Write file into ioBroker DB as base64 string
286
355
  * _adapter *(string)*: instance name, e.g. `vis.0`
287
- * fileName *(string)*: file name, e.g `main/vis-views.json`
356
+ * fileName *(string)*: file name, e.g. `main/vis-views.json`
288
357
  * data64 *(string)*: file content as base64 string
289
358
  * options *(object)*: optional `{mode: 0x0644}`
290
359
  * callback *(function)*: `function (error)`
@@ -292,7 +361,7 @@ Write file into ioBroker DB as base64 string
292
361
  ### <a name="writefile_w"></a>writeFile(_adapter, fileName, data, options, callback)
293
362
  Write file into ioBroker DB as text **DEPRECATED**
294
363
  * _adapter *(string)*: instance name, e.g. `vis.0`
295
- * fileName *(string)*: file name, e.g `main/vis-views.json`
364
+ * fileName *(string)*: file name, e.g. `main/vis-views.json`
296
365
  * data64 *(string)*: file content as base64 string
297
366
  * options *(object)*: optional `{mode: 0x644}`
298
367
  * callback *(function)*: `function (error)`
@@ -300,83 +369,83 @@ Write file into ioBroker DB as text **DEPRECATED**
300
369
  ### <a name="unlink_w"></a>unlink(_adapter, name, callback)
301
370
  Delete file in ioBroker DB
302
371
  * _adapter *(string)*: instance name, e.g. `vis.0`
303
- * name *(string)*: file name, e.g `main/vis-views.json`
372
+ * name *(string)*: file name, e.g. `main/vis-views.json`
304
373
  * callback *(function)*: `function (error)`
305
374
 
306
375
  ### <a name="deletefile_w"></a>deleteFile(_adapter, name, callback)
307
376
  Delete file in ioBroker DB (same as unlink, but only for files)
308
377
  * _adapter *(string)*: instance name, e.g. `vis.0`
309
- * name *(string)*: file name, e.g `main/vis-views.json`
378
+ * name *(string)*: file name, e.g. `main/vis-views.json`
310
379
  * callback *(function)*: `function (error)`
311
380
 
312
381
  ### <a name="deletefolder_w"></a>deleteFolder(_adapter, name, callback)
313
382
  Delete file in ioBroker DB (same as unlink, but only for folders)
314
383
  * _adapter *(string)*: instance name, e.g. `vis.0`
315
- * name *(string)*: folder name, e.g `main`
384
+ * name *(string)*: folder name, e.g. `main`
316
385
  * callback *(function)*: `function (error)`
317
386
 
318
387
  ### <a name="renamefile_w"></a>renameFile(_adapter, oldName, newName, callback)
319
388
  Rename file in ioBroker DB
320
389
  * _adapter *(string)*: instance name, e.g. `vis.0`
321
- * oldName *(string)*: current file name, e.g `main/vis-views.json`
322
- * newName *(string)*: new file name, e.g `main/vis-views-new.json`
390
+ * oldName *(string)*: current file name, e.g. `main/vis-views.json`
391
+ * newName *(string)*: new file name, e.g. `main/vis-views-new.json`
323
392
  * callback *(function)*: `function (error)`
324
393
 
325
394
  ### <a name="rename_w"></a>rename(_adapter, oldName, newName, callback)
326
395
  Rename file or folder in ioBroker DB
327
396
  * _adapter *(string)*: instance name, e.g. `vis.0`
328
- * oldName *(string)*: current file name, e.g `main/vis-views.json`
329
- * newName *(string)*: new file name, e.g `main/vis-views-new.json`
397
+ * oldName *(string)*: current file name, e.g. `main/vis-views.json`
398
+ * newName *(string)*: new file name, e.g. `main/vis-views-new.json`
330
399
  * callback *(function)*: `function (error)`
331
400
 
332
401
  ### <a name="mkdir_w"></a>mkdir(_adapter, dirName, callback)
333
402
  Create folder in ioBroker DB
334
403
  * _adapter *(string)*: instance name, e.g. `vis.0`
335
- * dirName *(string)*: desired folder name, e.g `main`
404
+ * dirName *(string)*: desired folder name, e.g. `main`
336
405
  * callback *(function)*: `function (error)`
337
406
 
338
407
  ### <a name="readdir_w"></a>readDir(_adapter, dirName, options, callback)
339
408
  Read content of folder in ioBroker DB
340
409
  * _adapter *(string)*: instance name, e.g. `vis.0`
341
- * dirName *(string)*: folder name, e.g `main`
410
+ * dirName *(string)*: folder name, e.g. `main`
342
411
  * options *(object)*: optional `{filter: '*'}` or `{filter: '*.json'}`
343
412
  * 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}`
344
413
 
345
414
  ### <a name="chmodfile_w"></a>chmodFile(_adapter, fileName, options, callback)
346
415
  Change file mode in ioBroker DB
347
416
  * _adapter *(string)*: instance name, e.g. `vis.0`
348
- * fileName *(string)*: file name, e.g `main/vis-views.json`
349
- * 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`
417
+ * fileName *(string)*: file name, e.g. `main/vis-views.json`
418
+ * options *(object)*: `{mode: 0x644}` or 0x644. The first digit is user, second group, third others. Bit 1 is `execute`, bit 2 is `write`, bit 3 is `read`
350
419
  * callback *(function)*: `function (error)`
351
420
 
352
421
  ### <a name="chownfile_w"></a>chownFile(_adapter, fileName, options, callback)
353
422
  Change file owner in ioBroker DB
354
423
  * _adapter *(string)*: instance name, e.g. `vis.0`
355
- * fileName *(string)*: file name, e.g `main/vis-views.json`
424
+ * fileName *(string)*: file name, e.g. `main/vis-views.json`
356
425
  * 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.
357
426
  * callback *(function)*: `function (error)`
358
427
 
359
428
  ### <a name="fileexists_w"></a>fileExists(_adapter, fileName, callback)
360
- Checks if the file or folder exists in ioBroker DB
429
+ Check if the file or folder exists in ioBroker DB
361
430
  * _adapter *(string)*: instance name, e.g. `vis.0`
362
- * fileName *(string)*: file name, e.g `main/vis-views.json`
431
+ * fileName *(string)*: file name, e.g. `main/vis-views.json`
363
432
  * callback *(function)*: `function (error, isExist)`
364
433
 
365
434
  ### <a name="subscribefiles_w"></a>subscribeFiles(id, pattern, callback)
366
- Subscribe on file changes in ioBroker DB
435
+ Subscribe to file changes in ioBroker DB
367
436
  * 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`
437
+ * pattern *(string)*: file name pattern, e.g. `main/*.json`
369
438
  * callback *(function)*: `function (error)`
370
439
 
371
440
  ### <a name="unsubscribefiles_w"></a>unsubscribeFiles(id, pattern, callback)
372
- Unsubscribe on file changes in ioBroker DB
441
+ Unsubscribe from file changes in ioBroker DB
373
442
  * id *(string)*: instance name, e.g. `vis.0` or any object ID of type `meta`. `id` could have wildcards `*` too.
374
- * pattern *(string)*: file name pattern, e.g `main/*.json`
443
+ * pattern *(string)*: file name pattern, e.g. `main/*.json`
375
444
  * callback *(function)*: `function (error)`
376
445
 
377
446
  ### <a name="getadapterinstances_w"></a>getAdapterInstances(adapterName, callback)
378
447
  Read all instances of the given adapter, or all instances of all adapters if adapterName is not defined
379
- * adapterName *(string)*: optional adapter name, e.g `history`.
448
+ * adapterName *(string)*: optional adapter name, e.g. `history`.
380
449
  * callback *(function)*: `function (error, instanceList)`, where instanceList is an array of instance objects, e.g. `{_id: 'system.adapter.history.0', common: {name: 'history', ...}, native: {...}}`
381
450
 
382
451
  <!-- WEB_METHODS_END -->
@@ -431,6 +500,8 @@ Read all instances of the given adapter, or all instances of all adapters if ada
431
500
  * [getObjectView](#getobjectview_a)
432
501
  * [setObject](#setobject_a)
433
502
  * [delObject](#delobject_a)
503
+ * [clientSubscribe](#clientsubscribe_a)
504
+ * [clientUnsubscribe](#clientunsubscribe_a)
434
505
  * [getAllObjects](#getallobjects_a)
435
506
  * [extendObject](#extendobject_a)
436
507
  * [getForeignObjects](#getforeignobjects_a)
@@ -489,22 +560,22 @@ Read content of HTTP(S) page server-side (without CORS and stuff)
489
560
  * callback *(function)*: `function (error, {status, statusText}, body)`
490
561
 
491
562
  ### <a name="sendto_a"></a>sendTo(adapterInstance, command, message, callback)
492
- Send message to specific instance
563
+ Send the message to specific instance
493
564
  * adapterInstance *(string)*: instance name, e.g. `history.0`
494
565
  * command *(string)*: command name
495
- * message *(object)*: message is instance dependent
566
+ * message *(object)*: the message is instance dependent
496
567
  * callback *(function)*: `function (result)`
497
568
 
498
569
  ### <a name="sendtohost_a"></a>sendToHost(host, command, message, callback)
499
- Send message to specific host.
500
- Host can answer following commands: `cmdExec, getRepository, getInstalled, getInstalledAdapter, getVersion, getDiagData, getLocationOnDisk, getDevList, getLogs, getHostInfo, delLogs, readDirAsZip, writeDirAsZip, readObjectsAsZip, writeObjectsAsZip, checkLogging, updateMultihost`.
570
+ Send a message to the specific host.
571
+ Host can answer to the following commands: `cmdExec, getRepository, getInstalled, getInstalledAdapter, getVersion, getDiagData, getLocationOnDisk, getDevList, getLogs, getHostInfo, delLogs, readDirAsZip, writeDirAsZip, readObjectsAsZip, writeObjectsAsZip, checkLogging, updateMultihost`.
501
572
  * host *(string)*: instance name, e.g. `history.0`
502
573
  * command *(string)*: command name
503
- * message *(object)*: message is command specific
574
+ * message *(object)*: the message is command-specific
504
575
  * callback *(function)*: `function (result)`
505
576
 
506
577
  ### <a name="authenabled_a"></a>authEnabled(callback)
507
- Ask server is authentication enabled and if the user authenticated
578
+ Ask server is authentication enabled, and if the user authenticated
508
579
  * callback *(function)*: `function (isAuthenticationUsed, userName)`
509
580
 
510
581
  ### <a name="logout_a"></a>logout(callback)
@@ -520,7 +591,7 @@ Get user permissions
520
591
  * callback *(function)*: `function (error, permissions)`
521
592
 
522
593
  ### <a name="getversion_a"></a>getVersion(callback)
523
- Get adapter version. Not the socket-classes version!
594
+ Get the adapter version. Not the socket-classes version!
524
595
  * callback *(function)*: `function (error, adapterVersion, adapterName)`
525
596
 
526
597
  ### <a name="getadaptername_a"></a>getAdapterName(callback)
@@ -528,9 +599,9 @@ Get adapter name. Not the socket-classes version!
528
599
  * callback *(function)*: `function (error, adapterVersion)`
529
600
 
530
601
  ### <a name="gethostbyip_a"></a>getHostByIp(ip, callback)
531
- Read host object by IP address
602
+ Read the host object by IP address
532
603
  * ip *(string)*: ip address. IPv4 or IPv6
533
- * callback *(function)*: `function (ip, obj)`. If host not found, obj is null
604
+ * callback *(function)*: `function (ip, obj)`. If host is not found, obj is null
534
605
 
535
606
  ### <a name="requirelog_a"></a>requireLog(isEnabled, callback)
536
607
  Activate or deactivate logging events. Events will be sent to the socket as `log` event. Adapter must have `common.logTransporter = true`
@@ -543,19 +614,19 @@ Get logs file from given host
543
614
  * callback *(function)*: `function (error, files)`, where `files` is array of `{fileName: `log/hostname/transport/file`, size: 123}`
544
615
 
545
616
  ### <a name="delstate_a"></a>delState(id, callback)
546
- Delete state. Corresponding object will be deleted too.
617
+ Delete state. The corresponding object will be deleted too.
547
618
  * id *(string)*: state ID
548
619
  * callback *(function)*: `function (error)`
549
620
 
550
621
  ### <a name="cmdexec_a"></a>cmdExec(host, id, cmd, callback)
551
- Execute shell command on host/controller. Following response commands are expected: ´cmdStdout, cmdStderr, cmdExit´
622
+ Execute the shell command on host/controller. Following response commands are expected: ´cmdStdout, cmdStderr, cmdExit´
552
623
  * host *(string)*: host name, like 'system.host.raspberrypi'
553
624
  * id *(string)*: session ID, like `Date.now()´. This session ID will come in events `cmdStdout, cmdStderr, cmdExit`
554
625
  * cmd *(string)*: command
555
626
  * callback *(function)*: `function (error)`
556
627
 
557
628
  ### <a name="eventsthreshold_a"></a>eventsThreshold(isActive)
558
- Used only for admin to limit number of events to front-end.
629
+ Used only for admin to the limited number of events to front-end.
559
630
  * isActive *(boolean)*: if true, then events will be limited
560
631
 
561
632
  ### <a name="getratings_a"></a>getRatings(update, callback)
@@ -568,17 +639,17 @@ Return current instance name like `admin.0`
568
639
  * callback *(function)*: `function (error, namespace)`
569
640
 
570
641
  ### <a name="checkfeaturesupported_a"></a>checkFeatureSupported(feature, callback)
571
- Checks if same feature is supported by current js-controller
642
+ Checks, if the same feature is supported by the current js-controller
572
643
  * feature *(string)*: feature name like `CONTROLLER_LICENSE_MANAGER`
573
644
  * callback *(function)*: `function (error, isSupported)`
574
645
 
575
646
  ### <a name="decrypt_a"></a>decrypt(encryptedText, callback)
576
- Decrypts text with system secret key
647
+ Decrypts text with the system secret key
577
648
  * encryptedText *(string)*: encrypted text
578
649
  * callback *(function)*: `function (error, decryptedText)`
579
650
 
580
651
  ### <a name="encrypt_a"></a>encrypt(plainText, callback)
581
- Encrypts text with system secret key
652
+ Encrypts text with the system secret key
582
653
  * plainText *(string)*: normal text
583
654
  * callback *(function)*: `function (error, encryptedText)`
584
655
 
@@ -641,14 +712,14 @@ Delete existing user. Admin cannot be deleted.
641
712
  * callback *(function)*: `function (error)`
642
713
 
643
714
  ### <a name="addgroup_a"></a>addGroup(group, desc, acl, callback)
644
- Add new group.
715
+ Add a new group.
645
716
  * group *(string)*: user name, like 'benjamin
646
717
  * desc *(string)*: optional description
647
718
  * 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}}`
648
719
  * callback *(function)*: `function (error)`
649
720
 
650
721
  ### <a name="delgroup_a"></a>delGroup(group, callback)
651
- Delete existing group. Administrator group cannot be deleted.
722
+ Delete the existing group. Administrator group cannot be deleted.
652
723
  * group *(string)*: group name, like 'users`
653
724
  * callback *(function)*: `function (error)`
654
725
 
@@ -668,12 +739,12 @@ Read absolutely all objects. Same as `getAllObjects`.
668
739
  * callback *(function)*: `function (error, objects)`, where `objects` is an object like `{'system.adapter.admin.0': {...}, 'system.adapter.web.0': {...}}`
669
740
 
670
741
  ### <a name="subscribeobjects_a"></a>subscribeObjects(pattern, callback)
671
- Subscribe on object changes by pattern. The events will come as 'objectChange' events to the socket.
742
+ Subscribe to object changes by pattern. The events will come as 'objectChange' events to the socket.
672
743
  * pattern *(string)*: pattern like 'system.adapter.*' or array of IDs like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
673
744
  * callback *(function)*: `function (error)`
674
745
 
675
746
  ### <a name="unsubscribeobjects_a"></a>unsubscribeObjects(pattern, callback)
676
- Unsubscribe on object changes by pattern.
747
+ Unsubscribe from object changes by pattern.
677
748
  * pattern *(string)*: pattern like 'system.adapter.*' or array of IDs like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
678
749
  * callback *(function)*: `function (error)`
679
750
 
@@ -691,17 +762,30 @@ Set object.
691
762
  * callback *(function)*: `function (error)`
692
763
 
693
764
  ### <a name="delobject_a"></a>delObject(id, options, callback)
694
- Delete object or objects recursively. Objects with `dontDelete` cannot be deleted.
765
+ Delete an object or objects recursively. Objects with `dontDelete` cannot be deleted.
695
766
  * id *(string)*: Object ID like, 'adapterName.0.channel'
696
767
  * options *(string)*: `{recursive: true}`
697
768
  * callback *(function)*: `function (error)`
698
769
 
770
+ ### <a name="clientsubscribe_a"></a>clientSubscribe(targetInstance, messageType, data, callback)
771
+ Client informs specific instance about subscription on its messages. After subscription the socket will receive "im" messages from desired instance
772
+ * targetInstance *(string)*: instance name, e.g. "cameras.0"
773
+ * messageType *(string)*: message type, e.g. "startRecording/cam1"
774
+ * data *(object)*: optional data object, e.g. {width: 640, height: 480}
775
+ * callback *(function)*: `function (error, result)`, target instance MUST acknowledge the subscription and return some object as result
776
+
777
+ ### <a name="clientunsubscribe_a"></a>clientUnsubscribe(targetInstance, messageType, callback)
778
+ Client unsubscribes from specific instance's messages
779
+ * targetInstance *(string)*: instance name, e.g. "cameras.0"
780
+ * messageType *(string)*: message type, e.g. "startRecording/cam1"
781
+ * callback *(function)*: `function (error, wasSubscribed)`, target instance MUST NOT acknowledge the un-subscription
782
+
699
783
  ### <a name="getallobjects_a"></a>getAllObjects(callback)
700
784
  Read absolutely all objects
701
785
  * callback *(function)*: `function (error, objects)`, where `objects` is an object like `{'system.adapter.admin.0': {...}, 'system.adapter.web.0': {...}}`
702
786
 
703
787
  ### <a name="extendobject_a"></a>extendObject(id, obj, callback)
704
- Extend existing object
788
+ Extend the existing object
705
789
  * id *(string)*: object ID
706
790
  * obj *(object)*: new parts of the object, like `{common: {name: 'new name'}}`
707
791
  * callback *(function)*: `function (error)`
@@ -725,7 +809,7 @@ Read states by pattern
725
809
 
726
810
  ### <a name="getforeignstates_a"></a>getForeignStates(pattern, callback)
727
811
  Read all states (which might not belong to this adapter) which match the given pattern
728
- * pattern *(string)*: pattern like
812
+ * pattern *(string)*: pattern like `system.adapter.*` or array of state IDs
729
813
  * callback *(function)*: `function (error)`
730
814
 
731
815
  ### <a name="getstate_a"></a>getState(id, callback)
@@ -747,16 +831,16 @@ Read one binary state.
747
831
  ### <a name="setbinarystate_a"></a>setBinaryState(id, base64, callback)
748
832
  Write one binary state.
749
833
  * id *(string)*: State ID like, 'javascript.0.binary'
750
- * base64 *(string)*: State value as base64 string. Binary states has no acknowledge flag.
834
+ * base64 *(string)*: State value as base64 string. Binary states have no acknowledged flag.
751
835
  * callback *(function)*: `function (error)`
752
836
 
753
837
  ### <a name="subscribe_a"></a>subscribe(pattern, callback)
754
- Subscribe on state changes by pattern. The events will come as 'stateChange' events to the socket.
838
+ Subscribe to state changes by pattern. The events will come as 'stateChange' events to the socket.
755
839
  * pattern *(string)*: pattern like 'system.adapter.*' or array of states like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
756
840
  * callback *(function)*: `function (error)`
757
841
 
758
842
  ### <a name="subscribestates_a"></a>subscribeStates(pattern, callback)
759
- Subscribe on state changes by pattern. Same as `subscribe`. The events will come as 'stateChange' events to the socket.
843
+ Subscribe to state changes by pattern. Same as `subscribe`. The events will come as 'stateChange' events to the socket.
760
844
  * pattern *(string)*: pattern like 'system.adapter.*' or array of states like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
761
845
  * callback *(function)*: `function (error)`
762
846
 
@@ -773,19 +857,19 @@ Unsubscribe from state changes by pattern. Same as `unsubscribe`.
773
857
  ### <a name="readfile_a"></a>readFile(_adapter, fileName, callback)
774
858
  Read file from ioBroker DB
775
859
  * _adapter *(string)*: instance name, e.g. `vis.0`
776
- * fileName *(string)*: file name, e.g `main/vis-views.json`
860
+ * fileName *(string)*: file name, e.g. `main/vis-views.json`
777
861
  * callback *(function)*: `function (error, data, mimeType)`
778
862
 
779
863
  ### <a name="readfile64_a"></a>readFile64(_adapter, fileName, callback)
780
864
  Read file from ioBroker DB as base64 string
781
865
  * _adapter *(string)*: instance name, e.g. `vis.0`
782
- * fileName *(string)*: file name, e.g `main/vis-views.json`
866
+ * fileName *(string)*: file name, e.g. `main/vis-views.json`
783
867
  * callback *(function)*: `function (error, base64, mimeType)`
784
868
 
785
869
  ### <a name="writefile64_a"></a>writeFile64(_adapter, fileName, data64, options, callback)
786
870
  Write file into ioBroker DB as base64 string
787
871
  * _adapter *(string)*: instance name, e.g. `vis.0`
788
- * fileName *(string)*: file name, e.g `main/vis-views.json`
872
+ * fileName *(string)*: file name, e.g. `main/vis-views.json`
789
873
  * data64 *(string)*: file content as base64 string
790
874
  * options *(object)*: optional `{mode: 0x0644}`
791
875
  * callback *(function)*: `function (error)`
@@ -801,83 +885,83 @@ Write file into ioBroker DB as base64 string
801
885
  ### <a name="unlink_a"></a>unlink(_adapter, name, callback)
802
886
  Delete file in ioBroker DB
803
887
  * _adapter *(string)*: instance name, e.g. `vis.0`
804
- * name *(string)*: file name, e.g `main/vis-views.json`
888
+ * name *(string)*: file name, e.g. `main/vis-views.json`
805
889
  * callback *(function)*: `function (error)`
806
890
 
807
891
  ### <a name="deletefile_a"></a>deleteFile(_adapter, name, callback)
808
892
  Delete file in ioBroker DB (same as unlink, but only for files)
809
893
  * _adapter *(string)*: instance name, e.g. `vis.0`
810
- * name *(string)*: file name, e.g `main/vis-views.json`
894
+ * name *(string)*: file name, e.g. `main/vis-views.json`
811
895
  * callback *(function)*: `function (error)`
812
896
 
813
897
  ### <a name="deletefolder_a"></a>deleteFolder(_adapter, name, callback)
814
898
  Delete file in ioBroker DB (same as unlink, but only for folders)
815
899
  * _adapter *(string)*: instance name, e.g. `vis.0`
816
- * name *(string)*: folder name, e.g `main`
900
+ * name *(string)*: folder name, e.g. `main`
817
901
  * callback *(function)*: `function (error)`
818
902
 
819
903
  ### <a name="renamefile_a"></a>renameFile(_adapter, oldName, newName, callback)
820
904
  Rename file in ioBroker DB
821
905
  * _adapter *(string)*: instance name, e.g. `vis.0`
822
- * oldName *(string)*: current file name, e.g `main/vis-views.json`
823
- * newName *(string)*: new file name, e.g `main/vis-views-new.json`
906
+ * oldName *(string)*: current file name, e.g. `main/vis-views.json`
907
+ * newName *(string)*: new file name, e.g. `main/vis-views-new.json`
824
908
  * callback *(function)*: `function (error)`
825
909
 
826
910
  ### <a name="rename_a"></a>rename(_adapter, oldName, newName, callback)
827
911
  Rename file or folder in ioBroker DB
828
912
  * _adapter *(string)*: instance name, e.g. `vis.0`
829
- * oldName *(string)*: current file name, e.g `main/vis-views.json`
830
- * newName *(string)*: new file name, e.g `main/vis-views-new.json`
913
+ * oldName *(string)*: current file name, e.g. `main/vis-views.json`
914
+ * newName *(string)*: new file name, e.g. `main/vis-views-new.json`
831
915
  * callback *(function)*: `function (error)`
832
916
 
833
917
  ### <a name="mkdir_a"></a>mkdir(_adapter, dirName, callback)
834
918
  Create folder in ioBroker DB
835
919
  * _adapter *(string)*: instance name, e.g. `vis.0`
836
- * dirName *(string)*: desired folder name, e.g `main`
920
+ * dirName *(string)*: desired folder name, e.g. `main`
837
921
  * callback *(function)*: `function (error)`
838
922
 
839
923
  ### <a name="readdir_a"></a>readDir(_adapter, dirName, options, callback)
840
924
  Read content of folder in ioBroker DB
841
925
  * _adapter *(string)*: instance name, e.g. `vis.0`
842
- * dirName *(string)*: folder name, e.g `main`
926
+ * dirName *(string)*: folder name, e.g. `main`
843
927
  * options *(object)*: optional `{filter: '*'}` or `{filter: '*.json'}`
844
928
  * 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}`
845
929
 
846
930
  ### <a name="chmodfile_a"></a>chmodFile(_adapter, fileName, options, callback)
847
931
  Change file mode in ioBroker DB
848
932
  * _adapter *(string)*: instance name, e.g. `vis.0`
849
- * fileName *(string)*: file name, e.g `main/vis-views.json`
850
- * 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`
933
+ * fileName *(string)*: file name, e.g. `main/vis-views.json`
934
+ * options *(object)*: `{mode: 0x644}` or 0x644. The first digit is user, second group, third others. Bit 1 is `execute`, bit 2 is `write`, bit 3 is `read`
851
935
  * callback *(function)*: `function (error)`
852
936
 
853
937
  ### <a name="chownfile_a"></a>chownFile(_adapter, fileName, options, callback)
854
938
  Change file owner in ioBroker DB
855
939
  * _adapter *(string)*: instance name, e.g. `vis.0`
856
- * fileName *(string)*: file name, e.g `main/vis-views.json`
940
+ * fileName *(string)*: file name, e.g. `main/vis-views.json`
857
941
  * 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.
858
942
  * callback *(function)*: `function (error)`
859
943
 
860
944
  ### <a name="fileexists_a"></a>fileExists(_adapter, fileName, callback)
861
- Checks if the file or folder exists in ioBroker DB
945
+ Check if the file or folder exists in ioBroker DB
862
946
  * _adapter *(string)*: instance name, e.g. `vis.0`
863
- * fileName *(string)*: file name, e.g `main/vis-views.json`
947
+ * fileName *(string)*: file name, e.g. `main/vis-views.json`
864
948
  * callback *(function)*: `function (error, isExist)`
865
949
 
866
950
  ### <a name="subscribefiles_a"></a>subscribeFiles(id, pattern, callback)
867
- Subscribe on file changes in ioBroker DB
951
+ Subscribe to file changes in ioBroker DB
868
952
  * id *(string)*: instance name, e.g. `vis.0` or any object ID of type `meta`. `id` could have wildcards `*` too.
869
- * pattern *(string)*: file name pattern, e.g `main/*.json`
953
+ * pattern *(string)*: file name pattern, e.g. `main/*.json`
870
954
  * callback *(function)*: `function (error)`
871
955
 
872
956
  ### <a name="unsubscribefiles_a"></a>unsubscribeFiles(id, pattern, callback)
873
- Unsubscribe on file changes in ioBroker DB
957
+ Unsubscribe from file changes in ioBroker DB
874
958
  * id *(string)*: instance name, e.g. `vis.0` or any object ID of type `meta`. `id` could have wildcards `*` too.
875
- * pattern *(string)*: file name pattern, e.g `main/*.json`
959
+ * pattern *(string)*: file name pattern, e.g. `main/*.json`
876
960
  * callback *(function)*: `function (error)`
877
961
 
878
962
  ### <a name="getadapterinstances_a"></a>getAdapterInstances(adapterName, callback)
879
963
  Read all instances of the given adapter, or all instances of all adapters if adapterName is not defined
880
- * adapterName *(string)*: optional adapter name, e.g `history`.
964
+ * adapterName *(string)*: optional adapter name, e.g. `history`.
881
965
  * callback *(function)*: `function (error, instanceList)`, where instanceList is an array of instance objects, e.g. `{_id: 'system.adapter.history.0', common: {name: 'history', ...}, native: {...}}`
882
966
 
883
967
  <!-- ADMIN_METHODS_END -->
@@ -888,6 +972,13 @@ Read all instances of the given adapter, or all instances of all adapters if ada
888
972
  -->
889
973
 
890
974
  ## Changelog
975
+ ### 1.3.1 (2023-07-31)
976
+ * (bluefox) Implemented subscribes of a client on messages from specific instance
977
+
978
+ ### 1.2.0 (2023-07-07)
979
+ * (foxriver76) fixed crash on invalid patterns with js-controller version 5
980
+ * (bluefox) extended the getObjects function with the possibility to read the list of IDs
981
+
891
982
  ### 1.1.5 (2023-03-13)
892
983
  * (bluefox) Added command `name`
893
984