iobroker.zigbee 1.8.1 → 1.8.3

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.
Files changed (89) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc.json +37 -0
  3. package/.github/FUNDING.yml +3 -0
  4. package/.github/auto-merge.yml +17 -0
  5. package/.github/dependabot.yml +24 -0
  6. package/.github/stale.yml +13 -0
  7. package/.github/workflows/codeql.yml +41 -0
  8. package/.github/workflows/dependabot-automerge.yml +22 -0
  9. package/.github/workflows/test-and-release.yml +149 -0
  10. package/.releaseconfig.json +3 -0
  11. package/.travis/wiki.sh +28 -0
  12. package/.travis.yml +41 -0
  13. package/README.md +31 -8
  14. package/admin/admin.js +466 -482
  15. package/admin/i18n/de/translations.json +2 -2
  16. package/admin/index_m.html +1 -1
  17. package/admin/tab_m.html +3 -44
  18. package/admin/words.js +2 -2
  19. package/gulpfile.js +464 -0
  20. package/io-package.json +18 -25
  21. package/lib/backup.js +2 -2
  22. package/lib/binding.js +37 -32
  23. package/lib/colors.js +158 -163
  24. package/lib/commands.js +90 -99
  25. package/lib/developer.js +12 -9
  26. package/lib/devices.js +179 -169
  27. package/lib/exclude.js +36 -30
  28. package/lib/exposes.js +139 -163
  29. package/lib/groups.js +83 -81
  30. package/lib/json.js +6 -5
  31. package/lib/networkmap.js +3 -2
  32. package/lib/ota.js +18 -34
  33. package/lib/rgb.js +72 -114
  34. package/lib/seriallist.js +20 -25
  35. package/lib/states.js +526 -511
  36. package/lib/statescontroller.js +183 -206
  37. package/lib/utils.js +23 -24
  38. package/lib/zbBaseExtension.js +4 -4
  39. package/lib/zbDelayedAction.js +13 -5
  40. package/lib/zbDeviceAvailability.js +65 -69
  41. package/lib/zbDeviceConfigure.js +21 -9
  42. package/lib/zbDeviceEvent.js +4 -3
  43. package/lib/zigbeecontroller.js +103 -109
  44. package/main.js +147 -163
  45. package/package.json +15 -29
  46. package/test/integration.js +5 -0
  47. package/test/mocha.custom.opts +2 -0
  48. package/test/mocha.setup.js +14 -0
  49. package/test/package.js +5 -0
  50. package/test/unit.js +5 -0
  51. package/docs/de/img/CC2531.png +0 -0
  52. package/docs/de/img/CC2538_CC2592_PA.PNG +0 -0
  53. package/docs/de/img/CC2591.png +0 -0
  54. package/docs/de/img/boards.jpg +0 -0
  55. package/docs/de/img/cc26x2r.PNG +0 -0
  56. package/docs/de/img/results.jpg +0 -0
  57. package/docs/de/img/sku_429478_2.png +0 -0
  58. package/docs/de/img/sku_429601_2.png +0 -0
  59. package/docs/de/readme.md +0 -27
  60. package/docs/en/img/CC2531.png +0 -0
  61. package/docs/en/img/CC2591.png +0 -0
  62. package/docs/en/img/deconz.png +0 -0
  63. package/docs/en/img/sku_429478_2.png +0 -0
  64. package/docs/en/img/sku_429601_2.png +0 -0
  65. package/docs/en/readme.md +0 -30
  66. package/docs/flashing_via_arduino_(en).md +0 -110
  67. package/docs/ru/img/CC2531.png +0 -0
  68. package/docs/ru/img/CC2591.png +0 -0
  69. package/docs/ru/img/sku_429478_2.png +0 -0
  70. package/docs/ru/img/sku_429601_2.png +0 -0
  71. package/docs/ru/readme.md +0 -28
  72. package/docs/tutorial/CC2530_20190425.zip +0 -0
  73. package/docs/tutorial/CC2530_CC2591_20190515.zip +0 -0
  74. package/docs/tutorial/CC2530_CC2592_20190515.zip +0 -0
  75. package/docs/tutorial/CC2531_20190425.zip +0 -0
  76. package/docs/tutorial/adm5_1.PNG +0 -0
  77. package/docs/tutorial/adm5_2.PNG +0 -0
  78. package/docs/tutorial/cat.PNG +0 -0
  79. package/docs/tutorial/groups-1.png +0 -0
  80. package/docs/tutorial/groups-2.png +0 -0
  81. package/docs/tutorial/inst.PNG +0 -0
  82. package/docs/tutorial/reflash-finish.PNG +0 -0
  83. package/docs/tutorial/reflash-step0.png +0 -0
  84. package/docs/tutorial/reflash-step1.PNG +0 -0
  85. package/docs/tutorial/reflash-step2.PNG +0 -0
  86. package/docs/tutorial/settings.png +0 -0
  87. package/docs/tutorial/tab-dev-1.png +0 -0
  88. package/docs/tutorial/zigbee.png +0 -0
  89. package/docs/tutorial/zigbee15.png +0 -0
package/lib/binding.js CHANGED
@@ -34,7 +34,7 @@ class Binding {
34
34
  debug(msg) {
35
35
  this.adapter.log.debug(msg);
36
36
  }
37
-
37
+
38
38
  warn(msg) {
39
39
  this.adapter.log.warn(msg);
40
40
  }
@@ -47,26 +47,30 @@ class Binding {
47
47
  switch (obj.command) {
48
48
  case 'addBinding':
49
49
  if (obj && obj.message && typeof obj.message === 'object') {
50
- this.addBinding(obj.from, obj.command, obj.message, err =>
51
- this.adapter.sendTo(obj.from, obj.command, err, obj.callback));
50
+ this.addBinding(obj.from, obj.command, obj.message, (err)=>{
51
+ this.adapter.sendTo(obj.from, obj.command, err, obj.callback);
52
+ });
52
53
  }
53
54
  break;
54
55
  case 'editBinding':
55
56
  if (obj && obj.message && typeof obj.message === 'object') {
56
- this.editBinding(obj.from, obj.command, obj.message, err =>
57
- this.adapter.sendTo(obj.from, obj.command, err, obj.callback));
57
+ this.editBinding(obj.from, obj.command, obj.message, (err)=>{
58
+ this.adapter.sendTo(obj.from, obj.command, err, obj.callback);
59
+ });
58
60
  }
59
61
  break;
60
62
  case 'getBinding':
61
63
  if (obj && obj.message && typeof obj.message === 'object') {
62
- this.getBinding(binding =>
63
- this.adapter.sendTo(obj.from, obj.command, binding, obj.callback));
64
+ this.getBinding((binding)=>{
65
+ this.adapter.sendTo(obj.from, obj.command, binding, obj.callback);
66
+ });
64
67
  }
65
68
  break;
66
69
  case 'delBinding':
67
70
  if (obj && obj.message) {
68
- this.delBinding(obj.from, obj.command, obj.message, err =>
69
- this.adapter.sendTo(obj.from, obj.command, err, obj.callback));
71
+ this.delBinding(obj.from, obj.command, obj.message, (err)=>{
72
+ this.adapter.sendTo(obj.from, obj.command, err, obj.callback);
73
+ });
70
74
  }
71
75
  break;
72
76
  }
@@ -82,23 +86,21 @@ class Binding {
82
86
  }
83
87
 
84
88
  extractDeviceId(stateId) {
85
- if (stateId) {
89
+ if (stateId)
86
90
  return stateId.replace(`${this.adapter.namespace}.`, '');
87
- }
88
91
  return '';
89
92
  }
90
93
 
91
94
  getBindEp(ep) {
92
- if (ep) {
95
+ if (ep)
93
96
  return parseInt(ep.split('_')[0]);
94
- }
95
97
 
96
98
  this.warn(`getBindEp called with illegal ep: ${safeJsonStringify(ep)}`);
97
99
  return 0;
98
100
  }
99
101
 
100
102
  getBindCl(ep) {
101
- return ep.indexOf('_') > 0 ? ep.split('_')[1] : null;
103
+ return (ep.indexOf('_') > 0) ? ep.split('_')[1] : null;
102
104
  }
103
105
 
104
106
  async doBindUnbind(type, bind_source, bind_source_ep, bind_target, bind_target_ep, callback) {
@@ -121,7 +123,8 @@ class Binding {
121
123
 
122
124
  if (!source || !target) {
123
125
  this.error('Devices not found');
124
- return callback && callback('Devices not found');
126
+ if (callback) callback('Devices not found');
127
+ return;
125
128
  }
126
129
  const sourceName = source.name;
127
130
  const targetName = target.name;
@@ -141,7 +144,8 @@ class Binding {
141
144
  }
142
145
  if (!found) {
143
146
  this.debug(`No bind clusters`);
144
- return callback && callback(`No bind clusters`);
147
+ if (callback) callback(`No bind clusters`);
148
+ return;
145
149
  } else {
146
150
  let ok = true;
147
151
  for (const clID of clusters) {
@@ -167,23 +171,23 @@ class Binding {
167
171
  `Failed to ${type} cluster '${cluster}' from '${sourceName}' to ` +
168
172
  `'${targetName}' (${error})`,
169
173
  );
170
- callback && callback(`Failed to ${type} cluster '${cluster}' from '${sourceName}' to '${targetName}' (${error})`);
174
+ if (callback) callback(`Failed to ${type} cluster '${cluster}' from '${sourceName}' to '${targetName}' (${error})`);
171
175
  ok = false;
172
176
  break;
173
177
  }
174
178
  }
175
179
  }
176
- ok && callback && callback(undefined, id);
180
+ if (ok && callback) callback(undefined, id);
177
181
  }
178
182
  } catch (error) {
179
183
  this.error(`Failed to doBindUnbind ${error.stack}`);
180
- callback && callback(`Failed to doBindUnbind ${error.stack}`);
184
+ if (callback) callback(`Failed to doBindUnbind ${error.stack}`);
181
185
  }
182
186
  }
183
187
 
184
188
  async addBinding(from, command, params, callback) {
185
189
  try {
186
- this.debug(`addBinding message: ${JSON.stringify(params)}`);
190
+ this.debug('addBinding message: ' + JSON.stringify(params));
187
191
  const bind_source = params.bind_source,
188
192
  bind_source_ep = params.bind_source_ep,
189
193
  bind_target = params.bind_target,
@@ -203,8 +207,9 @@ class Binding {
203
207
  type: 'state',
204
208
  common: {name: id},
205
209
  }, () => {
206
- this.adapter.setState(stateId, JSON.stringify(params), true, () =>
207
- callback());
210
+ this.adapter.setState(stateId, JSON.stringify(params), true, () => {
211
+ callback();
212
+ });
208
213
  });
209
214
  }
210
215
  });
@@ -216,7 +221,7 @@ class Binding {
216
221
 
217
222
  async editBinding(from, command, params, callback) {
218
223
  try {
219
- this.debug(`editBinding message: ${JSON.stringify(params)}`);
224
+ this.debug('editBinding message: ' + JSON.stringify(params));
220
225
  const old_id = params.id,
221
226
  bind_source = params.bind_source,
222
227
  bind_source_ep = params.bind_source_ep,
@@ -224,7 +229,7 @@ class Binding {
224
229
  bind_target_ep = params.bind_target_ep,
225
230
  id = this.getBindingId(bind_source, bind_source_ep, bind_target, bind_target_ep);
226
231
  if (old_id !== id) {
227
- await this.delBinding(from, command, old_id, async err => {
232
+ await this.delBinding(from, command, old_id, async (err)=>{
228
233
  if (err) {
229
234
  callback(err);
230
235
  } else {
@@ -234,10 +239,10 @@ class Binding {
234
239
  } else {
235
240
  const type = params.unbind_from_coordinator ? 'unbind' : 'bind';
236
241
  try {
237
- await this.doBindUnbind(type, bind_source, bind_source_ep, 'coordinator', '1');
242
+ await this.doBindUnbind(type , bind_source, bind_source_ep, 'coordinator', '1');
238
243
  this.debug('Successfully ' + (type === 'bind' ? 'bound' : 'unbound') + ' Coordinator from ' + bind_source);
239
244
  } catch (e) {
240
- this.error(`Could not ${type} Coordinator from ${bind_source}: ${JSON.stringify(e)}`);
245
+ this.error('Could not ' + type + ' Coordinator from ' + bind_source + ': ' + JSON.stringify(e));
241
246
  }
242
247
  }
243
248
  } catch (error) {
@@ -247,17 +252,17 @@ class Binding {
247
252
 
248
253
  async delBinding(from, command, bind_id, callback) {
249
254
  try {
250
- this.debug(`delBinding message: ${JSON.stringify(bind_id)}`);
255
+ this.debug('delBinding message: ' + JSON.stringify(bind_id));
251
256
  const stateId = `info.${bind_id}`;
252
257
  this.adapter.getStateAsync(stateId)
253
- .then(async stateV => {
254
- this.debug(`found state: ${JSON.stringify(stateV)}`);
258
+ .then(async (stateV) => {
259
+ this.debug('found state: ' + JSON.stringify(stateV));
255
260
  const params = JSON.parse(stateV.val);
256
261
  const bind_source = params.bind_source,
257
262
  bind_source_ep = params.bind_source_ep,
258
263
  bind_target = params.bind_target,
259
264
  bind_target_ep = params.bind_target_ep;
260
- await this.doBindUnbind('unbind', bind_source, bind_source_ep, bind_target, bind_target_ep, async err => {
265
+ await this.doBindUnbind('unbind', bind_source, bind_source_ep, bind_target, bind_target_ep, async (err) => {
261
266
  if (err) {
262
267
  callback({error: err});
263
268
  } else {
@@ -303,11 +308,11 @@ class Binding {
303
308
  }
304
309
  });
305
310
  return Promise.all(chain).then(() => {
306
- this.debug(`getBinding result: ${JSON.stringify(binding)}`);
311
+ this.debug('getBinding result: ' + JSON.stringify(binding));
307
312
  callback(binding);
308
313
  });
309
314
  } else {
310
- this.debug(`getBinding result: ${JSON.stringify(binding)}`);
315
+ this.debug('getBinding result: ' + JSON.stringify(binding));
311
316
  callback(binding);
312
317
  }
313
318
  });