iobroker.zigbee 1.8.18 → 1.8.20

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 (60) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +421 -415
  3. package/admin/adapter-settings.js +244 -244
  4. package/admin/admin.js +2981 -2981
  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 -1356
  19. package/admin/moment.min.js +1 -1
  20. package/admin/shuffle.min.js +2 -2
  21. package/admin/tab_m.html +1009 -1009
  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 -19
  26. package/docs/de/readme.md +126 -126
  27. package/docs/en/readme.md +128 -128
  28. package/docs/flashing_via_arduino_(en).md +110 -110
  29. package/docs/ru/readme.md +28 -28
  30. package/docs/tutorial/groups-1.png +0 -0
  31. package/docs/tutorial/groups-2.png +0 -0
  32. package/docs/tutorial/tab-dev-1.png +0 -0
  33. package/io-package.json +27 -9
  34. package/lib/backup.js +171 -171
  35. package/lib/binding.js +319 -319
  36. package/lib/colors.js +465 -465
  37. package/lib/commands.js +534 -534
  38. package/lib/developer.js +145 -145
  39. package/lib/devices.js +3135 -3135
  40. package/lib/exclude.js +162 -162
  41. package/lib/exposes.js +913 -913
  42. package/lib/groups.js +345 -345
  43. package/lib/json.js +59 -59
  44. package/lib/networkmap.js +55 -55
  45. package/lib/ota.js +198 -198
  46. package/lib/rgb.js +297 -297
  47. package/lib/seriallist.js +48 -48
  48. package/lib/states.js +6420 -6420
  49. package/lib/statescontroller.js +672 -672
  50. package/lib/tools.js +54 -54
  51. package/lib/utils.js +163 -163
  52. package/lib/zbBaseExtension.js +36 -36
  53. package/lib/zbDelayedAction.js +144 -144
  54. package/lib/zbDeviceAvailability.js +319 -319
  55. package/lib/zbDeviceConfigure.js +147 -147
  56. package/lib/zbDeviceEvent.js +48 -48
  57. package/lib/zigbeecontroller.js +989 -989
  58. package/main.js +65 -37
  59. package/package.json +6 -4
  60. package/support/docgen.js +93 -93
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;