iobroker.zigbee 1.6.8 → 1.6.16

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 (64) hide show
  1. package/.eslintignore +1 -1
  2. package/.eslintrc.json +36 -36
  3. package/.github/FUNDING.yml +3 -3
  4. package/.github/stale.yml +13 -13
  5. package/.github/workflows/test-and-release.yml +151 -151
  6. package/.travis/wiki.sh +27 -27
  7. package/LICENSE +21 -21
  8. package/README.md +424 -385
  9. package/admin/adapter-settings.js +244 -244
  10. package/admin/admin.js +2926 -2704
  11. package/admin/img/14153905L.png +0 -0
  12. package/admin/img/81855.png +0 -0
  13. package/admin/img/HG06338.png +0 -0
  14. package/admin/img/TI0001-cover.png +0 -0
  15. package/admin/img/philips_hue_lom001.png +0 -0
  16. package/admin/index.html +159 -159
  17. package/admin/index_m.html +1158 -1055
  18. package/admin/moment.min.js +1 -1
  19. package/admin/shuffle.min.js +2 -2
  20. package/admin/tab_m.html +944 -1025
  21. package/admin/vis-network.min.js +26 -26
  22. package/admin/words.js +108 -107
  23. package/docs/de/readme.md +27 -27
  24. package/docs/en/readme.md +30 -30
  25. package/docs/flashing_via_arduino_(en).md +110 -110
  26. package/docs/ru/readme.md +28 -28
  27. package/docs/tutorial/groups-1.png +0 -0
  28. package/docs/tutorial/groups-2.png +0 -0
  29. package/docs/tutorial/tab-dev-1.png +0 -0
  30. package/docs/tutorial/zigbee.png +0 -0
  31. package/io-package.json +355 -317
  32. package/lib/backup.js +132 -132
  33. package/lib/binding.js +325 -325
  34. package/lib/colors.js +460 -460
  35. package/lib/commands.js +501 -435
  36. package/lib/developer.js +148 -148
  37. package/lib/devices.js +3144 -3119
  38. package/lib/exclude.js +168 -168
  39. package/lib/exposes.js +13 -9
  40. package/lib/groups.js +342 -316
  41. package/lib/json.js +60 -60
  42. package/lib/networkmap.js +56 -56
  43. package/lib/ota.js +179 -153
  44. package/lib/rgb.js +255 -225
  45. package/lib/seriallist.js +37 -37
  46. package/lib/states.js +6407 -6381
  47. package/lib/statescontroller.js +627 -502
  48. package/lib/tools.js +54 -54
  49. package/lib/utils.js +151 -151
  50. package/lib/zbBaseExtension.js +32 -31
  51. package/lib/zbDelayedAction.js +152 -151
  52. package/lib/zbDeviceAvailability.js +318 -306
  53. package/lib/zbDeviceConfigure.js +152 -148
  54. package/lib/zbDeviceEvent.js +49 -43
  55. package/lib/zigbeecontroller.js +946 -856
  56. package/main.js +8 -4
  57. package/package.json +77 -74
  58. package/support/docgen.js +93 -93
  59. package/.devcontainer/devcontainer.json +0 -36
  60. package/.devcontainer/docker-compose.yml +0 -51
  61. package/.devcontainer/iobroker/Dockerfile +0 -2
  62. package/.devcontainer/nginx/nginx.conf +0 -33
  63. package/.devcontainer/parcel/Dockerfile +0 -9
  64. package/.devcontainer/parcel/run.sh +0 -7
package/lib/exclude.js CHANGED
@@ -1,168 +1,168 @@
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
- /**
38
- * @param {ioBroker.Message} obj
39
- */
40
- onMessage(obj) {
41
- if (typeof obj === 'object' && obj.command) {
42
- switch (obj.command) {
43
- case 'addExclude':
44
- if (obj && obj.message && typeof obj.message === 'object') {
45
- this.addExclude(obj.from, obj.command, obj.message, (err)=>{
46
- this.adapter.sendTo(obj.from, obj.command, err, obj.callback);
47
- });
48
- }
49
- break;
50
-
51
- case 'getExclude':
52
- if (obj && obj.message && typeof obj.message === 'object') {
53
- this.getExclude((exclude)=>{
54
- this.adapter.sendTo(obj.from, obj.command, exclude, obj.callback);
55
- });
56
- }
57
- break;
58
- case 'delExclude':
59
- if (obj && obj.message) {
60
- this.delExclude(obj.from, obj.command, obj.message, (err)=>{
61
- this.adapter.sendTo(obj.from, obj.command, err, obj.callback);
62
- });
63
- }
64
- break;
65
- }
66
- }
67
- }
68
-
69
- getExcludeId(exclude_target) {
70
- return `${this.extractDeviceId(exclude_target)}`;
71
- }
72
-
73
- extractDeviceId(stateId) {
74
- if (stateId)
75
- return stateId.replace(`${this.adapter.namespace}.`, '');
76
- return '';
77
- }
78
-
79
- extractExcludeId(stateId) {
80
- return stateId.replace(`${this.adapter.namespace}.exclude.`, '');
81
- }
82
-
83
- getExcludeName(devName, stateId) {
84
- return devName.replace(` ${stateId}`, '');
85
- }
86
-
87
- async addExclude(from, command, params, callback) {
88
- try {
89
- this.debug('addExclude message: ' + JSON.stringify(params));
90
- const exclude_mod = params.exclude_model.common.type;
91
- const stateId = `exclude.${exclude_mod}`;
92
-
93
- this.adapter.setObjectNotExists(stateId,
94
- {
95
- type: 'state',
96
- common: {name: exclude_mod},
97
- }, () => {
98
- this.adapter.setState(stateId, exclude_mod, true, () => {
99
- callback();
100
- });
101
- }
102
- );
103
- } catch (error) {
104
- this.error(`Failed to addExclude ${error.stack}`);
105
- throw new Error(`Failed to addExclude ${error.stack}`);
106
- }
107
- }
108
- async delExclude(from, command, exclude_id, callback) {
109
- try {
110
- this.debug('delExclude message: ' + JSON.stringify(exclude_id));
111
- const stateId = `exclude.${exclude_id}`;
112
- this.adapter.getStateAsync(stateId)
113
- .then(async (stateV) => {
114
- this.debug('found state: ' + JSON.stringify(stateV));
115
- this.adapter.deleteState(null, 'exclude', exclude_id, async () => {
116
- callback();
117
- });
118
- });
119
- } catch (error) {
120
- this.error(`Failed to delExclude ${error.stack}`);
121
- throw new Error(`Failed to delExclude ${error.stack}`);
122
- }
123
- }
124
-
125
- getExclude(callback) {
126
- try {
127
- const exclude = [];
128
- this.adapter.getStatesOf('exclude', (err, states) => {
129
- if (!err && states) {
130
- const exc = [];
131
- states.forEach(state => {
132
- if (state._id.startsWith(`${this.adapter.namespace}.exclude`)) {
133
- exc.push(new Promise(resolve => {
134
- return this.adapter.getStateAsync(state._id)
135
- .then(stateVa => {
136
- if (stateVa !== null) {
137
- const val = {
138
- id: this.extractExcludeId(state._id),
139
- name : stateVa.val
140
- };
141
- if (this.extractExcludeId(state._id) !== 'all') {
142
- exclude.push(val);
143
- }
144
- }
145
- resolve();
146
- });
147
- }));
148
- }
149
- });
150
- return Promise.all(exc).then(() => {
151
- const arrExclude = JSON.stringify(exclude);
152
- this.debug('getExclude result: ' + arrExclude);
153
- this.adapter.setState('exclude.all', arrExclude, true, () => {
154
- callback(exclude);
155
- });
156
- });
157
- } else {
158
- this.debug('getExclude result: ' + JSON.stringify(exclude));
159
- callback(exclude);
160
- }
161
- });
162
- } catch (error) {
163
- this.error(`Failed to getExclude ${error.stack}`);
164
- }
165
- }
166
- }
167
-
168
- 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
+ /**
38
+ * @param {ioBroker.Message} obj
39
+ */
40
+ onMessage(obj) {
41
+ if (typeof obj === 'object' && obj.command) {
42
+ switch (obj.command) {
43
+ case 'addExclude':
44
+ if (obj && obj.message && typeof obj.message === 'object') {
45
+ this.addExclude(obj.from, obj.command, obj.message, (err)=>{
46
+ this.adapter.sendTo(obj.from, obj.command, err, obj.callback);
47
+ });
48
+ }
49
+ break;
50
+
51
+ case 'getExclude':
52
+ if (obj && obj.message && typeof obj.message === 'object') {
53
+ this.getExclude((exclude)=>{
54
+ this.adapter.sendTo(obj.from, obj.command, exclude, obj.callback);
55
+ });
56
+ }
57
+ break;
58
+ case 'delExclude':
59
+ if (obj && obj.message) {
60
+ this.delExclude(obj.from, obj.command, obj.message, (err)=>{
61
+ this.adapter.sendTo(obj.from, obj.command, err, obj.callback);
62
+ });
63
+ }
64
+ break;
65
+ }
66
+ }
67
+ }
68
+
69
+ getExcludeId(exclude_target) {
70
+ return `${this.extractDeviceId(exclude_target)}`;
71
+ }
72
+
73
+ extractDeviceId(stateId) {
74
+ if (stateId)
75
+ return stateId.replace(`${this.adapter.namespace}.`, '');
76
+ return '';
77
+ }
78
+
79
+ extractExcludeId(stateId) {
80
+ return stateId.replace(`${this.adapter.namespace}.exclude.`, '');
81
+ }
82
+
83
+ getExcludeName(devName, stateId) {
84
+ return devName.replace(` ${stateId}`, '');
85
+ }
86
+
87
+ async addExclude(from, command, params, callback) {
88
+ try {
89
+ this.debug('addExclude message: ' + JSON.stringify(params));
90
+ const exclude_mod = params.exclude_model.common.type;
91
+ const stateId = `exclude.${exclude_mod}`;
92
+
93
+ this.adapter.setObjectNotExists(stateId,
94
+ {
95
+ type: 'state',
96
+ common: {name: exclude_mod},
97
+ }, () => {
98
+ this.adapter.setState(stateId, exclude_mod, true, () => {
99
+ callback();
100
+ });
101
+ }
102
+ );
103
+ } catch (error) {
104
+ this.error(`Failed to addExclude ${error.stack}`);
105
+ throw new Error(`Failed to addExclude ${error.stack}`);
106
+ }
107
+ }
108
+ async delExclude(from, command, exclude_id, callback) {
109
+ try {
110
+ this.debug('delExclude message: ' + JSON.stringify(exclude_id));
111
+ const stateId = `exclude.${exclude_id}`;
112
+ this.adapter.getStateAsync(stateId)
113
+ .then(async (stateV) => {
114
+ this.debug('found state: ' + JSON.stringify(stateV));
115
+ this.adapter.deleteState(null, 'exclude', exclude_id, async () => {
116
+ callback();
117
+ });
118
+ });
119
+ } catch (error) {
120
+ this.error(`Failed to delExclude ${error.stack}`);
121
+ throw new Error(`Failed to delExclude ${error.stack}`);
122
+ }
123
+ }
124
+
125
+ getExclude(callback) {
126
+ try {
127
+ const exclude = [];
128
+ this.adapter.getStatesOf('exclude', (err, states) => {
129
+ if (!err && states) {
130
+ const exc = [];
131
+ states.forEach(state => {
132
+ if (state._id.startsWith(`${this.adapter.namespace}.exclude`)) {
133
+ exc.push(new Promise(resolve => {
134
+ return this.adapter.getStateAsync(state._id)
135
+ .then(stateVa => {
136
+ if (stateVa !== null) {
137
+ const val = {
138
+ id: this.extractExcludeId(state._id),
139
+ name : stateVa.val
140
+ };
141
+ if (this.extractExcludeId(state._id) !== 'all') {
142
+ exclude.push(val);
143
+ }
144
+ }
145
+ resolve();
146
+ });
147
+ }));
148
+ }
149
+ });
150
+ return Promise.all(exc).then(() => {
151
+ const arrExclude = JSON.stringify(exclude);
152
+ this.debug('getExclude result: ' + arrExclude);
153
+ this.adapter.setState('exclude.all', arrExclude, true, () => {
154
+ callback(exclude);
155
+ });
156
+ });
157
+ } else {
158
+ this.debug('getExclude result: ' + JSON.stringify(exclude));
159
+ callback(exclude);
160
+ }
161
+ });
162
+ } catch (error) {
163
+ this.error(`Failed to getExclude ${error.stack}`);
164
+ }
165
+ }
166
+ }
167
+
168
+ module.exports = Exclude;
package/lib/exposes.js CHANGED
@@ -772,16 +772,20 @@ function applyExposes(mappedDevices, byModel, allExcludesObj) {
772
772
  const strippedModel = (deviceDef.model) ? deviceDef.model.replace(/\0.*$/g, '').trim() : '';
773
773
  // check if device is mapped
774
774
  const existsMap = byModel.get(strippedModel);
775
-
775
+
776
776
  if ((deviceDef.hasOwnProperty('exposes') && (!existsMap || !existsMap.hasOwnProperty('states'))) || allExcludesStr.indexOf(strippedModel) > 0) {
777
- const newDevice = createFromExposes(strippedModel, deviceDef);
778
- if (!existsMap) {
779
- mappedDevices.push(newDevice);
780
- byModel.set(strippedModel, newDevice);
781
- } else {
782
- existsMap.states = newDevice.states;
783
- existsMap.exposed = true;
784
- }
777
+ try {
778
+ const newDevice = createFromExposes(strippedModel, deviceDef);
779
+ if (!existsMap) {
780
+ mappedDevices.push(newDevice);
781
+ byModel.set(strippedModel, newDevice);
782
+ } else {
783
+ existsMap.states = newDevice.states;
784
+ existsMap.exposed = true;
785
+ }
786
+ } catch (e) {
787
+ console.log(`Wrong expose devicedefinition ${deviceDef.vendor} ${deviceDef.model}` );
788
+ }
785
789
  }
786
790
  }
787
791
  }