iobroker.zigbee 3.0.5 → 3.1.4

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.
@@ -39,7 +39,7 @@ class DeviceDebug extends EventEmitter {
39
39
  let flag='NONE';
40
40
  if (message.hasOwnProperty('data')) {
41
41
  const dataId = message.ID;
42
- const item = this.dataByID[dataId] ? this.dataByID[dataId] : { dataID: dataId, deviceID:'unknown', states:[],flags:[], errors:[], IO:message.IO };
42
+ const item = this.dataByID[dataId] ? this.dataByID[dataId] : { dataID: dataId, deviceID:'unknown', states:[],flags:[], errors:[], IO:message.IO, messages:{} };
43
43
  this.dataByID[dataId] = item;
44
44
  const data = message.data;
45
45
  if (data.error && item.errors.indexOf(data.error)<0) item.errors.push(data.error);
@@ -53,6 +53,11 @@ class DeviceDebug extends EventEmitter {
53
53
  else flag = item.IO ? 'I'+data.flag : 'O'+data.flag;
54
54
  else
55
55
  flag = item.IO ? 'IN' : 'OUT';
56
+ if (message.message) {
57
+ let msgIdx = 0;
58
+ while (item.messages.hasOwnProperty(`${flag}${msgIdx ? '-'+msgIdx : ''}`)) msgIdx++;
59
+ item.messages[`${flag}${msgIdx ? '-'+msgIdx : ''}`] = message.message;
60
+ }
56
61
  if (data.ID && data.ID !== item.deviceID) {
57
62
  item.deviceID = data.ID;
58
63
  const DevData = this.dataByDevice[item.deviceID] ? this.dataByDevice[item.deviceID] : { IN:[], OUT:[] };
@@ -73,9 +78,27 @@ class DeviceDebug extends EventEmitter {
73
78
  }
74
79
  }
75
80
 
76
- collectDebugData(logStatus) {
81
+ deleteMessagesFor(item) {
82
+ if (item == 'all') {
83
+ this.dataByDevice = {};
84
+ this.dataByID = {};
85
+ return;
86
+ }
87
+ delete this.dataByDevice[item];
88
+ const obsoleteIDs = [];
89
+ for (const id in this.dataByID) {
90
+ if (this.dataByID[id].deviceID === item) obsoleteIDs.push(id)
91
+ }
92
+ for (const id of obsoleteIDs) delete this.dataByID[id];
93
+ }
94
+
95
+ collectDebugData(logStatus, del) {
96
+ this.warn('collectingData')
77
97
  if (logStatus != undefined)
78
98
  this.logStatus = logStatus;
99
+ if (del) {
100
+ this.deleteMessagesFor(del);
101
+ }
79
102
  return this.dataByDevice;
80
103
  }
81
104
  }
package/lib/binding.js CHANGED
@@ -153,7 +153,7 @@ class Binding {
153
153
  if (source.endpoint.supportsOutputCluster(cluster) && targetValid) {
154
154
  this.debug(`${type}ing cluster '${cluster}' from '${sourceName}' to '${targetName}'`);
155
155
  try {
156
- const bindTarget = target.type === 'group' ? target.group : target.endpoint;
156
+ const bindTarget = target.type === 'group' ? target.device : target.endpoint;
157
157
  if (type === 'bind') {
158
158
  await source.endpoint.bind(cluster, bindTarget);
159
159
  } else {
@@ -260,18 +260,18 @@ class Binding {
260
260
  bind_target_ep = params.bind_target_ep;
261
261
  await this.doBindUnbind('unbind', bind_source, bind_source_ep, bind_target, bind_target_ep, async err => {
262
262
  if (err) {
263
- callback({error: err});
263
+ if (callback) callback({error: err});
264
264
  } else {
265
- this.adapter.deleteState(null, 'info', bind_id, async () => {
266
- // if (err) {
267
- // callback({error: err});
268
- // } else {
265
+ this.adapter.delObject(`info.${bind_id}`,{}, async (err) => {
266
+ if (err) {
267
+ if (callback) callback({error: err});
268
+ return;
269
+ }
269
270
  if (params.unbind_from_coordinator) {
270
271
  await this.doBindUnbind('bind', bind_source, bind_source_ep, 'coordinator', '1', callback);
271
272
  } else {
272
- callback();
273
+ if (callback) callback();
273
274
  }
274
- //}
275
275
  });
276
276
  }
277
277
  });