iobroker.zigbee 1.5.6 → 1.6.8

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/.devcontainer/devcontainer.json +35 -35
  2. package/.devcontainer/docker-compose.yml +51 -51
  3. package/.devcontainer/iobroker/Dockerfile +1 -1
  4. package/.devcontainer/nginx/nginx.conf +32 -32
  5. package/.devcontainer/parcel/Dockerfile +8 -8
  6. package/.devcontainer/parcel/run.sh +6 -6
  7. package/.eslintignore +1 -1
  8. package/.eslintrc.json +36 -36
  9. package/.github/FUNDING.yml +3 -3
  10. package/.github/stale.yml +13 -13
  11. package/.github/workflows/test-and-release.yml +151 -151
  12. package/.travis/wiki.sh +27 -27
  13. package/LICENSE +21 -21
  14. package/README.md +385 -353
  15. package/admin/adapter-settings.js +244 -208
  16. package/admin/admin.js +2704 -2714
  17. package/admin/img/R7060.png +0 -0
  18. package/admin/img/WHD02.png +0 -0
  19. package/admin/img/ikea_E1812.png +0 -0
  20. package/admin/img/philips_hue_lom001.png +0 -0
  21. package/admin/img/tuya_rb280.png +0 -0
  22. package/admin/index.html +159 -159
  23. package/admin/index_m.html +1055 -965
  24. package/admin/moment.min.js +1 -1
  25. package/admin/shuffle.min.js +2 -2
  26. package/admin/tab_m.html +1025 -934
  27. package/admin/vis-network.min.js +26 -26
  28. package/admin/words.js +106 -106
  29. package/docs/de/readme.md +27 -27
  30. package/docs/en/readme.md +30 -30
  31. package/docs/flashing_via_arduino_(en).md +110 -110
  32. package/docs/ru/readme.md +28 -28
  33. package/docs/tutorial/groups-1.png +0 -0
  34. package/docs/tutorial/groups-2.png +0 -0
  35. package/docs/tutorial/tab-dev-1.png +0 -0
  36. package/docs/tutorial/zigbee.png +0 -0
  37. package/io-package.json +317 -290
  38. package/lib/backup.js +132 -132
  39. package/lib/binding.js +325 -325
  40. package/lib/colors.js +460 -460
  41. package/lib/commands.js +435 -434
  42. package/lib/developer.js +148 -144
  43. package/lib/devices.js +3119 -3109
  44. package/lib/exclude.js +168 -168
  45. package/lib/exposes.js +204 -51
  46. package/lib/groups.js +316 -316
  47. package/lib/json.js +60 -60
  48. package/lib/networkmap.js +56 -56
  49. package/lib/ota.js +153 -153
  50. package/lib/rgb.js +225 -225
  51. package/lib/seriallist.js +37 -37
  52. package/lib/states.js +6381 -6322
  53. package/lib/statescontroller.js +502 -495
  54. package/lib/tools.js +54 -54
  55. package/lib/utils.js +151 -132
  56. package/lib/zbBaseExtension.js +31 -27
  57. package/lib/zbDelayedAction.js +151 -146
  58. package/lib/zbDeviceAvailability.js +306 -304
  59. package/lib/zbDeviceConfigure.js +148 -143
  60. package/lib/zbDeviceEvent.js +43 -43
  61. package/lib/zigbeecontroller.js +856 -822
  62. package/main.js +113 -39
  63. package/package.json +74 -73
  64. package/support/docgen.js +93 -93
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;