iobroker.zigbee 1.7.6 → 1.8.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/LICENSE +21 -21
- package/README.md +368 -381
- package/admin/admin.js +2951 -2927
- package/admin/i18n/de/translations.json +108 -0
- package/admin/i18n/en/translations.json +108 -0
- package/admin/i18n/es/translations.json +102 -0
- package/admin/i18n/fr/translations.json +108 -0
- package/admin/i18n/it/translations.json +102 -0
- package/admin/i18n/nl/translations.json +108 -0
- package/admin/i18n/pl/translations.json +108 -0
- package/admin/i18n/pt/translations.json +102 -0
- package/admin/i18n/ru/translations.json +108 -0
- package/admin/i18n/uk/translations.json +108 -0
- package/admin/i18n/zh-cn/translations.json +102 -0
- package/admin/img/philips_hue_lom001.png +0 -0
- package/admin/index.html +159 -159
- package/admin/index_m.html +1161 -1161
- package/admin/moment.min.js +1 -1
- package/admin/shuffle.min.js +2 -2
- package/admin/tab_m.html +985 -944
- package/admin/vis-network.min.css +1 -1
- package/admin/vis-network.min.js +27 -27
- package/admin/words.js +110 -110
- package/docs/de/img/CC2531.png +0 -0
- package/docs/de/img/CC2538_CC2592_PA.PNG +0 -0
- package/docs/de/img/CC2591.png +0 -0
- package/docs/de/img/boards.jpg +0 -0
- package/docs/de/img/cc26x2r.PNG +0 -0
- package/docs/de/img/results.jpg +0 -0
- package/docs/de/img/sku_429478_2.png +0 -0
- package/docs/de/img/sku_429601_2.png +0 -0
- package/docs/de/readme.md +27 -0
- package/docs/en/img/CC2531.png +0 -0
- package/docs/en/img/CC2591.png +0 -0
- package/docs/en/img/deconz.png +0 -0
- package/docs/en/img/sku_429478_2.png +0 -0
- package/docs/en/img/sku_429601_2.png +0 -0
- package/docs/en/readme.md +30 -0
- package/docs/flashing_via_arduino_(en).md +110 -0
- package/docs/ru/img/CC2531.png +0 -0
- package/docs/ru/img/CC2591.png +0 -0
- package/docs/ru/img/sku_429478_2.png +0 -0
- package/docs/ru/img/sku_429601_2.png +0 -0
- package/docs/ru/readme.md +28 -0
- package/docs/tutorial/CC2530_20190425.zip +0 -0
- package/docs/tutorial/CC2530_CC2591_20190515.zip +0 -0
- package/docs/tutorial/CC2530_CC2592_20190515.zip +0 -0
- package/docs/tutorial/CC2531_20190425.zip +0 -0
- package/docs/tutorial/adm5_1.PNG +0 -0
- package/docs/tutorial/adm5_2.PNG +0 -0
- package/docs/tutorial/cat.PNG +0 -0
- package/docs/tutorial/groups-1.png +0 -0
- package/docs/tutorial/groups-2.png +0 -0
- package/docs/tutorial/inst.PNG +0 -0
- package/docs/tutorial/reflash-finish.PNG +0 -0
- package/docs/tutorial/reflash-step0.png +0 -0
- package/docs/tutorial/reflash-step1.PNG +0 -0
- package/docs/tutorial/reflash-step2.PNG +0 -0
- package/docs/tutorial/settings.png +0 -0
- package/docs/tutorial/tab-dev-1.png +0 -0
- package/docs/tutorial/zigbee.png +0 -0
- package/docs/tutorial/zigbee15.png +0 -0
- package/io-package.json +335 -370
- package/lib/backup.js +171 -171
- package/lib/binding.js +320 -325
- package/lib/colors.js +465 -460
- package/lib/commands.js +510 -501
- package/lib/developer.js +145 -148
- package/lib/devices.js +3135 -3145
- package/lib/exclude.js +162 -168
- package/lib/exposes.js +828 -804
- package/lib/groups.js +340 -342
- package/lib/json.js +59 -60
- package/lib/networkmap.js +55 -56
- package/lib/ota.js +195 -179
- package/lib/rgb.js +297 -255
- package/lib/seriallist.js +48 -37
- package/lib/states.js +6405 -6416
- package/lib/statescontroller.js +693 -670
- package/lib/tools.js +54 -54
- package/lib/utils.js +152 -151
- package/lib/zbBaseExtension.js +36 -36
- package/lib/zbDelayedAction.js +144 -152
- package/lib/zbDeviceAvailability.js +319 -315
- package/lib/zbDeviceConfigure.js +147 -159
- package/lib/zbDeviceEvent.js +48 -49
- package/lib/zigbeecontroller.js +957 -951
- package/main.js +163 -147
- package/package.json +33 -19
- package/support/docgen.js +93 -93
- package/.eslintignore +0 -2
- package/.eslintrc.json +0 -37
- package/.github/FUNDING.yml +0 -3
- package/.github/stale.yml +0 -13
- package/.github/workflows/test-and-release.yml +0 -151
- package/.travis/wiki.sh +0 -28
- package/admin/adapter-settings.js +0 -244
package/lib/commands.js
CHANGED
|
@@ -1,501 +1,510 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const getZbId = require('./utils').getZbId;
|
|
4
|
-
const statesMapping = require('./devices');
|
|
5
|
-
const disallowedDashStates = [
|
|
6
|
-
'link_quality', 'available', 'battery', 'groups', 'device_query',
|
|
7
|
-
'hue_move', 'color_temp_move', 'satuation_move', 'brightness_move', 'brightness_step', 'hue_calibration',
|
|
8
|
-
'msg_from_zigbee','send_payload'
|
|
9
|
-
];
|
|
10
|
-
|
|
11
|
-
class Commands {
|
|
12
|
-
constructor(adapter) {
|
|
13
|
-
this.adapter = adapter;
|
|
14
|
-
this.adapter.on('message', this.onMessage.bind(this));
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
start(zbController, stController) {
|
|
18
|
-
this.zbController = zbController;
|
|
19
|
-
this.stController = stController;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
stop() {
|
|
23
|
-
delete this.zbController;
|
|
24
|
-
delete this.stController;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
info(msg) {
|
|
28
|
-
this.adapter.log.info(msg);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
error(msg) {
|
|
32
|
-
this.adapter.log.error(msg);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
debug(msg) {
|
|
36
|
-
this.adapter.log.debug(msg);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
warn(msg) {
|
|
40
|
-
this.adapter.log.warn(msg);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @param {ioBroker.Message} obj
|
|
45
|
-
*/
|
|
46
|
-
onMessage(obj) {
|
|
47
|
-
if (typeof obj === 'object' && obj.command) {
|
|
48
|
-
switch (obj.command) {
|
|
49
|
-
case 'letsPairing':
|
|
50
|
-
if (obj && obj.message && typeof obj.message === 'object') {
|
|
51
|
-
this.letsPairing(obj.from, obj.command, obj.message, obj.callback);
|
|
52
|
-
}
|
|
53
|
-
break;
|
|
54
|
-
case 'touchlinkReset':
|
|
55
|
-
if (obj && obj.message && typeof obj.message === 'object') {
|
|
56
|
-
this.touchlinkReset(obj.from, obj.command, obj.message, obj.callback);
|
|
57
|
-
}
|
|
58
|
-
break;
|
|
59
|
-
case 'getDevices':
|
|
60
|
-
if (obj && obj.message && typeof obj.message === 'object') {
|
|
61
|
-
this.getDevices(obj.from, obj.command, null, obj.callback);
|
|
62
|
-
}
|
|
63
|
-
break;
|
|
64
|
-
case 'renameDevice':
|
|
65
|
-
if (obj && obj.message && typeof obj.message === 'object') {
|
|
66
|
-
this.renameDevice(obj.from, obj.command, obj.message, obj.callback);
|
|
67
|
-
}
|
|
68
|
-
break;
|
|
69
|
-
case 'deleteDevice':
|
|
70
|
-
if (obj && obj.message && typeof obj.message === 'object') {
|
|
71
|
-
this.deleteDevice(obj.from, obj.command, obj.message, obj.callback);
|
|
72
|
-
}
|
|
73
|
-
break;
|
|
74
|
-
case 'getChannels':
|
|
75
|
-
if (obj && obj.message && typeof obj.message === 'object') {
|
|
76
|
-
this.getChannels(obj.from, obj.command, obj.message, obj.callback);
|
|
77
|
-
}
|
|
78
|
-
break;
|
|
79
|
-
case 'getCoordinatorInfo':
|
|
80
|
-
if (obj && obj.message && typeof obj.message === 'object') {
|
|
81
|
-
this.getCoordinatorInfo(obj.from, obj.command, obj.callback);
|
|
82
|
-
}
|
|
83
|
-
break;
|
|
84
|
-
case 'cleanDeviceStates':
|
|
85
|
-
if (obj && obj.message && typeof obj.message === 'object') {
|
|
86
|
-
this.cleanDeviceStates(obj.from, obj.command, obj.message, obj.callback);
|
|
87
|
-
}
|
|
88
|
-
break;
|
|
89
|
-
case 'setState':
|
|
90
|
-
if (obj && obj.message && typeof obj.message === 'object' && obj.message.id) {
|
|
91
|
-
// this.adapter.setState(obj.message.id, obj.message.val, false, obj.callback);
|
|
92
|
-
this.stController.setState_typed(obj.message.id, obj.message.val, false, undefined, obj.callback);
|
|
93
|
-
}
|
|
94
|
-
break;
|
|
95
|
-
case 'getDevice':
|
|
96
|
-
if (obj && obj.message && typeof obj.message === 'object' && obj.message.id) {
|
|
97
|
-
this.getDevices(obj.from, obj.command, obj.message.id, obj.callback);
|
|
98
|
-
}
|
|
99
|
-
break;
|
|
100
|
-
case 'reconfigure':
|
|
101
|
-
if (obj && obj.message && typeof obj.message === 'object') {
|
|
102
|
-
this.reconfigure(obj.from, obj.command, obj.message, obj.callback);
|
|
103
|
-
}
|
|
104
|
-
break;
|
|
105
|
-
case 'setDeviceActivated':
|
|
106
|
-
if (obj && obj.message && typeof obj.message === 'object') {
|
|
107
|
-
this.setDeviceActivated(obj.from, obj.command, obj.message, obj.callback);
|
|
108
|
-
}
|
|
109
|
-
break;
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
this.
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
.then(() =>
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
//
|
|
189
|
-
//
|
|
190
|
-
//
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
const
|
|
195
|
-
devInfo.
|
|
196
|
-
devInfo.
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
{
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
const
|
|
309
|
-
if (!
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
if (meta.hasOwnProperty('
|
|
376
|
-
|
|
377
|
-
else
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
if (meta.hasOwnProperty('
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
const
|
|
414
|
-
const
|
|
415
|
-
this.
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
this.
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
this.
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
const
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const getZbId = require('./utils').getZbId;
|
|
4
|
+
const statesMapping = require('./devices');
|
|
5
|
+
const disallowedDashStates = [
|
|
6
|
+
'link_quality', 'available', 'battery', 'groups', 'device_query',
|
|
7
|
+
'hue_move', 'color_temp_move', 'satuation_move', 'brightness_move', 'brightness_step', 'hue_calibration',
|
|
8
|
+
'msg_from_zigbee', 'send_payload',
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
class Commands {
|
|
12
|
+
constructor(adapter) {
|
|
13
|
+
this.adapter = adapter;
|
|
14
|
+
this.adapter.on('message', this.onMessage.bind(this));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
start(zbController, stController) {
|
|
18
|
+
this.zbController = zbController;
|
|
19
|
+
this.stController = stController;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
stop() {
|
|
23
|
+
delete this.zbController;
|
|
24
|
+
delete this.stController;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
info(msg) {
|
|
28
|
+
this.adapter.log.info(msg);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
error(msg) {
|
|
32
|
+
this.adapter.log.error(msg);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
debug(msg) {
|
|
36
|
+
this.adapter.log.debug(msg);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
warn(msg) {
|
|
40
|
+
this.adapter.log.warn(msg);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param {ioBroker.Message} obj
|
|
45
|
+
*/
|
|
46
|
+
onMessage(obj) {
|
|
47
|
+
if (typeof obj === 'object' && obj.command) {
|
|
48
|
+
switch (obj.command) {
|
|
49
|
+
case 'letsPairing':
|
|
50
|
+
if (obj && obj.message && typeof obj.message === 'object') {
|
|
51
|
+
this.letsPairing(obj.from, obj.command, obj.message, obj.callback);
|
|
52
|
+
}
|
|
53
|
+
break;
|
|
54
|
+
case 'touchlinkReset':
|
|
55
|
+
if (obj && obj.message && typeof obj.message === 'object') {
|
|
56
|
+
this.touchlinkReset(obj.from, obj.command, obj.message, obj.callback);
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
case 'getDevices':
|
|
60
|
+
if (obj && obj.message && typeof obj.message === 'object') {
|
|
61
|
+
this.getDevices(obj.from, obj.command, null, obj.callback);
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
case 'renameDevice':
|
|
65
|
+
if (obj && obj.message && typeof obj.message === 'object') {
|
|
66
|
+
this.renameDevice(obj.from, obj.command, obj.message, obj.callback);
|
|
67
|
+
}
|
|
68
|
+
break;
|
|
69
|
+
case 'deleteDevice':
|
|
70
|
+
if (obj && obj.message && typeof obj.message === 'object') {
|
|
71
|
+
this.deleteDevice(obj.from, obj.command, obj.message, obj.callback);
|
|
72
|
+
}
|
|
73
|
+
break;
|
|
74
|
+
case 'getChannels':
|
|
75
|
+
if (obj && obj.message && typeof obj.message === 'object') {
|
|
76
|
+
this.getChannels(obj.from, obj.command, obj.message, obj.callback);
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
case 'getCoordinatorInfo':
|
|
80
|
+
if (obj && obj.message && typeof obj.message === 'object') {
|
|
81
|
+
this.getCoordinatorInfo(obj.from, obj.command, obj.callback);
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
84
|
+
case 'cleanDeviceStates':
|
|
85
|
+
if (obj && obj.message && typeof obj.message === 'object') {
|
|
86
|
+
this.cleanDeviceStates(obj.from, obj.command, obj.message, obj.callback);
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
case 'setState':
|
|
90
|
+
if (obj && obj.message && typeof obj.message === 'object' && obj.message.id) {
|
|
91
|
+
// this.adapter.setState(obj.message.id, obj.message.val, false, obj.callback);
|
|
92
|
+
this.stController.setState_typed(obj.message.id, obj.message.val, false, undefined, obj.callback);
|
|
93
|
+
}
|
|
94
|
+
break;
|
|
95
|
+
case 'getDevice':
|
|
96
|
+
if (obj && obj.message && typeof obj.message === 'object' && obj.message.id) {
|
|
97
|
+
this.getDevices(obj.from, obj.command, obj.message.id, obj.callback);
|
|
98
|
+
}
|
|
99
|
+
break;
|
|
100
|
+
case 'reconfigure':
|
|
101
|
+
if (obj && obj.message && typeof obj.message === 'object') {
|
|
102
|
+
this.reconfigure(obj.from, obj.command, obj.message, obj.callback);
|
|
103
|
+
}
|
|
104
|
+
break;
|
|
105
|
+
case 'setDeviceActivated':
|
|
106
|
+
if (obj && obj.message && typeof obj.message === 'object') {
|
|
107
|
+
this.setDeviceActivated(obj.from, obj.command, obj.message, obj.callback);
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
letsPairing(from, command, message, callback) {
|
|
116
|
+
if (this.zbController) {
|
|
117
|
+
let devId = '';
|
|
118
|
+
if (message && message.id) {
|
|
119
|
+
devId = getZbId(message.id);
|
|
120
|
+
}
|
|
121
|
+
// allow devices to join the network within 60 secs
|
|
122
|
+
this.adapter.logToPairing('Pairing started ' + devId, true);
|
|
123
|
+
|
|
124
|
+
let cTimer = Number(this.adapter.config.countDown);
|
|
125
|
+
if (!this.adapter.config.countDown || !cTimer) {
|
|
126
|
+
cTimer = 60;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
this.zbController.permitJoin(cTimer, devId, err => {
|
|
130
|
+
if (!err) {
|
|
131
|
+
// set pairing mode on
|
|
132
|
+
this.adapter.setState('info.pairingMode', true);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
this.adapter.sendTo(from, command, 'Start pairing!', callback);
|
|
136
|
+
} else {
|
|
137
|
+
this.adapter.sendTo(
|
|
138
|
+
from, command,
|
|
139
|
+
{error: 'You need to setup serial port and start the adapter before pairing!'},
|
|
140
|
+
callback
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
touchlinkReset(from, command, message, callback) {
|
|
146
|
+
if (this.zbController) {
|
|
147
|
+
// allow devices to join the network within 60 secs
|
|
148
|
+
this.adapter.logToPairing('Touchlink reset started ', true);
|
|
149
|
+
|
|
150
|
+
let cTimer = Number(this.adapter.config.countDown);
|
|
151
|
+
if (!this.adapter.config.countDown || !cTimer) {
|
|
152
|
+
cTimer = 60;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
this.zbController.touchlinkReset(cTimer);
|
|
156
|
+
this.adapter.sendTo(from, command, 'Start touchlink reset and pairing!', callback);
|
|
157
|
+
} else {
|
|
158
|
+
this.adapter.sendTo(
|
|
159
|
+
from, command,
|
|
160
|
+
{error: 'You need to setup serial port and start the adapter before pairing!'},
|
|
161
|
+
callback
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async getDevices(from, command, id, callback) {
|
|
167
|
+
if (this.zbController) {
|
|
168
|
+
const pairedDevices = await this.zbController.getClients(true);
|
|
169
|
+
const groups = {};
|
|
170
|
+
let rooms;
|
|
171
|
+
this.adapter.getEnumsAsync('enum.rooms')
|
|
172
|
+
.then(enums => {
|
|
173
|
+
// rooms
|
|
174
|
+
rooms = enums['enum.rooms'];
|
|
175
|
+
})
|
|
176
|
+
// get all adapter devices
|
|
177
|
+
.then(() => this.adapter.getDevicesAsync())
|
|
178
|
+
.then(async result => {
|
|
179
|
+
const alls = id ? await this.adapter.getStatesAsync(id + '.*') : await this.adapter.getStatesAsync('*');
|
|
180
|
+
const allst = id ? await this.adapter.getStatesOfAsync(id) : await this.adapter.getStatesOfAsync();
|
|
181
|
+
result = result.filter(item => !id || id === item._id);
|
|
182
|
+
// get device states and groups
|
|
183
|
+
result.forEach(async devInfo => {
|
|
184
|
+
if (devInfo._id) {
|
|
185
|
+
// groups
|
|
186
|
+
// const grState = alls[`${devInfo._id}.groups`];
|
|
187
|
+
// if (grState && grState.val) {
|
|
188
|
+
// groups[devInfo._id] = JSON.parse(grState.val);
|
|
189
|
+
// }
|
|
190
|
+
// battery and link_quality
|
|
191
|
+
const lqState = alls[`${devInfo._id}.link_quality`];
|
|
192
|
+
devInfo.link_quality = lqState ? lqState.val : undefined;
|
|
193
|
+
devInfo.link_quality_lc = lqState ? lqState.lc : undefined;
|
|
194
|
+
const batState = alls[`${devInfo._id}.battery`];
|
|
195
|
+
devInfo.battery = batState ? batState.val : undefined;
|
|
196
|
+
// devInfo.states = states || {};
|
|
197
|
+
|
|
198
|
+
const states = allst.filter(item => item._id.startsWith(devInfo._id));
|
|
199
|
+
|
|
200
|
+
// put only allowed states
|
|
201
|
+
devInfo.statesDef = (states || []).filter(stateDef => {
|
|
202
|
+
const sid = stateDef._id;
|
|
203
|
+
const name = sid.split('.').pop();
|
|
204
|
+
return !disallowedDashStates.includes(name);
|
|
205
|
+
|
|
206
|
+
}).map(stateDef => {
|
|
207
|
+
const name = stateDef.common.name;
|
|
208
|
+
const devname = devInfo.common.name;
|
|
209
|
+
// replace state
|
|
210
|
+
return {
|
|
211
|
+
id: stateDef._id,
|
|
212
|
+
name: typeof name === 'string' ? name.replace(devname, '') : name,
|
|
213
|
+
type: stateDef.common.type,
|
|
214
|
+
read: stateDef.common.read,
|
|
215
|
+
write: stateDef.common.write,
|
|
216
|
+
val: alls[stateDef._id] ? alls[stateDef._id].val : undefined,
|
|
217
|
+
role: stateDef.common.role,
|
|
218
|
+
unit: stateDef.common.unit,
|
|
219
|
+
states: stateDef.common.states,
|
|
220
|
+
};
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
return result;
|
|
225
|
+
})
|
|
226
|
+
.then(async result => {
|
|
227
|
+
// combine info
|
|
228
|
+
const devices = [];
|
|
229
|
+
for (const devInfo of result) {
|
|
230
|
+
if (devInfo._id.indexOf('group') > 0) {
|
|
231
|
+
devInfo.icon = 'img/group.png';
|
|
232
|
+
devInfo.vendor = 'ioBroker';
|
|
233
|
+
// get group members and store them
|
|
234
|
+
const match = /zigbee.\d.group_([0-9]+)/.exec(devInfo._id);
|
|
235
|
+
if (match && match.length > 1) {
|
|
236
|
+
const groupmembers = await this.zbController.getGroupMembersFromController(match[1]);
|
|
237
|
+
this.debug(`group members: ${JSON.stringify(groupmembers)}`);
|
|
238
|
+
if (groupmembers && groupmembers.length > 0) {
|
|
239
|
+
const memberinfo = [];
|
|
240
|
+
for (const member of groupmembers) {
|
|
241
|
+
if (groups) {
|
|
242
|
+
const grouparray = groups[member.ieee];
|
|
243
|
+
if (grouparray) {
|
|
244
|
+
if (!grouparray.includes(match[1])) {
|
|
245
|
+
groups[member.ieee].push(match[1]);
|
|
246
|
+
}
|
|
247
|
+
} else {
|
|
248
|
+
groups[member.ieee] = [match[1]];
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const device = await this.adapter.getObjectAsync(`${this.adapter.namespace}.${member.ieee.substr(2)}`);
|
|
252
|
+
if (device) {
|
|
253
|
+
member.device = device.common.name;
|
|
254
|
+
} else {
|
|
255
|
+
member.device = 'unknown';
|
|
256
|
+
}
|
|
257
|
+
memberinfo.push(member);
|
|
258
|
+
}
|
|
259
|
+
devInfo.memberinfo = memberinfo;
|
|
260
|
+
this.debug(`memberinfo: ${JSON.stringify(devInfo.memberinfo)}`);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
} else {
|
|
264
|
+
const modelDesc = statesMapping.findModel(devInfo.common.type);
|
|
265
|
+
devInfo.icon = (modelDesc && modelDesc.icon) ? modelDesc.icon : 'img/unknown.png';
|
|
266
|
+
devInfo.vendor = modelDesc ? modelDesc.vendor : '';
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const id = getZbId(devInfo._id);
|
|
270
|
+
devInfo.info = await this.zbController.resolveEntity(id);
|
|
271
|
+
|
|
272
|
+
devInfo.rooms = [];
|
|
273
|
+
for (const room in rooms) {
|
|
274
|
+
if (!rooms.hasOwnProperty(room) ||
|
|
275
|
+
!rooms[room] ||
|
|
276
|
+
!rooms[room].common ||
|
|
277
|
+
!rooms[room].common.members
|
|
278
|
+
) {
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
if (rooms[room].common.members.includes(devInfo._id)) {
|
|
282
|
+
devInfo.rooms.push(rooms[room].common.name);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
devInfo.paired = !!devInfo.info;
|
|
286
|
+
// devInfo.groups = groups[devInfo._id];
|
|
287
|
+
devices.push(devInfo);
|
|
288
|
+
}
|
|
289
|
+
return devices;
|
|
290
|
+
})
|
|
291
|
+
.then(async (devices) => {
|
|
292
|
+
// fill group info
|
|
293
|
+
for (const groupdev in groups) {
|
|
294
|
+
this.debug(`GetDevices scanning group ${groupdev} ${JSON.stringify(groups[groupdev])}`);
|
|
295
|
+
const device = devices.find(dev => (groupdev === getZbId(dev._id)));
|
|
296
|
+
if (device) {
|
|
297
|
+
device.groups = groups[groupdev];
|
|
298
|
+
this.debug(`adding group info to device ${groupdev}`);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
// append devices that paired but not created
|
|
302
|
+
if (!id) {
|
|
303
|
+
for (const d of pairedDevices) {
|
|
304
|
+
const device = await this.zbController.resolveEntity(d.ieeeAddr);
|
|
305
|
+
if (!device) {
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
const exists = devices.find((dev) => (dev._id && device.device.ieeeAddr === getZbId(dev._id)));
|
|
309
|
+
if (!exists) {
|
|
310
|
+
devices.push({
|
|
311
|
+
_id: device.device.ieeeAddr,
|
|
312
|
+
icon: 'img/unknown.png',
|
|
313
|
+
paired: true,
|
|
314
|
+
info: device,
|
|
315
|
+
common: {
|
|
316
|
+
name: undefined,
|
|
317
|
+
type: undefined,
|
|
318
|
+
},
|
|
319
|
+
native: {}
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
return devices;
|
|
325
|
+
})
|
|
326
|
+
.then(devices => {
|
|
327
|
+
this.debug(`getDevices result: ${JSON.stringify(devices)}`);
|
|
328
|
+
this.adapter.sendTo(from, command, devices, callback);
|
|
329
|
+
})
|
|
330
|
+
.catch(err => this.error(`getDevices error: ${err.stack}`));
|
|
331
|
+
} else {
|
|
332
|
+
this.adapter.sendTo(from, command, {error: 'You need save and run adapter before pairing!'}, callback);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
async getCoordinatorInfo(from, command, callback) {
|
|
338
|
+
if (this.zbController) {
|
|
339
|
+
const coordinatorinfo = {
|
|
340
|
+
installSource: 'IADefault_1',
|
|
341
|
+
channel: '-1',
|
|
342
|
+
port: 'Default_1',
|
|
343
|
+
installedVersion: 'Default_1',
|
|
344
|
+
type: 'Default_1',
|
|
345
|
+
revision: 'Default_1',
|
|
346
|
+
version: '9-9.9.9.9'
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
const coordinatorVersion = await this.adapter.zbController.herdsman.getCoordinatorVersion();
|
|
350
|
+
|
|
351
|
+
await this.adapter.getForeignObject(`system.adapter.${this.adapter.namespace}`, (err, obj) => {
|
|
352
|
+
if (!err && obj) {
|
|
353
|
+
if (obj.common.installedFrom && obj.common.installedFrom.includes('://')) {
|
|
354
|
+
const instFrom = obj.common.installedFrom;
|
|
355
|
+
coordinatorinfo.installSource = instFrom.replace('tarball', 'commit');
|
|
356
|
+
} else {
|
|
357
|
+
coordinatorinfo.installSource = obj.common.installedFrom;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
try {
|
|
361
|
+
coordinatorinfo.port = obj.native.port;
|
|
362
|
+
coordinatorinfo.channel = obj.native.channel;
|
|
363
|
+
coordinatorinfo.installedVersion = obj.native.version;
|
|
364
|
+
if (coordinatorVersion && coordinatorVersion.type && coordinatorVersion.meta) {
|
|
365
|
+
coordinatorinfo.type = coordinatorVersion.type;
|
|
366
|
+
const meta = coordinatorVersion.meta;
|
|
367
|
+
if (meta) {
|
|
368
|
+
if (meta.hasOwnProperty('revision')) {
|
|
369
|
+
coordinatorinfo.revision = meta.revision;
|
|
370
|
+
}
|
|
371
|
+
let vt = 'x-';
|
|
372
|
+
if (meta.hasOwnProperty('transportrev')) {
|
|
373
|
+
vt = meta.transportrev + '-';
|
|
374
|
+
}
|
|
375
|
+
if (meta.hasOwnProperty('product')) {
|
|
376
|
+
vt = vt + meta.product + '.';
|
|
377
|
+
} else {
|
|
378
|
+
vt = vt + 'x.';
|
|
379
|
+
}
|
|
380
|
+
if (meta.hasOwnProperty('majorrel')) {
|
|
381
|
+
vt = vt + meta.majorrel + '.';
|
|
382
|
+
} else {
|
|
383
|
+
vt = vt + 'x.';
|
|
384
|
+
}
|
|
385
|
+
if (meta.hasOwnProperty('minorrel')) {
|
|
386
|
+
vt = vt + meta.minorrel + '.';
|
|
387
|
+
} else {
|
|
388
|
+
vt = vt + 'x.';
|
|
389
|
+
}
|
|
390
|
+
if (meta.hasOwnProperty('maintrel')) {
|
|
391
|
+
vt = vt + meta.maintrel + '.';
|
|
392
|
+
} else {
|
|
393
|
+
vt = vt + 'x.';
|
|
394
|
+
}
|
|
395
|
+
coordinatorinfo.version = vt;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
} catch {
|
|
399
|
+
this.warn('exception raised in getCoordinatorInfo');
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
this.debug(`getCoordinatorInfo result: ${JSON.stringify(coordinatorinfo)}`);
|
|
403
|
+
this.adapter.sendTo(from, command, coordinatorinfo, callback);
|
|
404
|
+
});
|
|
405
|
+
} else {
|
|
406
|
+
this.adapter.sendTo(from, command, {error: 'You need save and run adapter before pairing!'}, callback);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
renameDevice(from, command, msg, callback) {
|
|
412
|
+
if (this.stController) {
|
|
413
|
+
const id = msg.id;
|
|
414
|
+
const newName = msg.name;
|
|
415
|
+
this.stController.renameDevice(id, newName);
|
|
416
|
+
this.adapter.sendTo(from, command, {}, callback);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
deleteDevice(from, command, msg, callback) {
|
|
421
|
+
if (this.zbController && this.stController) {
|
|
422
|
+
this.debug(`deleteDevice message: ${JSON.stringify(msg)}`);
|
|
423
|
+
const id = msg.id;
|
|
424
|
+
const force = msg.force;
|
|
425
|
+
const sysid = id.replace(this.adapter.namespace + '.', '0x');
|
|
426
|
+
const devId = id.replace(this.adapter.namespace + '.', '');
|
|
427
|
+
this.debug(`deleteDevice sysid: ${sysid}`);
|
|
428
|
+
const dev = this.zbController.getDevice(sysid);
|
|
429
|
+
if (!dev) {
|
|
430
|
+
this.debug('Not found!');
|
|
431
|
+
this.debug(`Try delete dev ${devId} from iobroker.`);
|
|
432
|
+
this.stController.deleteDeviceStates(devId, () =>
|
|
433
|
+
this.adapter.sendTo(from, command, {}, callback));
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
this.zbController.remove(sysid, force, err => {
|
|
437
|
+
if (!err) {
|
|
438
|
+
this.stController.deleteDeviceStates(devId, () =>
|
|
439
|
+
this.adapter.sendTo(from, command, {}, callback));
|
|
440
|
+
} else {
|
|
441
|
+
this.debug(`Error on remove! ${err}`);
|
|
442
|
+
this.adapter.sendTo(from, command, {error: err}, callback);
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
} else {
|
|
446
|
+
this.adapter.sendTo(from, command, {error: 'You need to save and start the adapter!'}, callback);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
async cleanDeviceStates(from, command, msg, callback) {
|
|
451
|
+
this.info(`State cleanup with ${JSON.stringify(msg)}`);
|
|
452
|
+
const devicesFromDB = await this.zbController.getClients(false);
|
|
453
|
+
for (const device of devicesFromDB) {
|
|
454
|
+
const entity = await this.zbController.resolveEntity(device);
|
|
455
|
+
if (entity) {
|
|
456
|
+
const model = (entity.mapped) ? entity.mapped.model : entity.device.modelID;
|
|
457
|
+
await this.stController.deleteOrphanedDeviceStates(device.ieeeAddr, model, msg.force);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
this.adapter.sendTo(from, command, {}, callback);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
async getChannels(from, command, message, callback) {
|
|
464
|
+
if (this.zbController) {
|
|
465
|
+
const result = await this.zbController.getChannelsEnergy();
|
|
466
|
+
this.debug(`getChannels result: ${JSON.stringify(result)}`);
|
|
467
|
+
this.adapter.sendTo(from, command, result, callback);
|
|
468
|
+
} else {
|
|
469
|
+
this.adapter.sendTo(
|
|
470
|
+
from, command,
|
|
471
|
+
{error: 'You need to setup serial port and start the adapter before pairing!'},
|
|
472
|
+
callback
|
|
473
|
+
);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
async setDeviceActivated(from, command, msg, callback) {
|
|
478
|
+
if (this.stController) {
|
|
479
|
+
const id = msg.id;
|
|
480
|
+
const targetstate = msg.deactivated;
|
|
481
|
+
this.stController.setDeviceActivated(id, targetstate);
|
|
482
|
+
this.adapter.sendTo(from, command, {}, callback);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
async reconfigure(from, command, msg, callback) {
|
|
487
|
+
if (this.zbController) {
|
|
488
|
+
const devid = getZbId(msg.id);
|
|
489
|
+
this.debug(`Reconfigure ${devid}`);
|
|
490
|
+
const entity = await this.zbController.resolveEntity(devid);
|
|
491
|
+
if (entity) {
|
|
492
|
+
try {
|
|
493
|
+
await this.zbController.callExtensionMethod(
|
|
494
|
+
'doConfigure',
|
|
495
|
+
[entity.device, entity.mapped],
|
|
496
|
+
);
|
|
497
|
+
this.adapter.sendTo(from, command, {}, callback);
|
|
498
|
+
} catch (error) {
|
|
499
|
+
const errmsg = `Reconfigure failed ${entity.device.ieeeAddr} ${entity.device.modelID}, (${error.stack})`;
|
|
500
|
+
this.error(errmsg);
|
|
501
|
+
this.adapter.sendTo(from, command, {error: errmsg}, callback);
|
|
502
|
+
}
|
|
503
|
+
} else {
|
|
504
|
+
this.adapter.sendTo(from, command, {error: 'No device'}, callback);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
module.exports = Commands;
|