iobroker.zigbee 1.9.1 → 1.9.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 (60) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +433 -425
  3. package/admin/adapter-settings.js +244 -244
  4. package/admin/admin.js +2991 -2991
  5. package/admin/i18n/de/translations.json +108 -108
  6. package/admin/i18n/en/translations.json +108 -108
  7. package/admin/i18n/es/translations.json +102 -102
  8. package/admin/i18n/fr/translations.json +108 -108
  9. package/admin/i18n/it/translations.json +102 -102
  10. package/admin/i18n/nl/translations.json +108 -108
  11. package/admin/i18n/pl/translations.json +108 -108
  12. package/admin/i18n/pt/translations.json +102 -102
  13. package/admin/i18n/ru/translations.json +108 -108
  14. package/admin/i18n/uk/translations.json +108 -108
  15. package/admin/i18n/zh-cn/translations.json +102 -102
  16. package/admin/img/philips_hue_lom001.png +0 -0
  17. package/admin/index.html +163 -163
  18. package/admin/index_m.html +1360 -1360
  19. package/admin/moment.min.js +1 -1
  20. package/admin/shuffle.min.js +2 -2
  21. package/admin/tab_m.html +1021 -1021
  22. package/admin/vis-network.min.css +1 -1
  23. package/admin/vis-network.min.js +26 -26
  24. package/admin/words.js +110 -110
  25. package/docs/de/basedocu.md +19 -19
  26. package/docs/de/readme.md +126 -126
  27. package/docs/en/readme.md +128 -128
  28. package/docs/flashing_via_arduino_(en).md +110 -110
  29. package/docs/ru/readme.md +28 -28
  30. package/docs/tutorial/groups-1.png +0 -0
  31. package/docs/tutorial/groups-2.png +0 -0
  32. package/docs/tutorial/tab-dev-1.png +0 -0
  33. package/io-package.json +27 -27
  34. package/lib/backup.js +171 -171
  35. package/lib/binding.js +319 -319
  36. package/lib/colors.js +465 -465
  37. package/lib/commands.js +4 -2
  38. package/lib/developer.js +151 -151
  39. package/lib/devicemgmt.js +374 -393
  40. package/lib/devices.js +3139 -3139
  41. package/lib/exclude.js +162 -162
  42. package/lib/exposes.js +41 -14
  43. package/lib/groups.js +345 -345
  44. package/lib/json.js +59 -59
  45. package/lib/networkmap.js +55 -55
  46. package/lib/ota.js +198 -198
  47. package/lib/rgb.js +297 -297
  48. package/lib/seriallist.js +48 -48
  49. package/lib/states.js +6420 -6420
  50. package/lib/statescontroller.js +25 -10
  51. package/lib/tools.js +54 -54
  52. package/lib/utils.js +165 -165
  53. package/lib/zbBaseExtension.js +36 -36
  54. package/lib/zbDelayedAction.js +144 -144
  55. package/lib/zbDeviceAvailability.js +319 -319
  56. package/lib/zbDeviceConfigure.js +148 -151
  57. package/lib/zbDeviceEvent.js +48 -48
  58. package/lib/zigbeecontroller.js +1014 -1014
  59. package/package.json +4 -4
  60. package/support/docgen.js +93 -93
package/lib/exclude.js CHANGED
@@ -1,162 +1,162 @@
1
- 'use strict';
2
-
3
- class Exclude {
4
- constructor(adapter) {
5
- this.adapter = adapter;
6
- this.adapter.on('message', this.onMessage.bind(this));
7
- }
8
-
9
- start(zbController, stController) {
10
- this.zbController = zbController;
11
- this.stController = stController;
12
- }
13
-
14
- stop() {
15
- delete this.zbController;
16
- delete this.stController;
17
- }
18
-
19
- info(msg) {
20
- this.adapter.log.info(msg);
21
- }
22
-
23
- error(msg) {
24
- this.adapter.log.error(msg);
25
- }
26
-
27
- debug(msg) {
28
- this.adapter.log.debug(msg);
29
- }
30
-
31
- warn(msg) {
32
- this.adapter.log.warn(msg);
33
- }
34
-
35
-
36
- /**
37
- * @param {ioBroker.Message} obj
38
- */
39
- onMessage(obj) {
40
- if (typeof obj === 'object' && obj.command) {
41
- switch (obj.command) {
42
- case 'addExclude':
43
- if (obj && obj.message && typeof obj.message === 'object') {
44
- this.addExclude(obj.from, obj.command, obj.message, err =>
45
- this.adapter.sendTo(obj.from, obj.command, err, obj.callback));
46
- }
47
- break;
48
-
49
- case 'getExclude':
50
- if (obj && obj.message && typeof obj.message === 'object') {
51
- this.getExclude(exclude =>
52
- this.adapter.sendTo(obj.from, obj.command, exclude, obj.callback));
53
- }
54
- break;
55
- case 'delExclude':
56
- if (obj && obj.message) {
57
- this.delExclude(obj.from, obj.command, obj.message, err =>
58
- this.adapter.sendTo(obj.from, obj.command, err, obj.callback));
59
- }
60
- break;
61
- }
62
- }
63
- }
64
-
65
- getExcludeId(exclude_target) {
66
- return `${this.extractDeviceId(exclude_target)}`;
67
- }
68
-
69
- extractDeviceId(stateId) {
70
- if (stateId) {
71
- return stateId.replace(`${this.adapter.namespace}.`, '');
72
- }
73
- return '';
74
- }
75
-
76
- extractExcludeId(stateId) {
77
- return stateId.replace(`${this.adapter.namespace}.exclude.`, '');
78
- }
79
-
80
- getExcludeName(devName, stateId) {
81
- return devName.replace(` ${stateId}`, '');
82
- }
83
-
84
- async addExclude(from, command, params, callback) {
85
- try {
86
- this.debug('addExclude message: ' + JSON.stringify(params));
87
- const exclude_mod = params.exclude_model.common.type;
88
- const stateId = `exclude.${exclude_mod}`;
89
-
90
- this.adapter.setObjectNotExists(stateId,
91
- {
92
- type: 'state',
93
- common: {name: exclude_mod},
94
- },
95
- () => this.adapter.setState(stateId, exclude_mod, true, () =>
96
- callback()),
97
- );
98
- } catch (error) {
99
- this.error(`Failed to addExclude ${error.stack}`);
100
- throw new Error(`Failed to addExclude ${error.stack}`);
101
- }
102
- }
103
-
104
- async delExclude(from, command, exclude_id, callback) {
105
- try {
106
- this.debug(`delExclude message: ${JSON.stringify(exclude_id)}`);
107
- const stateId = `exclude.${exclude_id}`;
108
- this.adapter.getStateAsync(stateId)
109
- .then(async (stateV) => {
110
- this.debug(`found state: ${JSON.stringify(stateV)}`);
111
- this.adapter.deleteState(null, 'exclude', exclude_id, async () =>
112
- callback());
113
- });
114
- } catch (error) {
115
- this.error(`Failed to delExclude ${error.stack}`);
116
- throw new Error(`Failed to delExclude ${error.stack}`);
117
- }
118
- }
119
-
120
- getExclude(callback) {
121
- try {
122
- const exclude = [];
123
- this.adapter.getStatesOf('exclude', (err, states) => {
124
- if (!err && states) {
125
- const exc = [];
126
- states.forEach(state => {
127
- if (state._id.startsWith(`${this.adapter.namespace}.exclude`)) {
128
- exc.push(new Promise(resolve =>
129
- this.adapter.getStateAsync(state._id)
130
- .then(stateVa => {
131
- if (stateVa !== null) {
132
- const val = {
133
- id: this.extractExcludeId(state._id),
134
- name: stateVa.val
135
- };
136
- if (this.extractExcludeId(state._id) !== 'all') {
137
- exclude.push(val);
138
- }
139
- }
140
- resolve();
141
- })));
142
- }
143
- });
144
- return Promise.all(exc)
145
- .then(() => {
146
- const arrExclude = JSON.stringify(exclude);
147
- this.debug(`getExclude result: ${arrExclude}`);
148
- this.adapter.setState('exclude.all', arrExclude, true, () =>
149
- callback(exclude));
150
- });
151
- } else {
152
- this.debug(`getExclude result: ${JSON.stringify(exclude)}`);
153
- callback(exclude);
154
- }
155
- });
156
- } catch (error) {
157
- this.error(`Failed to getExclude ${error.stack}`);
158
- }
159
- }
160
- }
161
-
162
- module.exports = Exclude;
1
+ 'use strict';
2
+
3
+ class Exclude {
4
+ constructor(adapter) {
5
+ this.adapter = adapter;
6
+ this.adapter.on('message', this.onMessage.bind(this));
7
+ }
8
+
9
+ start(zbController, stController) {
10
+ this.zbController = zbController;
11
+ this.stController = stController;
12
+ }
13
+
14
+ stop() {
15
+ delete this.zbController;
16
+ delete this.stController;
17
+ }
18
+
19
+ info(msg) {
20
+ this.adapter.log.info(msg);
21
+ }
22
+
23
+ error(msg) {
24
+ this.adapter.log.error(msg);
25
+ }
26
+
27
+ debug(msg) {
28
+ this.adapter.log.debug(msg);
29
+ }
30
+
31
+ warn(msg) {
32
+ this.adapter.log.warn(msg);
33
+ }
34
+
35
+
36
+ /**
37
+ * @param {ioBroker.Message} obj
38
+ */
39
+ onMessage(obj) {
40
+ if (typeof obj === 'object' && obj.command) {
41
+ switch (obj.command) {
42
+ case 'addExclude':
43
+ if (obj && obj.message && typeof obj.message === 'object') {
44
+ this.addExclude(obj.from, obj.command, obj.message, err =>
45
+ this.adapter.sendTo(obj.from, obj.command, err, obj.callback));
46
+ }
47
+ break;
48
+
49
+ case 'getExclude':
50
+ if (obj && obj.message && typeof obj.message === 'object') {
51
+ this.getExclude(exclude =>
52
+ this.adapter.sendTo(obj.from, obj.command, exclude, obj.callback));
53
+ }
54
+ break;
55
+ case 'delExclude':
56
+ if (obj && obj.message) {
57
+ this.delExclude(obj.from, obj.command, obj.message, err =>
58
+ this.adapter.sendTo(obj.from, obj.command, err, obj.callback));
59
+ }
60
+ break;
61
+ }
62
+ }
63
+ }
64
+
65
+ getExcludeId(exclude_target) {
66
+ return `${this.extractDeviceId(exclude_target)}`;
67
+ }
68
+
69
+ extractDeviceId(stateId) {
70
+ if (stateId) {
71
+ return stateId.replace(`${this.adapter.namespace}.`, '');
72
+ }
73
+ return '';
74
+ }
75
+
76
+ extractExcludeId(stateId) {
77
+ return stateId.replace(`${this.adapter.namespace}.exclude.`, '');
78
+ }
79
+
80
+ getExcludeName(devName, stateId) {
81
+ return devName.replace(` ${stateId}`, '');
82
+ }
83
+
84
+ async addExclude(from, command, params, callback) {
85
+ try {
86
+ this.debug('addExclude message: ' + JSON.stringify(params));
87
+ const exclude_mod = params.exclude_model.common.type;
88
+ const stateId = `exclude.${exclude_mod}`;
89
+
90
+ this.adapter.setObjectNotExists(stateId,
91
+ {
92
+ type: 'state',
93
+ common: {name: exclude_mod},
94
+ },
95
+ () => this.adapter.setState(stateId, exclude_mod, true, () =>
96
+ callback()),
97
+ );
98
+ } catch (error) {
99
+ this.error(`Failed to addExclude ${error.stack}`);
100
+ throw new Error(`Failed to addExclude ${error.stack}`);
101
+ }
102
+ }
103
+
104
+ async delExclude(from, command, exclude_id, callback) {
105
+ try {
106
+ this.debug(`delExclude message: ${JSON.stringify(exclude_id)}`);
107
+ const stateId = `exclude.${exclude_id}`;
108
+ this.adapter.getStateAsync(stateId)
109
+ .then(async (stateV) => {
110
+ this.debug(`found state: ${JSON.stringify(stateV)}`);
111
+ this.adapter.deleteState(null, 'exclude', exclude_id, async () =>
112
+ callback());
113
+ });
114
+ } catch (error) {
115
+ this.error(`Failed to delExclude ${error.stack}`);
116
+ throw new Error(`Failed to delExclude ${error.stack}`);
117
+ }
118
+ }
119
+
120
+ getExclude(callback) {
121
+ try {
122
+ const exclude = [];
123
+ this.adapter.getStatesOf('exclude', (err, states) => {
124
+ if (!err && states) {
125
+ const exc = [];
126
+ states.forEach(state => {
127
+ if (state._id.startsWith(`${this.adapter.namespace}.exclude`)) {
128
+ exc.push(new Promise(resolve =>
129
+ this.adapter.getStateAsync(state._id)
130
+ .then(stateVa => {
131
+ if (stateVa !== null) {
132
+ const val = {
133
+ id: this.extractExcludeId(state._id),
134
+ name: stateVa.val
135
+ };
136
+ if (this.extractExcludeId(state._id) !== 'all') {
137
+ exclude.push(val);
138
+ }
139
+ }
140
+ resolve();
141
+ })));
142
+ }
143
+ });
144
+ return Promise.all(exc)
145
+ .then(() => {
146
+ const arrExclude = JSON.stringify(exclude);
147
+ this.debug(`getExclude result: ${arrExclude}`);
148
+ this.adapter.setState('exclude.all', arrExclude, true, () =>
149
+ callback(exclude));
150
+ });
151
+ } else {
152
+ this.debug(`getExclude result: ${JSON.stringify(exclude)}`);
153
+ callback(exclude);
154
+ }
155
+ });
156
+ } catch (error) {
157
+ this.error(`Failed to getExclude ${error.stack}`);
158
+ }
159
+ }
160
+ }
161
+
162
+ module.exports = Exclude;
package/lib/exposes.js CHANGED
@@ -248,9 +248,37 @@ function createFromExposes(model, def) {
248
248
  }
249
249
 
250
250
  const icon = utils.getDeviceIcon(def);
251
- for (const expose of def.exposes) {
252
- let state;
253
251
 
252
+ if (typeof def.exposes == 'object') {
253
+ for (const expose of def.exposes) {
254
+ genStateFromExpose(expose);
255
+
256
+
257
+ }
258
+ }
259
+
260
+ // maybee here check manufacturerName for tuya devices
261
+ if (typeof def.exposes == 'function') {
262
+ const expFunction = def.exposes(def, {}); // maybee here check manufacturerName for tuya devices
263
+
264
+ for (const expose of expFunction) {
265
+ genStateFromExpose(expose);
266
+ }
267
+ }
268
+
269
+ const newDev = {
270
+ models: [model],
271
+ icon,
272
+ states,
273
+ exposed: true,
274
+ };
275
+
276
+ return newDev;
277
+
278
+
279
+
280
+ function genStateFromExpose(expose) {
281
+ let state;
254
282
  switch (expose.type) {
255
283
  case 'light':
256
284
  for (const prop of expose.features) {
@@ -362,7 +390,7 @@ function createFromExposes(model, def) {
362
390
  x: xy[0],
363
391
  y: xy[1]
364
392
  };
365
- */
393
+ */
366
394
  let xy = [0, 0];
367
395
  const rgbcolor = colors.ParseColor(value);
368
396
 
@@ -851,22 +879,20 @@ function createFromExposes(model, def) {
851
879
  }
852
880
  }
853
881
  break;
882
+ case 'list':
883
+ // is not mapped
884
+ // for (const prop of expose) {
885
+ // let nam = prop.name;
886
+
887
+ // }
888
+ break;
854
889
  default:
855
890
  console.log(`Unhandled expose type ${expose.type} for device ${model}`);
891
+
856
892
  }
857
893
  }
858
- const newDev = {
859
- models: [model],
860
- icon,
861
- states,
862
- exposed: true,
863
- };
864
- // make the function code printable in log
865
- //console.log(`Created mapping for device ${model}: ${JSON.stringify(newDev, function(key, value) {
866
- // if (typeof value === 'function') {return value.toString() } else { return value } }, ' ')}`);
867
- return newDev;
868
- }
869
894
 
895
+ }
870
896
  function applyExposes(mappedDevices, byModel, allExcludesObj) {
871
897
  // for exclude search
872
898
  const allExcludesStr = JSON.stringify(allExcludesObj);
@@ -890,6 +916,7 @@ function applyExposes(mappedDevices, byModel, allExcludesObj) {
890
916
  function applyDeviceDef(mappedDevices, byModel, allExcludesStr, deviceDef) {
891
917
  const stripModel = utils.getModelRegEx(deviceDef.model);
892
918
  // check if device is mapped
919
+
893
920
  const existsMap = byModel.get(stripModel);
894
921
 
895
922
  if ((deviceDef.hasOwnProperty('exposes') && (!existsMap || !existsMap.hasOwnProperty('states'))) || allExcludesStr.indexOf(stripModel) > 0) {