iobroker.zigbee 1.8.9 → 1.8.12

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 (104) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +413 -387
  3. package/admin/adapter-settings.js +244 -244
  4. package/admin/admin.js +2981 -2961
  5. package/admin/i18n/de/translations.json +108 -108
  6. package/admin/i18n/en/translations.json +108 -108
  7. package/admin/i18n/es/translations.json +102 -102
  8. package/admin/i18n/fr/translations.json +108 -108
  9. package/admin/i18n/it/translations.json +102 -102
  10. package/admin/i18n/nl/translations.json +108 -108
  11. package/admin/i18n/pl/translations.json +108 -108
  12. package/admin/i18n/pt/translations.json +102 -102
  13. package/admin/i18n/ru/translations.json +108 -108
  14. package/admin/i18n/uk/translations.json +108 -108
  15. package/admin/i18n/zh-cn/translations.json +102 -102
  16. package/admin/img/philips_hue_lom001.png +0 -0
  17. package/admin/index.html +159 -159
  18. package/admin/index_m.html +1356 -1331
  19. package/admin/moment.min.js +1 -1
  20. package/admin/shuffle.min.js +2 -2
  21. package/admin/tab_m.html +1009 -986
  22. package/admin/vis-network.min.css +1 -1
  23. package/admin/vis-network.min.js +27 -27
  24. package/admin/words.js +110 -110
  25. package/docs/de/basedocu.md +19 -0
  26. package/docs/de/img/Bild10.png +0 -0
  27. package/docs/de/img/Bild12.png +0 -0
  28. package/docs/de/img/Bild13.png +0 -0
  29. package/docs/de/img/Bild14.png +0 -0
  30. package/docs/de/img/Bild15.png +0 -0
  31. package/docs/de/img/Bild16.png +0 -0
  32. package/docs/de/img/Bild17.png +0 -0
  33. package/docs/de/img/Bild18.png +0 -0
  34. package/docs/de/img/Bild19.png +0 -0
  35. package/docs/de/img/Bild2.png +0 -0
  36. package/docs/de/img/Bild20.png +0 -0
  37. package/docs/de/img/Bild21.png +0 -0
  38. package/docs/de/img/Bild22.png +0 -0
  39. package/docs/de/img/Bild23.png +0 -0
  40. package/docs/de/img/Bild24.png +0 -0
  41. package/docs/de/img/Bild25.png +0 -0
  42. package/docs/de/img/Bild26.png +0 -0
  43. package/docs/de/img/Bild28.png +0 -0
  44. package/docs/de/img/Bild3.png +0 -0
  45. package/docs/de/img/Bild30.png +0 -0
  46. package/docs/de/img/Bild31.png +0 -0
  47. package/docs/de/img/Bild32.png +0 -0
  48. package/docs/de/img/Bild33.png +0 -0
  49. package/docs/de/img/Bild34.png +0 -0
  50. package/docs/de/img/Bild35.png +0 -0
  51. package/docs/de/img/Bild36.png +0 -0
  52. package/docs/de/img/Bild37.png +0 -0
  53. package/docs/de/img/Bild4.png +0 -0
  54. package/docs/de/img/Bild5.jpg +0 -0
  55. package/docs/de/img/Bild6.png +0 -0
  56. package/docs/de/img/Bild7.png +0 -0
  57. package/docs/de/img/Bild8.png +0 -0
  58. package/docs/de/img/Bild9.png +0 -0
  59. package/docs/de/img/software1.jpg +0 -0
  60. package/docs/de/img/sonoff.png +0 -0
  61. package/docs/de/readme.md +126 -27
  62. package/docs/en/img/Bild13.png +0 -0
  63. package/docs/en/img/Bild18.png +0 -0
  64. package/docs/en/img/Bild23.png +0 -0
  65. package/docs/en/img/Bild25.png +0 -0
  66. package/docs/en/img/Bild26.png +0 -0
  67. package/docs/en/img/Bild4.png +0 -0
  68. package/docs/en/img/Bild9.png +0 -0
  69. package/docs/en/img/software1.jpg +0 -0
  70. package/docs/en/readme.md +128 -30
  71. package/docs/flashing_via_arduino_(en).md +110 -110
  72. package/docs/ru/readme.md +28 -28
  73. package/docs/tutorial/groups-1.png +0 -0
  74. package/docs/tutorial/groups-2.png +0 -0
  75. package/docs/tutorial/tab-dev-1.png +0 -0
  76. package/io-package.json +13 -30
  77. package/lib/backup.js +171 -171
  78. package/lib/binding.js +319 -320
  79. package/lib/colors.js +465 -465
  80. package/lib/commands.js +534 -510
  81. package/lib/developer.js +145 -145
  82. package/lib/devices.js +3135 -3135
  83. package/lib/exclude.js +162 -162
  84. package/lib/exposes.js +873 -830
  85. package/lib/groups.js +345 -340
  86. package/lib/json.js +59 -59
  87. package/lib/networkmap.js +55 -55
  88. package/lib/ota.js +198 -195
  89. package/lib/rgb.js +297 -297
  90. package/lib/seriallist.js +48 -48
  91. package/lib/states.js +6420 -6420
  92. package/lib/statescontroller.js +693 -693
  93. package/lib/tools.js +54 -54
  94. package/lib/utils.js +163 -157
  95. package/lib/zbBaseExtension.js +36 -36
  96. package/lib/zbDelayedAction.js +144 -144
  97. package/lib/zbDeviceAvailability.js +319 -319
  98. package/lib/zbDeviceConfigure.js +147 -147
  99. package/lib/zbDeviceEvent.js +48 -48
  100. package/lib/zigbeecontroller.js +989 -956
  101. package/main.js +70 -5
  102. package/package.json +11 -11
  103. package/support/docgen.js +93 -93
  104. /package/admin/img/{paumann_spot.png → paulmann_spot.png} +0 -0
package/main.js CHANGED
@@ -216,9 +216,64 @@ class Zigbee extends utils.Adapter {
216
216
  }
217
217
  const extfiles = this.config.external.split(';');
218
218
  for (const moduleName of extfiles) {
219
- if (!moduleName) {
220
- continue;
219
+ if (!moduleName) continue;
220
+ const sandbox = {
221
+ require,
222
+ module: {},
223
+ };
224
+ const mN = (fs.existsSync(moduleName) ? moduleName : this.expandFileName(moduleName).replace('.', '_'));
225
+ if (!fs.existsSync(mN)) {
226
+ this.log.warn(`External converter not loaded - neither ${moduleName} nor ${mN} exist.`)
227
+
221
228
  }
229
+ else {
230
+ const converterCode = fs.readFileSync(mN, {encoding: 'utf8'}).toString();
231
+ let converterLoaded = true;
232
+ if (converterCode.match(/..\/lib\/legacy/gm)) {
233
+ this.log.warn(`External converter ${mN} contains an unsupported reference to '/lib/legacy' - external converter not loaded.`)
234
+ converterLoaded = false;
235
+ }
236
+ else
237
+ {
238
+ // remove the require statements and attempt to place them in the sandbox
239
+ const requiredLibraries = converterCode.matchAll(/(\w+) += +require\(['"](\S+)['"]\);/gm);
240
+ for (const line of requiredLibraries) {
241
+ const movedLine = line[2].replace('..', '../zigbee-herdsman-converters')
242
+ try {
243
+ sandbox[line[1]] = require(movedLine);
244
+ }
245
+ catch (e) {
246
+ this.log.warn(`error adding ${line[1]} (${movedLine}) to the sandbox: ${e}`);
247
+ converterLoaded = false;
248
+ }
249
+ }
250
+ }
251
+ if (converterLoaded) {
252
+ this.log.info(`Apply converter from module: ${mN}`);
253
+ //this.log.warn(converterCode.replace(/const (\w+) += +require\(['"](\S+)['"]\);/gm, ''));
254
+ try {
255
+ vm.runInNewContext(converterCode.replace(/const (\w+) += +require\(['"](\S+)['"]\);/gm, ''), sandbox);
256
+ const converter = sandbox.module.exports;
257
+
258
+ if (Array.isArray(converter)) for (const item of converter) yield item;
259
+ else yield converter;
260
+ }
261
+ catch (e) {
262
+ this.log.error(`Unable to apply converter from module: ${mN} - the code does not run: ${e}`)
263
+ }
264
+ }
265
+ else
266
+ this.log.info(`Ignoring converter from module: ${mN} - see warn messages for reason`);
267
+
268
+ }
269
+ }
270
+
271
+ /* if (this.config.external === undefined) {
272
+ return;
273
+ }
274
+ const extfiles = this.config.external.split(';');
275
+ for (const moduleName of extfiles) {
276
+ if (!moduleName) continue;
222
277
  this.log.info(`Apply converter from module: ${moduleName}`);
223
278
  const sandbox = {
224
279
  require,
@@ -235,14 +290,23 @@ class Zigbee extends utils.Adapter {
235
290
  yield converter;
236
291
  }
237
292
  }
238
- }
293
+ */
294
+ }
239
295
 
240
296
  applyExternalConverters() {
297
+ try {
241
298
  for (const definition of this.getExternalDefinition()) {
242
299
  const toAdd = {...definition};
243
300
  delete toAdd['homeassistant'];
244
- zigbeeHerdsmanConverters.addDeviceDefinition(toAdd);
301
+ try {
302
+ zigbeeHerdsmanConverters.addDeviceDefinition(toAdd);
303
+ }
304
+ catch { this.log.error(`unable to apply external converter ${JSON.stringfy(toAdd)}`) }
245
305
  }
306
+ }
307
+ catch(error) {
308
+ this.log.error('error applying external converters');
309
+ }
246
310
  }
247
311
 
248
312
  async doConnect() {
@@ -503,7 +567,7 @@ class Zigbee extends utils.Adapter {
503
567
  deviceId = parseInt(deviceId);
504
568
  }
505
569
  const entity = await this.zbController.resolveEntity(deviceId);
506
- this.log.debug(`entity: ${safeJsonStringify(entity)}`);
570
+ this.log.debug(`entity: ${deviceId} ${model} ${safeJsonStringify(entity)}`);
507
571
  const mappedModel = entity.mapped;
508
572
  if (!mappedModel) {
509
573
  this.log.debug(`No mapped model for ${model}`);
@@ -851,6 +915,7 @@ class Zigbee extends utils.Adapter {
851
915
 
852
916
  onPairing(message, data) {
853
917
  if (Number.isInteger(data)) {
918
+ _pairingMode = true;
854
919
  this.setState('info.pairingCountdown', data, true);
855
920
  _pairingMode = true;
856
921
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.zigbee",
3
- "version": "1.8.9",
3
+ "version": "1.8.12",
4
4
  "author": {
5
5
  "name": "Kirov Ilya",
6
6
  "email": "kirovilya@gmail.com"
@@ -21,11 +21,11 @@
21
21
  "serialport": "^10.5.0"
22
22
  },
23
23
  "dependencies": {
24
- "@iobroker/adapter-core": "^2.6.7",
25
- "tar": "^6.1.12",
26
- "typescript": "^4.9.3",
27
- "zigbee-herdsman": "0.14.80",
28
- "zigbee-herdsman-converters": "14.0.687"
24
+ "@iobroker/adapter-core": "^2.6.8",
25
+ "tar": "^6.1.15",
26
+ "typescript": "^5.0.4",
27
+ "zigbee-herdsman": "0.16.0",
28
+ "zigbee-herdsman-converters": "15.32.0"
29
29
  },
30
30
  "description": "Zigbee devices",
31
31
  "devDependencies": {
@@ -33,17 +33,17 @@
33
33
  "@alcalzone/release-script-plugin-iobroker": "^3.5.9",
34
34
  "@alcalzone/release-script-plugin-license": "^3.5.9",
35
35
  "@iobroker/testing": "^4.1.0",
36
- "axios": "^1.2.0",
36
+ "axios": "^1.3.4",
37
37
  "chai": "^4.3.7",
38
38
  "chai-as-promised": "^7.1.1",
39
- "eslint": "^8.28.0",
40
- "eslint-config-prettier": "^8.5.0",
39
+ "eslint": "^8.41.0",
40
+ "eslint-config-prettier": "^8.8.0",
41
41
  "eslint-plugin-prettier": "^4.2.1",
42
42
  "gulp": "^4.0.2",
43
43
  "gulp-jsdoc3": "^3.0.0",
44
- "gulp-replace": "^1.1.3",
44
+ "gulp-replace": "^1.1.4",
45
45
  "mixin-deep": "^2.0.1",
46
- "mocha": "^10.1.0"
46
+ "mocha": "^10.2.0"
47
47
  },
48
48
  "homepage": "https://github.com/ioBroker/ioBroker.zigbee",
49
49
  "keywords": [
package/support/docgen.js CHANGED
@@ -1,93 +1,93 @@
1
- /**
2
- * This script generates the supported devices page.
3
- *
4
- */
5
-
6
- let devices = [...require('zigbee-herdsman-converters').devices];
7
-
8
- for (const device of devices) {
9
- if (device.whiteLabel) {
10
- for (const whiteLabel of device.whiteLabel) {
11
- const whiteLabelDevice = {
12
- ...device,
13
- model: whiteLabel.model,
14
- vendor: whiteLabel.vendor,
15
- description: whiteLabel.description,
16
- whiteLabelOf: device,
17
- };
18
-
19
- delete whiteLabelDevice.whiteLabel;
20
-
21
- devices.push(whiteLabelDevice);
22
- }
23
- }
24
- }
25
-
26
- devices = new Map(devices.map((d) => [d.model, d]));
27
-
28
- const Devices = require('../lib/devices');
29
- let iobDevices = Devices.devices;
30
- Devices.fillStatesWithExposes('');
31
-
32
- const iobCount = iobDevices.filter((d) => (!d.exposed)).length;
33
- iobDevices = new Map(iobDevices.map((d) => d.models.map((m) => [m, d])).flat());
34
-
35
- const fs = require('fs');
36
- const outputdir = process.argv[2];
37
-
38
- if (!outputdir) {
39
- console.error('Please specify an output directory');
40
- }
41
-
42
- const file = 'Supported-devices.md';
43
- let text = `*NOTE: Automatically generated by 'npm run docgen'* \n\n` +
44
- `Currently **${iobDevices.size}**(${iobCount} described in adapter) devices are supported.\n\n` +
45
- `(⭐EXP) - means that the device is presented automatically, based on the 'exposes' from the zigbee-herdsman-converters.\n\n`;
46
-
47
- const logDevices = (devmodels) => {
48
- let result = '';
49
-
50
- devmodels.forEach((devmodel) => {
51
- const iobDevice = iobDevices.get(devmodel);
52
- const device = devices.get(devmodel);
53
- const pathImg = (iobDevice.icon.startsWith('http')) ? devmodel : iobDevice.icon.replace(new RegExp('img/', 'g'), '').replace(new RegExp('.png', 'g'), '');
54
- const icon = (iobDevice.icon.startsWith('http')) ? iobDevice.icon : `https://github.com/ioBroker/ioBroker.zigbee/raw/master/admin/${iobDevice.icon}`;
55
- let brand;
56
- const models = [];
57
- let zmodels;
58
- if (device.zigbeeModel) {
59
- zmodels = device.zigbeeModel;
60
- } else {
61
- zmodels = [devmodel];
62
- }
63
- zmodels.forEach((modelId) => {
64
- const re = /[^\x20-\x7E]+/g;
65
- const model = modelId.replace(re, ' ');
66
- const desc = `${device.description} (${device.supports})`;
67
- const name = `**${device.model}${(iobDevice.exposed) ? ' (⭐EXP)': ''}**<br>`;
68
- if (brand == undefined) {
69
- brand= {
70
- name: name,
71
- desc: desc,
72
- pathImg: pathImg,
73
- };
74
- }
75
- models.push(model);
76
- });
77
- const modelsStr = models.join(', ');
78
- result += `| ${brand.name} (${modelsStr}) | ${brand.desc} | ![${brand.pathImg}](${icon}) |\n`;
79
- });
80
-
81
- return result;
82
- };
83
-
84
- const vendors = Array.from(new Set([...iobDevices.keys()].map((m) => (devices.get(m)) ? devices.get(m).vendor : null)));
85
- vendors.sort();
86
- text += '| Model | Description | Picture |\n';
87
- text += '| ------------- | ------------- | -------------------------- |\n';
88
- vendors.forEach((vendor) => {
89
- text += `| | **${vendor}** | |\n`;
90
- text += logDevices([...iobDevices.keys()].map((m) => devices.get(m)).filter((d) => d && d.vendor === vendor).map((d) => d.model));
91
- });
92
-
93
- fs.writeFileSync(outputdir + '/' + file, text);
1
+ /**
2
+ * This script generates the supported devices page.
3
+ *
4
+ */
5
+
6
+ let devices = [...require('zigbee-herdsman-converters').devices];
7
+
8
+ for (const device of devices) {
9
+ if (device.whiteLabel) {
10
+ for (const whiteLabel of device.whiteLabel) {
11
+ const whiteLabelDevice = {
12
+ ...device,
13
+ model: whiteLabel.model,
14
+ vendor: whiteLabel.vendor,
15
+ description: whiteLabel.description,
16
+ whiteLabelOf: device,
17
+ };
18
+
19
+ delete whiteLabelDevice.whiteLabel;
20
+
21
+ devices.push(whiteLabelDevice);
22
+ }
23
+ }
24
+ }
25
+
26
+ devices = new Map(devices.map((d) => [d.model, d]));
27
+
28
+ const Devices = require('../lib/devices');
29
+ let iobDevices = Devices.devices;
30
+ Devices.fillStatesWithExposes('');
31
+
32
+ const iobCount = iobDevices.filter((d) => (!d.exposed)).length;
33
+ iobDevices = new Map(iobDevices.map((d) => d.models.map((m) => [m, d])).flat());
34
+
35
+ const fs = require('fs');
36
+ const outputdir = process.argv[2];
37
+
38
+ if (!outputdir) {
39
+ console.error('Please specify an output directory');
40
+ }
41
+
42
+ const file = 'Supported-devices.md';
43
+ let text = `*NOTE: Automatically generated by 'npm run docgen'* \n\n` +
44
+ `Currently **${iobDevices.size}**(${iobCount} described in adapter) devices are supported.\n\n` +
45
+ `(⭐EXP) - means that the device is presented automatically, based on the 'exposes' from the zigbee-herdsman-converters.\n\n`;
46
+
47
+ const logDevices = (devmodels) => {
48
+ let result = '';
49
+
50
+ devmodels.forEach((devmodel) => {
51
+ const iobDevice = iobDevices.get(devmodel);
52
+ const device = devices.get(devmodel);
53
+ const pathImg = (iobDevice.icon.startsWith('http')) ? devmodel : iobDevice.icon.replace(new RegExp('img/', 'g'), '').replace(new RegExp('.png', 'g'), '');
54
+ const icon = (iobDevice.icon.startsWith('http')) ? iobDevice.icon : `https://github.com/ioBroker/ioBroker.zigbee/raw/master/admin/${iobDevice.icon}`;
55
+ let brand;
56
+ const models = [];
57
+ let zmodels;
58
+ if (device.zigbeeModel) {
59
+ zmodels = device.zigbeeModel;
60
+ } else {
61
+ zmodels = [devmodel];
62
+ }
63
+ zmodels.forEach((modelId) => {
64
+ const re = /[^\x20-\x7E]+/g;
65
+ const model = modelId.replace(re, ' ');
66
+ const desc = `${device.description} (${device.supports})`;
67
+ const name = `**${device.model}${(iobDevice.exposed) ? ' (⭐EXP)': ''}**<br>`;
68
+ if (brand == undefined) {
69
+ brand= {
70
+ name: name,
71
+ desc: desc,
72
+ pathImg: pathImg,
73
+ };
74
+ }
75
+ models.push(model);
76
+ });
77
+ const modelsStr = models.join(', ');
78
+ result += `| ${brand.name} (${modelsStr}) | ${brand.desc} | ![${brand.pathImg}](${icon}) |\n`;
79
+ });
80
+
81
+ return result;
82
+ };
83
+
84
+ const vendors = Array.from(new Set([...iobDevices.keys()].map((m) => (devices.get(m)) ? devices.get(m).vendor : null)));
85
+ vendors.sort();
86
+ text += '| Model | Description | Picture |\n';
87
+ text += '| ------------- | ------------- | -------------------------- |\n';
88
+ vendors.forEach((vendor) => {
89
+ text += `| | **${vendor}** | |\n`;
90
+ text += logDevices([...iobDevices.keys()].map((m) => devices.get(m)).filter((d) => d && d.vendor === vendor).map((d) => d.model));
91
+ });
92
+
93
+ fs.writeFileSync(outputdir + '/' + file, text);