iobroker.zigbee 1.8.21 → 1.8.23

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