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/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,153 @@
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
+ 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;