iobroker.zigbee 1.7.6 → 1.8.1

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 (97) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +368 -381
  3. package/admin/admin.js +2951 -2927
  4. package/admin/i18n/de/translations.json +108 -0
  5. package/admin/i18n/en/translations.json +108 -0
  6. package/admin/i18n/es/translations.json +102 -0
  7. package/admin/i18n/fr/translations.json +108 -0
  8. package/admin/i18n/it/translations.json +102 -0
  9. package/admin/i18n/nl/translations.json +108 -0
  10. package/admin/i18n/pl/translations.json +108 -0
  11. package/admin/i18n/pt/translations.json +102 -0
  12. package/admin/i18n/ru/translations.json +108 -0
  13. package/admin/i18n/uk/translations.json +108 -0
  14. package/admin/i18n/zh-cn/translations.json +102 -0
  15. package/admin/img/philips_hue_lom001.png +0 -0
  16. package/admin/index.html +159 -159
  17. package/admin/index_m.html +1161 -1161
  18. package/admin/moment.min.js +1 -1
  19. package/admin/shuffle.min.js +2 -2
  20. package/admin/tab_m.html +985 -944
  21. package/admin/vis-network.min.css +1 -1
  22. package/admin/vis-network.min.js +27 -27
  23. package/admin/words.js +110 -110
  24. package/docs/de/img/CC2531.png +0 -0
  25. package/docs/de/img/CC2538_CC2592_PA.PNG +0 -0
  26. package/docs/de/img/CC2591.png +0 -0
  27. package/docs/de/img/boards.jpg +0 -0
  28. package/docs/de/img/cc26x2r.PNG +0 -0
  29. package/docs/de/img/results.jpg +0 -0
  30. package/docs/de/img/sku_429478_2.png +0 -0
  31. package/docs/de/img/sku_429601_2.png +0 -0
  32. package/docs/de/readme.md +27 -0
  33. package/docs/en/img/CC2531.png +0 -0
  34. package/docs/en/img/CC2591.png +0 -0
  35. package/docs/en/img/deconz.png +0 -0
  36. package/docs/en/img/sku_429478_2.png +0 -0
  37. package/docs/en/img/sku_429601_2.png +0 -0
  38. package/docs/en/readme.md +30 -0
  39. package/docs/flashing_via_arduino_(en).md +110 -0
  40. package/docs/ru/img/CC2531.png +0 -0
  41. package/docs/ru/img/CC2591.png +0 -0
  42. package/docs/ru/img/sku_429478_2.png +0 -0
  43. package/docs/ru/img/sku_429601_2.png +0 -0
  44. package/docs/ru/readme.md +28 -0
  45. package/docs/tutorial/CC2530_20190425.zip +0 -0
  46. package/docs/tutorial/CC2530_CC2591_20190515.zip +0 -0
  47. package/docs/tutorial/CC2530_CC2592_20190515.zip +0 -0
  48. package/docs/tutorial/CC2531_20190425.zip +0 -0
  49. package/docs/tutorial/adm5_1.PNG +0 -0
  50. package/docs/tutorial/adm5_2.PNG +0 -0
  51. package/docs/tutorial/cat.PNG +0 -0
  52. package/docs/tutorial/groups-1.png +0 -0
  53. package/docs/tutorial/groups-2.png +0 -0
  54. package/docs/tutorial/inst.PNG +0 -0
  55. package/docs/tutorial/reflash-finish.PNG +0 -0
  56. package/docs/tutorial/reflash-step0.png +0 -0
  57. package/docs/tutorial/reflash-step1.PNG +0 -0
  58. package/docs/tutorial/reflash-step2.PNG +0 -0
  59. package/docs/tutorial/settings.png +0 -0
  60. package/docs/tutorial/tab-dev-1.png +0 -0
  61. package/docs/tutorial/zigbee.png +0 -0
  62. package/docs/tutorial/zigbee15.png +0 -0
  63. package/io-package.json +335 -370
  64. package/lib/backup.js +171 -171
  65. package/lib/binding.js +320 -325
  66. package/lib/colors.js +465 -460
  67. package/lib/commands.js +510 -501
  68. package/lib/developer.js +145 -148
  69. package/lib/devices.js +3135 -3145
  70. package/lib/exclude.js +162 -168
  71. package/lib/exposes.js +828 -804
  72. package/lib/groups.js +340 -342
  73. package/lib/json.js +59 -60
  74. package/lib/networkmap.js +55 -56
  75. package/lib/ota.js +195 -179
  76. package/lib/rgb.js +297 -255
  77. package/lib/seriallist.js +48 -37
  78. package/lib/states.js +6405 -6416
  79. package/lib/statescontroller.js +693 -670
  80. package/lib/tools.js +54 -54
  81. package/lib/utils.js +152 -151
  82. package/lib/zbBaseExtension.js +36 -36
  83. package/lib/zbDelayedAction.js +144 -152
  84. package/lib/zbDeviceAvailability.js +319 -315
  85. package/lib/zbDeviceConfigure.js +147 -159
  86. package/lib/zbDeviceEvent.js +48 -49
  87. package/lib/zigbeecontroller.js +957 -951
  88. package/main.js +163 -147
  89. package/package.json +33 -19
  90. package/support/docgen.js +93 -93
  91. package/.eslintignore +0 -2
  92. package/.eslintrc.json +0 -37
  93. package/.github/FUNDING.yml +0 -3
  94. package/.github/stale.yml +0 -13
  95. package/.github/workflows/test-and-release.yml +0 -151
  96. package/.travis/wiki.sh +0 -28
  97. package/admin/adapter-settings.js +0 -244
package/lib/backup.js CHANGED
@@ -1,171 +1,171 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
- const pathLib = require('path');
5
-
6
- class Backup {
7
- constructor(adapter) {
8
- this.adapter = adapter;
9
- this.adapter.on('message', this.onMessage.bind(this));
10
- this.inProgress = new Set();
11
- }
12
-
13
- start(zbController, stController) {
14
- this.zbController = zbController;
15
- this.stController = stController;
16
- }
17
-
18
- stop() {
19
- delete this.zbController;
20
- delete this.stController;
21
- }
22
-
23
- info(msg) {
24
- this.adapter.log.info(msg);
25
- }
26
-
27
- warn(msg) {
28
- this.adapter.log.info(msg);
29
- }
30
-
31
- error(msg) {
32
- this.adapter.log.error(msg);
33
- }
34
-
35
- debug(msg) {
36
- this.adapter.log.debug(msg);
37
- }
38
-
39
- onMessage(obj) {
40
- if (typeof obj === 'object' && obj.command) {
41
- switch (obj.command) {
42
- case 'listbackups':
43
- this.listbackups(obj);
44
- break;
45
- case 'restore':
46
- this.restore(obj);
47
- break;
48
- }
49
- }
50
- }
51
-
52
- async configure (zigbeeOptions) {
53
- this.zigbeeOptions = zigbeeOptions;
54
- this.backup(zigbeeOptions);
55
- const allBackupFiles = this.listBackupsFiles(zigbeeOptions);
56
- this.delBackupsFiles(zigbeeOptions, allBackupFiles);
57
- }
58
-
59
- backup(options) {
60
- // backup prior database and nv data before start adapter
61
- const files = [];
62
- if (options.disableBackup) {
63
- this.info(`internal Backups are disabled`);
64
- } else {
65
- if (fs.existsSync(pathLib.join(options.dbDir, options.backupPath))) files.push(options.backupPath);
66
- if (fs.existsSync(pathLib.join(options.dbDir, options.dbPath))) files.push(options.dbPath);
67
- if (files.length == 0) return;
68
-
69
- const d = new Date();
70
- const backup_name = `${d.getFullYear()}_${('0' + (d.getMonth() + 1)).slice(-2)}_${('0' + d.getDate()).slice(-2)}-` +
71
- `${('0' + d.getHours()).slice(-2)}_${('0' + d.getMinutes()).slice(-2)}_${('0' + d.getSeconds()).slice(-2)}`;
72
- const tar = require('tar');
73
- const name = pathLib.join(options.dbDir, `backup_${backup_name}.tar.gz`);
74
- const f = fs.createWriteStream(name);
75
- f.on('finish', () => {
76
- this.debug(`Backup ${name} success`);
77
- });
78
- f.on('error', err => {
79
- this.error(`Cannot pack backup ${name}: ` + err);
80
- });
81
- try {
82
- tar.create({gzip: true, p: false, cwd: options.dbDir}, files).pipe(f);
83
- } catch (err) {
84
- this.error(`Cannot pack backup ${name}: ` + err);
85
- }
86
- }
87
- }
88
-
89
- listBackupsFiles(options) {
90
- const dir = options.dbDir;
91
- const result = [];
92
-
93
- if (fs.existsSync(dir)) {
94
- const directoryContent = fs.readdirSync(dir);
95
-
96
- let files = directoryContent.filter((filename) => {
97
- if (filename.indexOf('gz') > 0) {
98
- return fs.statSync(`${dir}/${filename}`).isFile();
99
- }
100
- });
101
-
102
- let sorted = files.sort((a, b) => {
103
- let aStat = fs.statSync(`${dir}/${a}`),
104
- bStat = fs.statSync(`${dir}/${b}`);
105
-
106
- return new Date(bStat.birthtime).getTime() - new Date(aStat.birthtime).getTime();
107
- });
108
-
109
- for (let i = 0; i < files.length; i++) {
110
- if (files[i].match(/\.tar\.gz$/i)) { // safety first
111
- result.push(files[i]);
112
- }
113
- }
114
- return result;
115
- } else {
116
- return result;
117
- }
118
- }
119
-
120
- // eslint-disable-next-line no-unused-vars
121
- delBackupsFiles(options, files) {
122
- const arr = files.length;
123
- if (arr > 10) {
124
- this.info('delete old Backup files. keep only last 10')
125
- }
126
-
127
- for (let i = 10; i < files.length; i++) {
128
- const name = options.dbDir + '/' + files[i];
129
- try {
130
- require('fs').unlinkSync(name);
131
- } catch (error) {
132
- this.error(error);
133
- }
134
- }
135
- }
136
-
137
- // eslint-disable-next-line no-unused-vars
138
- async listbackups(obj) {
139
-
140
- }
141
-
142
- async restore(options, name) {
143
- if (fs.existsSync(pathLib.join(options.dbDir, name))) {
144
- try {
145
- this.log.info('Stop herdsman');
146
- if (this.reconnectTimer) clearTimeout(this.reconnectTimer);
147
- this.callPluginMethod('stop');
148
- if (this.zbController) {
149
- await this.zbController.stop();
150
- }
151
- const tar = require('tar');
152
- try {
153
- tar.extract({file: name, cwd: options.dbDir}, err => {
154
- if (err) {
155
- this.log.error(`Cannot extract from file ${name}: ${err}`);
156
- } else {
157
- this.log.info(`Extract from file ${name} success`);
158
- }
159
- this.doConnect();
160
- });
161
- } catch (err) {
162
- this.log.error(`Cannot extrack backup ${name}: ${err}`);
163
- }
164
- } catch (error) {
165
- this.log.error(`Stop herdsman error (${error.stack})`);
166
- }
167
- }
168
- }
169
- }
170
-
171
- module.exports = Backup;
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const pathLib = require('path');
5
+
6
+ class Backup {
7
+ constructor(adapter) {
8
+ this.adapter = adapter;
9
+ this.adapter.on('message', this.onMessage.bind(this));
10
+ this.inProgress = new Set();
11
+ }
12
+
13
+ start(zbController, stController) {
14
+ this.zbController = zbController;
15
+ this.stController = stController;
16
+ }
17
+
18
+ stop() {
19
+ delete this.zbController;
20
+ delete this.stController;
21
+ }
22
+
23
+ info(msg) {
24
+ this.adapter.log.info(msg);
25
+ }
26
+
27
+ warn(msg) {
28
+ this.adapter.log.info(msg);
29
+ }
30
+
31
+ error(msg) {
32
+ this.adapter.log.error(msg);
33
+ }
34
+
35
+ debug(msg) {
36
+ this.adapter.log.debug(msg);
37
+ }
38
+
39
+ onMessage(obj) {
40
+ if (typeof obj === 'object' && obj.command) {
41
+ switch (obj.command) {
42
+ case 'listbackups':
43
+ this.listbackups(obj);
44
+ break;
45
+ case 'restore':
46
+ this.restore(obj);
47
+ break;
48
+ }
49
+ }
50
+ }
51
+
52
+ async configure(zigbeeOptions) {
53
+ this.zigbeeOptions = zigbeeOptions;
54
+ this.backup(zigbeeOptions);
55
+ const allBackupFiles = this.listBackupsFiles(zigbeeOptions);
56
+ this.delBackupsFiles(zigbeeOptions, allBackupFiles);
57
+ }
58
+
59
+ backup(options) {
60
+ // backup prior database and nv data before start adapter
61
+ const files = [];
62
+ if (options.disableBackup) {
63
+ this.info(`internal Backups are disabled`);
64
+ } else {
65
+ if (fs.existsSync(pathLib.join(options.dbDir, options.backupPath))) files.push(options.backupPath);
66
+ if (fs.existsSync(pathLib.join(options.dbDir, options.dbPath))) files.push(options.dbPath);
67
+ if (files.length == 0) return;
68
+
69
+ const d = new Date();
70
+ const backup_name = `${d.getFullYear()}_${('0' + (d.getMonth() + 1)).slice(-2)}_${('0' + d.getDate()).slice(-2)}-` +
71
+ `${('0' + d.getHours()).slice(-2)}_${('0' + d.getMinutes()).slice(-2)}_${('0' + d.getSeconds()).slice(-2)}`;
72
+ const tar = require('tar');
73
+ const name = pathLib.join(options.dbDir, `backup_${backup_name}.tar.gz`);
74
+ const f = fs.createWriteStream(name);
75
+ f.on('finish', () => {
76
+ this.debug(`Backup ${name} success`);
77
+ });
78
+ f.on('error', err => {
79
+ this.error(`Cannot pack backup ${name}: ` + err);
80
+ });
81
+ try {
82
+ tar.create({gzip: true, p: false, cwd: options.dbDir}, files).pipe(f);
83
+ } catch (err) {
84
+ this.error(`Cannot pack backup ${name}: ` + err);
85
+ }
86
+ }
87
+ }
88
+
89
+ listBackupsFiles(options) {
90
+ const dir = options.dbDir;
91
+ const result = [];
92
+
93
+ if (fs.existsSync(dir)) {
94
+ const directoryContent = fs.readdirSync(dir);
95
+
96
+ let files = directoryContent.filter((filename) => {
97
+ if (filename.indexOf('gz') > 0) {
98
+ return fs.statSync(`${dir}/${filename}`).isFile();
99
+ }
100
+ });
101
+
102
+ let sorted = files.sort((a, b) => {
103
+ let aStat = fs.statSync(`${dir}/${a}`),
104
+ bStat = fs.statSync(`${dir}/${b}`);
105
+
106
+ return new Date(bStat.birthtime).getTime() - new Date(aStat.birthtime).getTime();
107
+ });
108
+
109
+ for (let i = 0; i < files.length; i++) {
110
+ if (files[i].match(/\.tar\.gz$/i)) { // safety first
111
+ result.push(files[i]);
112
+ }
113
+ }
114
+ return result;
115
+ } else {
116
+ return result;
117
+ }
118
+ }
119
+
120
+ // eslint-disable-next-line no-unused-vars
121
+ delBackupsFiles(options, files) {
122
+ const arr = files.length;
123
+ if (arr > 10) {
124
+ this.info('delete old Backup files. keep only last 10');
125
+ }
126
+
127
+ for (let i = 10; i < files.length; i++) {
128
+ const name = options.dbDir + '/' + files[i];
129
+ try {
130
+ require('fs').unlinkSync(name);
131
+ } catch (error) {
132
+ this.error(error);
133
+ }
134
+ }
135
+ }
136
+
137
+ // eslint-disable-next-line no-unused-vars
138
+ async listbackups(obj) {
139
+
140
+ }
141
+
142
+ async restore(options, name) {
143
+ if (fs.existsSync(pathLib.join(options.dbDir, name))) {
144
+ try {
145
+ this.log.info('Stop herdsman');
146
+ if (this.reconnectTimer) clearTimeout(this.reconnectTimer);
147
+ this.callPluginMethod('stop');
148
+ if (this.zbController) {
149
+ await this.zbController.stop();
150
+ }
151
+ const tar = require('tar');
152
+ try {
153
+ tar.extract({file: name, cwd: options.dbDir}, err => {
154
+ if (err) {
155
+ this.log.error(`Cannot extract from file ${name}: ${err}`);
156
+ } else {
157
+ this.log.info(`Extract from file ${name} success`);
158
+ }
159
+ this.doConnect();
160
+ });
161
+ } catch (err) {
162
+ this.log.error(`Cannot extrack backup ${name}: ${err}`);
163
+ }
164
+ } catch (error) {
165
+ this.log.error(`Stop herdsman error (${error.stack})`);
166
+ }
167
+ }
168
+ }
169
+ }
170
+
171
+ module.exports = Backup;