iobroker.zigbee 3.0.0 → 3.0.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.
@@ -57,23 +57,6 @@ class StatesController extends EventEmitter {
57
57
  this.adapter.sendError(error, message);
58
58
  }
59
59
 
60
- TriggerUpload(delay) {
61
- if (this.timeoutHandleUpload) return;
62
- this.warn('triggering upload')
63
- this.timeoutHandleUpload = this.adapter.setTimeout(() => {
64
- try {
65
- this.warn('executing upload')
66
- exec('iobroker upload zigbee', (error, stdout, stderr) => {
67
- if (error) this.error('exec error: ' + JSON.stringify(error));
68
- this.warn('upload done');
69
- });
70
- }
71
- catch (error) {
72
- this.error('error on upload exec');
73
- }
74
- }, delay);
75
- }
76
-
77
60
  getStashedErrors() {
78
61
  const rv = [];
79
62
  try {
@@ -99,7 +82,7 @@ class StatesController extends EventEmitter {
99
82
 
100
83
  async AddModelFromHerdsman(device, model) {
101
84
  // this.warn('addModelFromHerdsman ' + JSON.stringify(model) + ' ' + JSON.stringify(this.localConfig.getOverrideWithKey(model, 'legacy', true)));
102
- if (this.localConfig.getOverrideWithKey(model, 'legacy', true)) {
85
+ if (this.localConfig.getOverrideWithTargetAndKey(model, 'legacy', true)) {
103
86
  this.debug('Applying legacy definition for ' + model);
104
87
  await this.addLegacyDevice(model);
105
88
  }
@@ -296,48 +279,60 @@ class StatesController extends EventEmitter {
296
279
  }
297
280
 
298
281
  }
299
- this.collectOptions(id.split('.')[2], model, options =>
282
+ this.collectOptions(id.split('.')[2], model, true, options =>
300
283
  this.publishFromState(deviceId, model, stateKey, state, options, debugId));
301
284
  }
302
285
  });
303
286
  }
304
287
  }
305
288
 
306
- async collectOptions(devId, model, callback) {
307
- const result = {};
308
- // find model states for options and get it values. No options for groups !!!
309
- const devStates = await this.getDevStates('0x' + devId, model);
310
- if (devStates == null || devStates == undefined || devStates.states == null || devStates.states == undefined) {
311
- callback(result);
312
- return;
313
- }
314
-
315
- const states = devStates.states.filter(statedesc => statedesc.isOption || statedesc.inOptions);
316
- if (states == null || states == undefined) {
317
- callback(result);
318
- return;
319
- }
320
- let cnt = 0;
289
+ async collectOptions(devId, model, getOptionStates, callback) {
321
290
  try {
322
- const len = states.length;
323
- states.forEach(statedesc => {
324
- const id = `${this.adapter.namespace}.${devId}.${statedesc.id}`;
325
- this.adapter.getState(id, (err, state) => {
326
- cnt = cnt + 1;
327
- if (!err && state) {
328
- result[statedesc.id] = state.val;
329
- }
330
- if (cnt === len) {
331
- callback(result);
332
- }
333
- });
334
- });
335
- if (!len) {
291
+ const result = this.localConfig.getOptions(devId);
292
+ if (!getOptionStates) {
336
293
  callback(result);
294
+ return;
295
+ }
296
+ // find model states for options and get it values. No options for groups !!!
297
+ const devStates = await this.getDevStates('0x' + devId, model);
298
+ if (devStates == null || devStates == undefined || devStates.states == null || devStates.states == undefined) {
299
+ callback(result);
300
+ return;
301
+ }
302
+
303
+ const states = devStates.states.filter(statedesc => statedesc.isOption || statedesc.inOptions);
304
+ if (states == null || states == undefined) {
305
+ callback(result);
306
+ return;
307
+ }
308
+ let cnt = 0;
309
+ try {
310
+ const len = states.length;
311
+ states.forEach(statedesc => {
312
+ const id = `${this.adapter.namespace}.${devId}.${statedesc.id}`;
313
+ this.adapter.getState(id, (err, state) => {
314
+ cnt = cnt + 1;
315
+ if (!err && state) {
316
+ this.debug(`collect options for ${devId}: ${JSON.stringify(result)}`);
317
+ result[statedesc.id] = state.val;
318
+ }
319
+ if (cnt === len) {
320
+ callback(result);
321
+ }
322
+ });
323
+ });
324
+ if (!len) {
325
+ callback(result);
326
+ }
327
+ } catch (error) {
328
+ this.sendError(error);
329
+ this.error(`Error collectOptions for ${devId}. Error: ${error.stack}`);
337
330
  }
338
- } catch (error) {
339
- this.sendError(error);
340
- this.error(`Error collectOptions for ${devId}. Error: ${error.stack}`);
331
+ }
332
+ catch (error) {
333
+ this.error(`Error in collectOptions for ${devId} , ${model} : ${error && error.message ? error.message : 'no message given'}`);
334
+ callback({});
335
+
341
336
  }
342
337
  }
343
338
 
@@ -1047,7 +1042,7 @@ class StatesController extends EventEmitter {
1047
1042
 
1048
1043
  } else {
1049
1044
  if (statedesc.prepublish) {
1050
- this.collectOptions(devId, model, options =>
1045
+ this.collectOptions(devId, model, false, options =>
1051
1046
  statedesc.prepublish(devId, value, newvalue => {
1052
1047
  this.updateState(devId, stateID, newvalue, common) }, options)
1053
1048
  );
@@ -1088,7 +1083,7 @@ class StatesController extends EventEmitter {
1088
1083
  };
1089
1084
 
1090
1085
  const options = await new Promise((resolve, reject) => {
1091
- this.collectOptions(devId, model, (options) => {
1086
+ this.collectOptions(devId, model, false, (options) => {
1092
1087
  resolve(options);
1093
1088
  });
1094
1089
  });
@@ -1220,10 +1215,15 @@ class StatesController extends EventEmitter {
1220
1215
  if (cluster !== '64529') {
1221
1216
  if (has_elevated_debug) this.emit('device_debug', { ID:debugId, data: { error:'EPROC', IO:true }});
1222
1217
  this.error(`Error while processing converters DEVICE_ID: '${devId}' cluster '${cluster}' type '${type}'`);
1218
+ this.error(`error message: ${error && error.message ? error.message : ''}`);
1223
1219
  }
1224
1220
  });
1225
1221
  }
1226
1222
 
1223
+ async stop() {
1224
+ this.localConfig.retainData();
1225
+ }
1226
+
1227
1227
 
1228
1228
 
1229
1229
  }
@@ -155,7 +155,7 @@ class DeviceConfigure extends BaseExtension {
155
155
  if (mappedDevice.configure === undefined) return `No configure available for ${device.ieeeAddr} ${mappedDevice.model}.`;
156
156
  this.info(`Configuring ${device.ieeeAddr} ${mappedDevice.model}`);
157
157
  this.configuring.add(device.ieeeAddr);
158
- if (typeof mappedDevice.configure === 'function') await mappedDevice.configure(device, coordinatorEndpoint, this);
158
+ if (typeof mappedDevice.configure === 'function') await mappedDevice.configure(device, coordinatorEndpoint, mappedDevice);
159
159
  else {
160
160
  const promises = [];
161
161
  promises.push(...mappedDevice.configure);
@@ -669,6 +669,7 @@ class ZigbeeController extends EventEmitter {
669
669
  if (this.HerdsmanStarted) await this.permitJoin(0);
670
670
  await this.herdsman.stop();
671
671
  this.HerdsmanStarted = false;
672
+ this.info('zigbecontroller stopped successfully');
672
673
  } catch (error) {
673
674
  this.sendError(error);
674
675
  if (this.herdsmanStarted) {
package/main.js CHANGED
@@ -809,7 +809,7 @@ class Zigbee extends utils.Adapter {
809
809
  this.emit('device_debug', { ID:debugID, data: { error: 'NOCONV',states:[{id:stateDesc.id, value:value, payload:'no converter'}] , IO:false }, message:message});
810
810
  }
811
811
  else {
812
- this.log.warn(message);
812
+ this.log.info(message);
813
813
  }
814
814
  return;
815
815
  }
@@ -1084,12 +1084,13 @@ class Zigbee extends utils.Adapter {
1084
1084
  debug.log = originalLogMethod;
1085
1085
  }
1086
1086
 
1087
- this.log.info('cleaned everything up...');
1088
- if (this.reconnectTimer) clearTimeout(this.reconnectTimer);
1087
+ this.log.info('cleaning everything up...');
1089
1088
  await this.callPluginMethod('stop');
1089
+ await this.stController.stop();
1090
1090
  if (this.zbController) {
1091
1091
  await this.zbController.stop();
1092
1092
  }
1093
+ this.log.info('cleanup successful');
1093
1094
  callback();
1094
1095
  } catch (error) {
1095
1096
  if (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.zigbee",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "author": {
5
5
  "name": "Kirov Ilya",
6
6
  "email": "kirovilya@gmail.com"
@@ -28,8 +28,8 @@
28
28
  "ajv": "^8.17.1",
29
29
  "uri-js": "^4.4.1",
30
30
  "typescript": "^5.6.3",
31
- "zigbee-herdsman": "^3.3.2",
32
- "zigbee-herdsman-converters": "^23.13.0"
31
+ "zigbee-herdsman": "3.3.2",
32
+ "zigbee-herdsman-converters": "23.13.0"
33
33
  },
34
34
  "description": "Zigbee devices",
35
35
  "devDependencies": {