iobroker.zigbee 1.6.15 → 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 (52) 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 -444
  9. package/admin/adapter-settings.js +244 -244
  10. package/admin/admin.js +2926 -2926
  11. package/admin/img/philips_hue_lom001.png +0 -0
  12. package/admin/index.html +159 -159
  13. package/admin/index_m.html +1158 -1158
  14. package/admin/moment.min.js +1 -1
  15. package/admin/shuffle.min.js +2 -2
  16. package/admin/tab_m.html +944 -944
  17. package/admin/vis-network.min.js +26 -26
  18. package/admin/words.js +108 -108
  19. package/docs/de/readme.md +27 -27
  20. package/docs/en/readme.md +30 -30
  21. package/docs/flashing_via_arduino_(en).md +110 -110
  22. package/docs/ru/readme.md +28 -28
  23. package/docs/tutorial/groups-1.png +0 -0
  24. package/docs/tutorial/groups-2.png +0 -0
  25. package/docs/tutorial/tab-dev-1.png +0 -0
  26. package/io-package.json +355 -348
  27. package/lib/backup.js +132 -132
  28. package/lib/binding.js +325 -325
  29. package/lib/colors.js +460 -460
  30. package/lib/commands.js +501 -501
  31. package/lib/developer.js +148 -148
  32. package/lib/devices.js +3144 -3144
  33. package/lib/exclude.js +168 -168
  34. package/lib/exposes.js +795 -795
  35. package/lib/groups.js +342 -342
  36. package/lib/json.js +60 -60
  37. package/lib/networkmap.js +56 -56
  38. package/lib/ota.js +179 -179
  39. package/lib/rgb.js +255 -255
  40. package/lib/seriallist.js +37 -37
  41. package/lib/states.js +6407 -6407
  42. package/lib/statescontroller.js +627 -627
  43. package/lib/tools.js +54 -54
  44. package/lib/utils.js +151 -151
  45. package/lib/zbBaseExtension.js +32 -32
  46. package/lib/zbDelayedAction.js +152 -152
  47. package/lib/zbDeviceAvailability.js +318 -318
  48. package/lib/zbDeviceConfigure.js +152 -152
  49. package/lib/zbDeviceEvent.js +49 -49
  50. package/lib/zigbeecontroller.js +946 -946
  51. package/package.json +77 -77
  52. 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;