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/json.js CHANGED
@@ -1,61 +1,61 @@
1
- 'use strict';
2
-
3
- const hasProp = Object.prototype.hasOwnProperty;
4
-
5
- function throwsMessage(err) {
6
- return '[Throws: ' + (err ? err.message : '?') + ']';
7
- }
8
-
9
- function safeGetValueFromPropertyOnObject(obj, property) {
10
- if (hasProp.call(obj, property)) {
11
- try {
12
- return obj[property];
13
- }
14
- catch (err) {
15
- return throwsMessage(err);
16
- }
17
- }
18
-
19
- return obj[property];
20
- }
21
-
22
- function ensureProperties(obj) {
23
- const seen = [ ]; // store references to objects we have seen before
24
-
25
- function visit(obj) {
26
- if (obj === null || typeof obj !== 'object') {
27
- return obj;
28
- }
29
-
30
- if (seen.indexOf(obj) !== -1) {
31
- return '[Circular]';
32
- }
33
- seen.push(obj);
34
-
35
- if (typeof obj.toJSON === 'function') {
36
- try {
37
- return visit(obj.toJSON());
38
- } catch(err) {
39
- return throwsMessage(err);
40
- }
41
- }
42
-
43
- if (Array.isArray(obj)) {
44
- return obj.map(visit);
45
- }
46
-
47
- return Object.keys(obj).reduce((result, prop) => {
48
- // prevent faulty defined getter properties
49
- result[prop] = visit(safeGetValueFromPropertyOnObject(obj, prop));
50
- return result;
51
- }, {});
52
- }
53
-
54
- return visit(obj);
55
- }
56
-
57
- module.exports = function (data, replacer, space) {
58
- return JSON.stringify(ensureProperties(data), replacer, space);
59
- };
60
-
1
+ 'use strict';
2
+
3
+ const hasProp = Object.prototype.hasOwnProperty;
4
+
5
+ function throwsMessage(err) {
6
+ return '[Throws: ' + (err ? err.message : '?') + ']';
7
+ }
8
+
9
+ function safeGetValueFromPropertyOnObject(obj, property) {
10
+ if (hasProp.call(obj, property)) {
11
+ try {
12
+ return obj[property];
13
+ }
14
+ catch (err) {
15
+ return throwsMessage(err);
16
+ }
17
+ }
18
+
19
+ return obj[property];
20
+ }
21
+
22
+ function ensureProperties(obj) {
23
+ const seen = [ ]; // store references to objects we have seen before
24
+
25
+ function visit(obj) {
26
+ if (obj === null || typeof obj !== 'object') {
27
+ return obj;
28
+ }
29
+
30
+ if (seen.indexOf(obj) !== -1) {
31
+ return '[Circular]';
32
+ }
33
+ seen.push(obj);
34
+
35
+ if (typeof obj.toJSON === 'function') {
36
+ try {
37
+ return visit(obj.toJSON());
38
+ } catch(err) {
39
+ return throwsMessage(err);
40
+ }
41
+ }
42
+
43
+ if (Array.isArray(obj)) {
44
+ return obj.map(visit);
45
+ }
46
+
47
+ return Object.keys(obj).reduce((result, prop) => {
48
+ // prevent faulty defined getter properties
49
+ result[prop] = visit(safeGetValueFromPropertyOnObject(obj, prop));
50
+ return result;
51
+ }, {});
52
+ }
53
+
54
+ return visit(obj);
55
+ }
56
+
57
+ module.exports = function (data, replacer, space) {
58
+ return JSON.stringify(ensureProperties(data), replacer, space);
59
+ };
60
+
61
61
  module.exports.ensureProperties = ensureProperties;
package/lib/networkmap.js CHANGED
@@ -1,57 +1,57 @@
1
- 'use strict';
2
-
3
-
4
- class NetworkMap {
5
- constructor(adapter) {
6
- this.adapter = adapter;
7
- this.adapter.on('message', this.onMessage.bind(this));
8
- }
9
-
10
- start(zbController, stController) {
11
- this.zbController = zbController;
12
- this.stController = stController;
13
- }
14
-
15
- stop() {
16
- delete this.zbController;
17
- delete this.stController;
18
- }
19
-
20
- info(msg) {
21
- this.adapter.log.info(msg);
22
- }
23
-
24
- error(msg) {
25
- this.adapter.log.error(msg);
26
- }
27
-
28
- debug(msg) {
29
- this.adapter.log.debug(msg);
30
- }
31
-
32
- /**
33
- * @param {ioBroker.Message} obj
34
- */
35
- onMessage(obj) {
36
- if (typeof obj === 'object' && obj.command) {
37
- switch (obj.command) {
38
- case 'getMap':
39
- if (obj && obj.message && typeof obj.message === 'object') {
40
- this.getMap(obj.from, obj.command, obj.callback);
41
- }
42
- break;
43
- }
44
- }
45
- }
46
-
47
- getMap(from, command, callback) {
48
- if (this.zbController) {
49
- this.zbController.getMap((networkmap) => {
50
- this.adapter.log.debug('getMap result: ' + JSON.stringify(networkmap));
51
- this.adapter.sendTo(from, command, networkmap, callback);
52
- });
53
- }
54
- }
55
- }
56
-
1
+ 'use strict';
2
+
3
+
4
+ class NetworkMap {
5
+ constructor(adapter) {
6
+ this.adapter = adapter;
7
+ this.adapter.on('message', this.onMessage.bind(this));
8
+ }
9
+
10
+ start(zbController, stController) {
11
+ this.zbController = zbController;
12
+ this.stController = stController;
13
+ }
14
+
15
+ stop() {
16
+ delete this.zbController;
17
+ delete this.stController;
18
+ }
19
+
20
+ info(msg) {
21
+ this.adapter.log.info(msg);
22
+ }
23
+
24
+ error(msg) {
25
+ this.adapter.log.error(msg);
26
+ }
27
+
28
+ debug(msg) {
29
+ this.adapter.log.debug(msg);
30
+ }
31
+
32
+ /**
33
+ * @param {ioBroker.Message} obj
34
+ */
35
+ onMessage(obj) {
36
+ if (typeof obj === 'object' && obj.command) {
37
+ switch (obj.command) {
38
+ case 'getMap':
39
+ if (obj && obj.message && typeof obj.message === 'object') {
40
+ this.getMap(obj.from, obj.command, obj.callback);
41
+ }
42
+ break;
43
+ }
44
+ }
45
+ }
46
+
47
+ getMap(from, command, callback) {
48
+ if (this.zbController) {
49
+ this.zbController.getMap((networkmap) => {
50
+ this.adapter.log.debug('getMap result: ' + JSON.stringify(networkmap));
51
+ this.adapter.sendTo(from, command, networkmap, callback);
52
+ });
53
+ }
54
+ }
55
+ }
56
+
57
57
  module.exports = NetworkMap;
package/lib/ota.js CHANGED
@@ -1,153 +1,179 @@
1
- 'use strict';
2
-
3
- const getZbId = require('./utils').getZbId;
4
-
5
- class Ota {
6
- constructor(adapter) {
7
- this.adapter = adapter;
8
- this.adapter.on('message', this.onMessage.bind(this));
9
- this.inProgress = new Set();
10
- }
11
-
12
- start(zbController, stController) {
13
- this.zbController = zbController;
14
- this.stController = stController;
15
- }
16
-
17
- stop() {
18
- delete this.zbController;
19
- delete this.stController;
20
- }
21
-
22
- info(msg) {
23
- this.adapter.log.info(msg);
24
- }
25
-
26
- warn(msg) {
27
- this.adapter.log.info(msg);
28
- }
29
-
30
- error(msg) {
31
- this.adapter.log.error(msg);
32
- }
33
-
34
- debug(msg) {
35
- this.adapter.log.debug(msg);
36
- }
37
-
38
- /**
39
- * @param {ioBroker.Message} obj
40
- */
41
- onMessage(obj) {
42
- if (typeof obj === 'object' && obj.command) {
43
- switch (obj.command) {
44
- case 'checkOtaAvail':
45
- this.checkOtaAvail(obj);
46
- break;
47
- case 'startOta':
48
- this.startOta(obj);
49
- break;
50
- }
51
- }
52
- }
53
-
54
- async checkOtaAvail(obj) {
55
- const device = await this.getDeviceForMessage(obj);
56
- if (!device) {
57
- this.debug(`Device ${obj.message.devId} is unavailable`);
58
- this.adapter.sendTo(obj.from, obj.command, {status: 'fail', device: getZbId(obj.message.devId), msg: 'Device is unavailable'}, obj.callback);
59
- return;
60
- }
61
- if (this.inProgress.has(device.device.ieeeAddr)) {
62
- this.warn(`Update or check already in progress for '${device.name}', skipping...`);
63
- return;
64
- }
65
- this.inProgress.add(device.device.ieeeAddr);
66
- const result = {status: 'unknown', device: device ? device.name : null};
67
- try {
68
- this.debug(`Checking if firmware update is available for ${device.name}`);
69
-
70
- if (device && device.mapped.ota) {
71
- const available = await device.mapped.ota.isUpdateAvailable(device.device, this);
72
- result.status = available ? 'available' : 'not_available';
73
- } else {
74
- result.status = 'not_supported';
75
- }
76
- this.debug(`Firmware update for ${device.name} is ${result.status}`);
77
- this.adapter.sendTo(obj.from, obj.command, result, obj.callback);
78
- } catch (error) {
79
- const message = `Failed to check if update available for '${device.name}' (${error.message})`;
80
- result.status = 'fail';
81
- result.msg = message;
82
- this.warn(message);
83
- this.adapter.sendTo(obj.from, obj.command, result, obj.callback);
84
- }
85
- this.inProgress.delete(device.device.ieeeAddr);
86
- }
87
-
88
- async startOta(obj) {
89
- const device = await this.getDeviceForMessage(obj);
90
- if (!device) {
91
- this.debug(`Device ${obj.message.devId} is unavailable`);
92
- this.adapter.sendTo(obj.from, obj.command, {status: 'fail', device: getZbId(obj.message.devId), msg: 'Device is unavailable'}, obj.callback);
93
- return;
94
- }
95
- if (this.inProgress.has(device.device.ieeeAddr)) {
96
- this.error(`Update or check already in progress for '${device.name}', skipping...`);
97
- return;
98
- }
99
- this.inProgress.add(device.device.ieeeAddr);
100
- const result = {status: 'unknown', device: device ? device.name : null};
101
- try {
102
- this.info('Start firmware update for '+device.name);
103
-
104
- const onProgress = (progress, remaining) => {
105
- let message = `Update of '${device.name}' at ${progress}%`;
106
- if (remaining) {
107
- message += `, +- ${Math.round(remaining / 60)} minutes remaining`;
108
- }
109
- this.info(message);
110
- };
111
-
112
- const from_ = await this.readSoftwareBuildIDAndDateCode(device.device, false);
113
- await device.mapped.ota.updateToLatest(device.device, this, onProgress);
114
- const to = await this.readSoftwareBuildIDAndDateCode(device.device, true);
115
- const [fromS, toS] = [JSON.stringify(from_), JSON.stringify(to)];
116
- result.status = 'success';
117
- result.msg = `Finished update of '${device.name}'` + (to ? `, from '${fromS}' to '${toS}'` : ``);
118
- this.info(result.msg);
119
- this.adapter.sendTo(obj.from, obj.command, result, obj.callback);
120
- } catch (error) {
121
- const message = `Update of '${device.name}' failed (${error.message})`;
122
- result.status = 'fail';
123
- result.msg = message;
124
- this.error(message);
125
- this.adapter.sendTo(obj.from, obj.command, result, obj.callback);
126
- }
127
- this.inProgress.delete(device.device.ieeeAddr);
128
- }
129
-
130
- async readSoftwareBuildIDAndDateCode(device, update) {
131
- try {
132
- const endpoint = device.endpoints.find((e) => e.supportsInputCluster('genBasic'));
133
- const result = await endpoint.read('genBasic', ['dateCode', 'swBuildId']);
134
-
135
- if (update) {
136
- device.softwareBuildID = result.swBuildId;
137
- device.dateCode = result.dateCode;
138
- device.save();
139
- }
140
-
141
- return {softwareBuildID: result.swBuildId, dateCode: result.dateCode};
142
- } catch (e) {
143
- return null;
144
- }
145
- }
146
-
147
- async getDeviceForMessage(obj) {
148
- const devId = getZbId(obj.message.devId);
149
- return this.zbController.resolveEntity(devId);
150
- }
151
- }
152
-
153
- module.exports = Ota;
1
+ 'use strict';
2
+
3
+ const getZbId = require('./utils').getZbId;
4
+
5
+ class Ota {
6
+ constructor(adapter) {
7
+ this.adapter = adapter;
8
+ this.adapter.on('message', this.onMessage.bind(this));
9
+ this.inProgress = new Set();
10
+ }
11
+
12
+ start(zbController, stController) {
13
+ this.zbController = zbController;
14
+ this.stController = stController;
15
+ }
16
+
17
+ stop() {
18
+ delete this.zbController;
19
+ delete this.stController;
20
+ }
21
+
22
+ info(msg) {
23
+ this.adapter.log.info(msg);
24
+ }
25
+
26
+ warn(msg) {
27
+ this.adapter.log.info(msg);
28
+ }
29
+
30
+ error(msg) {
31
+ this.adapter.log.error(msg);
32
+ }
33
+
34
+ debug(msg) {
35
+ this.adapter.log.debug(msg);
36
+ }
37
+
38
+ /**
39
+ * @param {ioBroker.Message} obj
40
+ */
41
+ onMessage(obj) {
42
+ if (typeof obj === 'object' && obj.command) {
43
+ switch (obj.command) {
44
+ case 'checkOtaAvail':
45
+ this.checkOtaAvail(obj);
46
+ break;
47
+ case 'startOta':
48
+ this.startOta(obj);
49
+ break;
50
+ }
51
+ }
52
+ }
53
+
54
+ async checkOtaAvail(obj) {
55
+ const device = await this.getDeviceForMessage(obj);
56
+ if (!device) {
57
+ this.debug(`Device ${obj.message.devId} is unavailable`);
58
+ this.adapter.sendTo(obj.from, obj.command, {status: 'fail', device: getZbId(obj.message.devId), msg: 'Device is unavailable'}, obj.callback);
59
+ return;
60
+ }
61
+ if (this.inProgress.has(device.device.ieeeAddr)) {
62
+ this.warn(`Update or check already in progress for '${device.name}', skipping...`);
63
+ return;
64
+ }
65
+ // do not attempt update for a device which has been deactivated or is unavailable
66
+ const stateObj = await this.adapter.getObjectAsync(obj.message.devId);
67
+ if (stateObj && stateObj.common && stateObj.common.deactivated) {
68
+ this.warn(`Device ${obj.message.devId} is deactivated, skipping...`);
69
+ this.adapter.sendTo(obj.from, obj.command, {status: 'fail', device: getZbId(obj.message.devId), msg: 'Device is deactivated'}, obj.callback);
70
+ return;
71
+ }
72
+ const availablestate = await this.adapter.getStateAsync(obj.message.devId.replace(this.namespace + '.', '') + '.available');
73
+ const lqi = await this.adapter.getStateAsync(obj.message.devId.replace(this.namespace + '.', '') + '.link_quality');
74
+ if ((availablestate && (!availablestate.val)) || (lqi && lqi.val < 1)) {
75
+ this.warn(`Device ${obj.message.devId} is marked unavailable, skipping...`);
76
+ this.adapter.sendTo(obj.from, obj.command, {status: 'fail', device: getZbId(obj.message.devId), msg: 'Device is marked unavailable'}, obj.callback);
77
+ return;
78
+ }
79
+ this.inProgress.add(device.device.ieeeAddr);
80
+ const result = {status: 'unknown', device: device ? device.name : null};
81
+ try {
82
+ this.debug(`Checking if firmware update is available for ${device.name}`);
83
+
84
+ if (device && device.mapped.ota) {
85
+ const available = await device.mapped.ota.isUpdateAvailable(device.device, this);
86
+ result.status = available ? 'available' : 'not_available';
87
+ } else {
88
+ result.status = 'not_supported';
89
+ }
90
+ this.debug(`Firmware update for ${device.name} is ${result.status}`);
91
+ this.adapter.sendTo(obj.from, obj.command, result, obj.callback);
92
+ } catch (error) {
93
+ const message = `Failed to check if update available for '${device.name}' (${error.message})`;
94
+ result.status = 'fail';
95
+ result.msg = message;
96
+ this.warn(message);
97
+ this.adapter.sendTo(obj.from, obj.command, result, obj.callback);
98
+ }
99
+ this.inProgress.delete(device.device.ieeeAddr);
100
+ }
101
+
102
+ async startOta(obj) {
103
+ const device = await this.getDeviceForMessage(obj);
104
+ if (!device) {
105
+ this.debug(`Device ${obj.message.devId} is unavailable`);
106
+ this.adapter.sendTo(obj.from, obj.command, {status: 'fail', device: getZbId(obj.message.devId), msg: 'Device is unavailable'}, obj.callback);
107
+ return;
108
+ }
109
+ if (this.inProgress.has(device.device.ieeeAddr)) {
110
+ this.error(`Update or check already in progress for '${device.name}', skipping...`);
111
+ return;
112
+ }
113
+ // do not attempt update for a device which has been deactivated or is unavailable
114
+ const stateObj = await this.adapter.getObjectAsync(obj.message.devId);
115
+ if (stateObj && stateObj.common && stateObj.common.deactivated) {
116
+ this.warn(`Device ${obj.message.devId} is deactivated, skipping...`);
117
+ return;
118
+ }
119
+ const availablestate = await this.adapter.getStateAsync(obj.message.devId.replace(this.namespace + '.', '') + '.available');
120
+ const lqi = await this.adapter.getStateAsync(obj.message.devId.replace(this.namespace + '.', '') + '.link_quality');
121
+ if ((availablestate && (!availablestate.val)) || (lqi && lqi.val < 1)) {
122
+ this.warn(`Device ${obj.message.devId} is marked unavailable, skipping...`);
123
+ return;
124
+ }
125
+ this.inProgress.add(device.device.ieeeAddr);
126
+ const result = {status: 'unknown', device: device ? device.name : null};
127
+ try {
128
+ this.info('Start firmware update for '+device.name);
129
+
130
+ const onProgress = (progress, remaining) => {
131
+ let message = `Update of '${device.name}' at ${progress}%`;
132
+ if (remaining) {
133
+ message += `, +- ${Math.round(remaining / 60)} minutes remaining`;
134
+ }
135
+ this.info(message);
136
+ };
137
+
138
+ const from_ = await this.readSoftwareBuildIDAndDateCode(device.device, false);
139
+ await device.mapped.ota.updateToLatest(device.device, this, onProgress);
140
+ const to = await this.readSoftwareBuildIDAndDateCode(device.device, true);
141
+ const [fromS, toS] = [JSON.stringify(from_), JSON.stringify(to)];
142
+ result.status = 'success';
143
+ result.msg = `Finished update of '${device.name}'` + (to ? `, from '${fromS}' to '${toS}'` : ``);
144
+ this.info(result.msg);
145
+ this.adapter.sendTo(obj.from, obj.command, result, obj.callback);
146
+ } catch (error) {
147
+ const message = `Update of '${device.name}' failed (${error.message})`;
148
+ result.status = 'fail';
149
+ result.msg = message;
150
+ this.error(message);
151
+ this.adapter.sendTo(obj.from, obj.command, result, obj.callback);
152
+ }
153
+ this.inProgress.delete(device.device.ieeeAddr);
154
+ }
155
+
156
+ async readSoftwareBuildIDAndDateCode(device, update) {
157
+ try {
158
+ const endpoint = device.endpoints.find((e) => e.supportsInputCluster('genBasic'));
159
+ const result = await endpoint.read('genBasic', ['dateCode', 'swBuildId']);
160
+
161
+ if (update) {
162
+ device.softwareBuildID = result.swBuildId;
163
+ device.dateCode = result.dateCode;
164
+ device.save();
165
+ }
166
+
167
+ return {softwareBuildID: result.swBuildId, dateCode: result.dateCode};
168
+ } catch (e) {
169
+ return null;
170
+ }
171
+ }
172
+
173
+ async getDeviceForMessage(obj) {
174
+ const devId = getZbId(obj.message.devId);
175
+ return this.zbController.resolveEntity(devId);
176
+ }
177
+ }
178
+
179
+ module.exports = Ota;