iobroker.zigbee 1.8.1 → 1.8.3
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.
- package/.eslintignore +2 -0
- package/.eslintrc.json +37 -0
- package/.github/FUNDING.yml +3 -0
- package/.github/auto-merge.yml +17 -0
- package/.github/dependabot.yml +24 -0
- package/.github/stale.yml +13 -0
- package/.github/workflows/codeql.yml +41 -0
- package/.github/workflows/dependabot-automerge.yml +22 -0
- package/.github/workflows/test-and-release.yml +149 -0
- package/.releaseconfig.json +3 -0
- package/.travis/wiki.sh +28 -0
- package/.travis.yml +41 -0
- package/README.md +31 -8
- package/admin/admin.js +466 -482
- package/admin/i18n/de/translations.json +2 -2
- package/admin/index_m.html +1 -1
- package/admin/tab_m.html +3 -44
- package/admin/words.js +2 -2
- package/gulpfile.js +464 -0
- package/io-package.json +18 -25
- package/lib/backup.js +2 -2
- package/lib/binding.js +37 -32
- package/lib/colors.js +158 -163
- package/lib/commands.js +90 -99
- package/lib/developer.js +12 -9
- package/lib/devices.js +179 -169
- package/lib/exclude.js +36 -30
- package/lib/exposes.js +139 -163
- package/lib/groups.js +83 -81
- package/lib/json.js +6 -5
- package/lib/networkmap.js +3 -2
- package/lib/ota.js +18 -34
- package/lib/rgb.js +72 -114
- package/lib/seriallist.js +20 -25
- package/lib/states.js +526 -511
- package/lib/statescontroller.js +183 -206
- package/lib/utils.js +23 -24
- package/lib/zbBaseExtension.js +4 -4
- package/lib/zbDelayedAction.js +13 -5
- package/lib/zbDeviceAvailability.js +65 -69
- package/lib/zbDeviceConfigure.js +21 -9
- package/lib/zbDeviceEvent.js +4 -3
- package/lib/zigbeecontroller.js +103 -109
- package/main.js +147 -163
- package/package.json +15 -29
- package/test/integration.js +5 -0
- package/test/mocha.custom.opts +2 -0
- package/test/mocha.setup.js +14 -0
- package/test/package.js +5 -0
- package/test/unit.js +5 -0
- package/docs/de/img/CC2531.png +0 -0
- package/docs/de/img/CC2538_CC2592_PA.PNG +0 -0
- package/docs/de/img/CC2591.png +0 -0
- package/docs/de/img/boards.jpg +0 -0
- package/docs/de/img/cc26x2r.PNG +0 -0
- package/docs/de/img/results.jpg +0 -0
- package/docs/de/img/sku_429478_2.png +0 -0
- package/docs/de/img/sku_429601_2.png +0 -0
- package/docs/de/readme.md +0 -27
- package/docs/en/img/CC2531.png +0 -0
- package/docs/en/img/CC2591.png +0 -0
- package/docs/en/img/deconz.png +0 -0
- package/docs/en/img/sku_429478_2.png +0 -0
- package/docs/en/img/sku_429601_2.png +0 -0
- package/docs/en/readme.md +0 -30
- package/docs/flashing_via_arduino_(en).md +0 -110
- package/docs/ru/img/CC2531.png +0 -0
- package/docs/ru/img/CC2591.png +0 -0
- package/docs/ru/img/sku_429478_2.png +0 -0
- package/docs/ru/img/sku_429601_2.png +0 -0
- package/docs/ru/readme.md +0 -28
- package/docs/tutorial/CC2530_20190425.zip +0 -0
- package/docs/tutorial/CC2530_CC2591_20190515.zip +0 -0
- package/docs/tutorial/CC2530_CC2592_20190515.zip +0 -0
- package/docs/tutorial/CC2531_20190425.zip +0 -0
- package/docs/tutorial/adm5_1.PNG +0 -0
- package/docs/tutorial/adm5_2.PNG +0 -0
- package/docs/tutorial/cat.PNG +0 -0
- package/docs/tutorial/groups-1.png +0 -0
- package/docs/tutorial/groups-2.png +0 -0
- package/docs/tutorial/inst.PNG +0 -0
- package/docs/tutorial/reflash-finish.PNG +0 -0
- package/docs/tutorial/reflash-step0.png +0 -0
- package/docs/tutorial/reflash-step1.PNG +0 -0
- package/docs/tutorial/reflash-step2.PNG +0 -0
- package/docs/tutorial/settings.png +0 -0
- package/docs/tutorial/tab-dev-1.png +0 -0
- package/docs/tutorial/zigbee.png +0 -0
- package/docs/tutorial/zigbee15.png +0 -0
package/lib/commands.js
CHANGED
|
@@ -5,7 +5,7 @@ const statesMapping = require('./devices');
|
|
|
5
5
|
const disallowedDashStates = [
|
|
6
6
|
'link_quality', 'available', 'battery', 'groups', 'device_query',
|
|
7
7
|
'hue_move', 'color_temp_move', 'satuation_move', 'brightness_move', 'brightness_step', 'hue_calibration',
|
|
8
|
-
'msg_from_zigbee',
|
|
8
|
+
'msg_from_zigbee','send_payload'
|
|
9
9
|
];
|
|
10
10
|
|
|
11
11
|
class Commands {
|
|
@@ -112,6 +112,7 @@ class Commands {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
|
|
115
116
|
letsPairing(from, command, message, callback) {
|
|
116
117
|
if (this.zbController) {
|
|
117
118
|
let devId = '';
|
|
@@ -122,11 +123,11 @@ class Commands {
|
|
|
122
123
|
this.adapter.logToPairing('Pairing started ' + devId, true);
|
|
123
124
|
|
|
124
125
|
let cTimer = Number(this.adapter.config.countDown);
|
|
125
|
-
if (!this.adapter.config.countDown ||
|
|
126
|
+
if (!this.adapter.config.countDown || cTimer == 0) {
|
|
126
127
|
cTimer = 60;
|
|
127
128
|
}
|
|
128
129
|
|
|
129
|
-
this.zbController.permitJoin(cTimer, devId, err => {
|
|
130
|
+
this.zbController.permitJoin(cTimer, devId, (err) => {
|
|
130
131
|
if (!err) {
|
|
131
132
|
// set pairing mode on
|
|
132
133
|
this.adapter.setState('info.pairingMode', true);
|
|
@@ -148,7 +149,7 @@ class Commands {
|
|
|
148
149
|
this.adapter.logToPairing('Touchlink reset started ', true);
|
|
149
150
|
|
|
150
151
|
let cTimer = Number(this.adapter.config.countDown);
|
|
151
|
-
if (!this.adapter.config.countDown ||
|
|
152
|
+
if (!this.adapter.config.countDown || cTimer == 0) {
|
|
152
153
|
cTimer = 60;
|
|
153
154
|
}
|
|
154
155
|
|
|
@@ -169,51 +170,53 @@ class Commands {
|
|
|
169
170
|
const groups = {};
|
|
170
171
|
let rooms;
|
|
171
172
|
this.adapter.getEnumsAsync('enum.rooms')
|
|
172
|
-
.then(enums => {
|
|
173
|
+
.then((enums) => {
|
|
173
174
|
// rooms
|
|
174
175
|
rooms = enums['enum.rooms'];
|
|
175
176
|
})
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
177
|
+
.then(() => {
|
|
178
|
+
// get all adapter devices
|
|
179
|
+
return this.adapter.getDevicesAsync();
|
|
180
|
+
})
|
|
181
|
+
.then(async (result) => {
|
|
182
|
+
const alls = (id) ? await this.adapter.getStatesAsync(id+'.*') : await this.adapter.getStatesAsync('*');
|
|
183
|
+
const allst = (id) ? await this.adapter.getStatesOfAsync(id) : await this.adapter.getStatesOfAsync();
|
|
184
|
+
result = result.filter((item)=>!id || id == item._id);
|
|
182
185
|
// get device states and groups
|
|
183
|
-
result.forEach(async devInfo => {
|
|
186
|
+
result.forEach(async (devInfo) => {
|
|
184
187
|
if (devInfo._id) {
|
|
185
188
|
// groups
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
189
|
+
// const grState = alls[`${devInfo._id}.groups`];
|
|
190
|
+
// if (grState && grState.val) {
|
|
191
|
+
// groups[devInfo._id] = JSON.parse(grState.val);
|
|
192
|
+
// }
|
|
190
193
|
// battery and link_quality
|
|
191
194
|
const lqState = alls[`${devInfo._id}.link_quality`];
|
|
192
|
-
devInfo.link_quality = lqState ? lqState.val
|
|
193
|
-
devInfo.link_quality_lc = lqState ? lqState.lc
|
|
195
|
+
devInfo.link_quality = (lqState) ? lqState.val: undefined;
|
|
196
|
+
devInfo.link_quality_lc = (lqState) ? lqState.lc: undefined;
|
|
194
197
|
const batState = alls[`${devInfo._id}.battery`];
|
|
195
|
-
devInfo.battery = batState ? batState.val
|
|
198
|
+
devInfo.battery = (batState) ? batState.val: undefined;
|
|
196
199
|
// devInfo.states = states || {};
|
|
197
200
|
|
|
198
|
-
const states = allst.filter(item
|
|
201
|
+
const states = allst.filter((item)=>item._id.startsWith(devInfo._id));
|
|
199
202
|
|
|
200
203
|
// put only allowed states
|
|
201
|
-
devInfo.statesDef = (states || []).filter(stateDef
|
|
204
|
+
devInfo.statesDef = (states || []).filter((stateDef)=>{
|
|
202
205
|
const sid = stateDef._id;
|
|
203
206
|
const name = sid.split('.').pop();
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}).map(stateDef
|
|
207
|
+
if (disallowedDashStates.includes(name)) return false;
|
|
208
|
+
return true;
|
|
209
|
+
}).map((stateDef)=>{
|
|
207
210
|
const name = stateDef.common.name;
|
|
208
211
|
const devname = devInfo.common.name;
|
|
209
212
|
// replace state
|
|
210
213
|
return {
|
|
211
214
|
id: stateDef._id,
|
|
212
|
-
name: typeof name === 'string' ? name.replace(devname, '') : name,
|
|
215
|
+
name: (typeof name === 'string') ? name.replace(devname, '') : name,
|
|
213
216
|
type: stateDef.common.type,
|
|
214
217
|
read: stateDef.common.read,
|
|
215
218
|
write: stateDef.common.write,
|
|
216
|
-
val: alls[stateDef._id] ? alls[stateDef._id].val : undefined,
|
|
219
|
+
val: (alls[stateDef._id]) ? alls[stateDef._id].val : undefined,
|
|
217
220
|
role: stateDef.common.role,
|
|
218
221
|
unit: stateDef.common.unit,
|
|
219
222
|
states: stateDef.common.states,
|
|
@@ -223,7 +226,7 @@ class Commands {
|
|
|
223
226
|
});
|
|
224
227
|
return result;
|
|
225
228
|
})
|
|
226
|
-
.then(async result => {
|
|
229
|
+
.then(async (result) => {
|
|
227
230
|
// combine info
|
|
228
231
|
const devices = [];
|
|
229
232
|
for (const devInfo of result) {
|
|
@@ -234,38 +237,40 @@ class Commands {
|
|
|
234
237
|
const match = /zigbee.\d.group_([0-9]+)/.exec(devInfo._id);
|
|
235
238
|
if (match && match.length > 1) {
|
|
236
239
|
const groupmembers = await this.zbController.getGroupMembersFromController(match[1]);
|
|
237
|
-
this.debug(
|
|
240
|
+
this.debug('group members: ' + JSON.stringify(groupmembers));
|
|
238
241
|
if (groupmembers && groupmembers.length > 0) {
|
|
239
242
|
const memberinfo = [];
|
|
240
243
|
for (const member of groupmembers) {
|
|
241
244
|
if (groups) {
|
|
242
245
|
const grouparray = groups[member.ieee];
|
|
243
|
-
if (grouparray)
|
|
244
|
-
|
|
245
|
-
|
|
246
|
+
if (grouparray)
|
|
247
|
+
{
|
|
248
|
+
if (!grouparray.includes(match[1])) {
|
|
249
|
+
groups[member.ieee].push(match[1])
|
|
246
250
|
}
|
|
247
|
-
} else {
|
|
248
|
-
groups[member.ieee] = [match[1]];
|
|
249
251
|
}
|
|
252
|
+
else groups[member.ieee] = [match[1]];
|
|
250
253
|
}
|
|
251
|
-
const device = await this.adapter.getObjectAsync(
|
|
254
|
+
const device = await this.adapter.getObjectAsync(this.adapter.namespace + '.' + member.ieee.substr(2));
|
|
252
255
|
if (device) {
|
|
253
256
|
member.device = device.common.name;
|
|
254
|
-
}
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
255
259
|
member.device = 'unknown';
|
|
256
260
|
}
|
|
257
261
|
memberinfo.push(member);
|
|
258
262
|
}
|
|
259
263
|
devInfo.memberinfo = memberinfo;
|
|
260
|
-
this.debug(
|
|
264
|
+
this.debug('memberinfo: ' + JSON.stringify(devInfo.memberinfo));
|
|
261
265
|
}
|
|
262
266
|
}
|
|
263
|
-
}
|
|
267
|
+
}
|
|
268
|
+
else
|
|
269
|
+
{
|
|
264
270
|
const modelDesc = statesMapping.findModel(devInfo.common.type);
|
|
265
271
|
devInfo.icon = (modelDesc && modelDesc.icon) ? modelDesc.icon : 'img/unknown.png';
|
|
266
|
-
devInfo.vendor = modelDesc ? modelDesc.vendor : '';
|
|
272
|
+
devInfo.vendor = (modelDesc) ? modelDesc.vendor : '';
|
|
267
273
|
}
|
|
268
|
-
|
|
269
274
|
const id = getZbId(devInfo._id);
|
|
270
275
|
devInfo.info = await this.zbController.resolveEntity(id);
|
|
271
276
|
|
|
@@ -274,11 +279,10 @@ class Commands {
|
|
|
274
279
|
if (!rooms.hasOwnProperty(room) ||
|
|
275
280
|
!rooms[room] ||
|
|
276
281
|
!rooms[room].common ||
|
|
277
|
-
!rooms[room].common.members
|
|
278
|
-
) {
|
|
282
|
+
!rooms[room].common.members) {
|
|
279
283
|
continue;
|
|
280
284
|
}
|
|
281
|
-
if (rooms[room].common.members.
|
|
285
|
+
if (rooms[room].common.members.indexOf(devInfo._id) !== -1) {
|
|
282
286
|
devInfo.rooms.push(rooms[room].common.name);
|
|
283
287
|
}
|
|
284
288
|
}
|
|
@@ -291,20 +295,18 @@ class Commands {
|
|
|
291
295
|
.then(async (devices) => {
|
|
292
296
|
// fill group info
|
|
293
297
|
for (const groupdev in groups) {
|
|
294
|
-
|
|
295
|
-
const device = devices.find(dev =>
|
|
298
|
+
this.debug('GetDevices scanning group ' + groupdev + ' ' + JSON.stringify(groups[groupdev]))
|
|
299
|
+
const device = devices.find((dev) =>( groupdev === getZbId(dev._id) ))
|
|
296
300
|
if (device) {
|
|
297
|
-
device.groups = groups[groupdev]
|
|
298
|
-
this.debug(
|
|
301
|
+
device.groups = groups[groupdev]
|
|
302
|
+
this.debug('adding group info to device ' + groupdev);
|
|
299
303
|
}
|
|
300
304
|
}
|
|
301
305
|
// append devices that paired but not created
|
|
302
306
|
if (!id) {
|
|
303
307
|
for (const d of pairedDevices) {
|
|
304
308
|
const device = await this.zbController.resolveEntity(d.ieeeAddr);
|
|
305
|
-
if (!device)
|
|
306
|
-
continue;
|
|
307
|
-
}
|
|
309
|
+
if (!device) continue;
|
|
308
310
|
const exists = devices.find((dev) => (dev._id && device.device.ieeeAddr === getZbId(dev._id)));
|
|
309
311
|
if (!exists) {
|
|
310
312
|
devices.push({
|
|
@@ -323,11 +325,13 @@ class Commands {
|
|
|
323
325
|
}
|
|
324
326
|
return devices;
|
|
325
327
|
})
|
|
326
|
-
.then(devices => {
|
|
327
|
-
this.debug(
|
|
328
|
+
.then((devices) => {
|
|
329
|
+
this.debug('getDevices result: ' + JSON.stringify(devices));
|
|
328
330
|
this.adapter.sendTo(from, command, devices, callback);
|
|
329
331
|
})
|
|
330
|
-
.catch(err =>
|
|
332
|
+
.catch((err) => {
|
|
333
|
+
this.error('getDevices error: ' + err.stack);
|
|
334
|
+
});
|
|
331
335
|
} else {
|
|
332
336
|
this.adapter.sendTo(from, command, {error: 'You need save and run adapter before pairing!'}, callback);
|
|
333
337
|
}
|
|
@@ -348,16 +352,17 @@ class Commands {
|
|
|
348
352
|
|
|
349
353
|
const coordinatorVersion = await this.adapter.zbController.herdsman.getCoordinatorVersion();
|
|
350
354
|
|
|
351
|
-
await this.adapter.getForeignObject(
|
|
355
|
+
await this.adapter.getForeignObject('system.adapter.' + this.adapter.namespace, (err, obj) => {
|
|
352
356
|
if (!err && obj) {
|
|
353
357
|
if (obj.common.installedFrom && obj.common.installedFrom.includes('://')) {
|
|
354
358
|
const instFrom = obj.common.installedFrom;
|
|
355
|
-
coordinatorinfo.installSource = instFrom.replace('tarball',
|
|
359
|
+
coordinatorinfo.installSource = instFrom.replace('tarball','commit');
|
|
356
360
|
} else {
|
|
357
361
|
coordinatorinfo.installSource = obj.common.installedFrom;
|
|
358
362
|
}
|
|
359
363
|
}
|
|
360
|
-
try
|
|
364
|
+
try
|
|
365
|
+
{
|
|
361
366
|
coordinatorinfo.port = obj.native.port;
|
|
362
367
|
coordinatorinfo.channel = obj.native.channel;
|
|
363
368
|
coordinatorinfo.installedVersion = obj.native.version;
|
|
@@ -365,41 +370,24 @@ class Commands {
|
|
|
365
370
|
coordinatorinfo.type = coordinatorVersion.type;
|
|
366
371
|
const meta = coordinatorVersion.meta;
|
|
367
372
|
if (meta) {
|
|
368
|
-
if (meta.hasOwnProperty('revision'))
|
|
369
|
-
coordinatorinfo.revision = meta.revision;
|
|
370
|
-
}
|
|
373
|
+
if (meta.hasOwnProperty('revision')) coordinatorinfo.revision = meta.revision;
|
|
371
374
|
let vt = 'x-';
|
|
372
|
-
if (meta.hasOwnProperty('transportrev'))
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
if (meta.hasOwnProperty('
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
vt = vt + meta.majorrel + '.';
|
|
382
|
-
} else {
|
|
383
|
-
vt = vt + 'x.';
|
|
384
|
-
}
|
|
385
|
-
if (meta.hasOwnProperty('minorrel')) {
|
|
386
|
-
vt = vt + meta.minorrel + '.';
|
|
387
|
-
} else {
|
|
388
|
-
vt = vt + 'x.';
|
|
389
|
-
}
|
|
390
|
-
if (meta.hasOwnProperty('maintrel')) {
|
|
391
|
-
vt = vt + meta.maintrel + '.';
|
|
392
|
-
} else {
|
|
393
|
-
vt = vt + 'x.';
|
|
394
|
-
}
|
|
375
|
+
if (meta.hasOwnProperty('transportrev')) vt = meta.transportrev + '-';
|
|
376
|
+
if (meta.hasOwnProperty('product')) vt = vt + meta.product + '.';
|
|
377
|
+
else vt = vt + 'x.';
|
|
378
|
+
if (meta.hasOwnProperty('majorrel')) vt = vt + meta.majorrel + '.';
|
|
379
|
+
else vt = vt + 'x.';
|
|
380
|
+
if (meta.hasOwnProperty('minorrel')) vt = vt + meta.minorrel + '.';
|
|
381
|
+
else vt = vt + 'x.';
|
|
382
|
+
if (meta.hasOwnProperty('maintrel')) vt = vt + meta.maintrel + '.';
|
|
383
|
+
else vt = vt + 'x.';
|
|
395
384
|
coordinatorinfo.version = vt;
|
|
396
385
|
}
|
|
397
386
|
}
|
|
398
|
-
} catch {
|
|
399
|
-
this.warn('exception raised in getCoordinatorInfo');
|
|
400
387
|
}
|
|
388
|
+
catch { this.warn('exception raised in getCoordinatorInfo');}
|
|
401
389
|
|
|
402
|
-
this.debug(
|
|
390
|
+
this.debug('getCoorinatorInfo result: ' + JSON.stringify(coordinatorinfo));
|
|
403
391
|
this.adapter.sendTo(from, command, coordinatorinfo, callback);
|
|
404
392
|
});
|
|
405
393
|
} else {
|
|
@@ -419,26 +407,28 @@ class Commands {
|
|
|
419
407
|
|
|
420
408
|
deleteDevice(from, command, msg, callback) {
|
|
421
409
|
if (this.zbController && this.stController) {
|
|
422
|
-
this.debug(
|
|
410
|
+
this.debug('deleteDevice message: ' + JSON.stringify(msg));
|
|
423
411
|
const id = msg.id;
|
|
424
412
|
const force = msg.force;
|
|
425
413
|
const sysid = id.replace(this.adapter.namespace + '.', '0x');
|
|
426
414
|
const devId = id.replace(this.adapter.namespace + '.', '');
|
|
427
|
-
this.debug(
|
|
415
|
+
this.debug('deleteDevice sysid: ' + sysid);
|
|
428
416
|
const dev = this.zbController.getDevice(sysid);
|
|
429
417
|
if (!dev) {
|
|
430
418
|
this.debug('Not found!');
|
|
431
|
-
this.debug(
|
|
432
|
-
this.stController.deleteDeviceStates(devId, () =>
|
|
433
|
-
this.adapter.sendTo(from, command, {}, callback)
|
|
419
|
+
this.debug('Try delete dev ' + devId + ' from iobroker.');
|
|
420
|
+
this.stController.deleteDeviceStates(devId, () => {
|
|
421
|
+
this.adapter.sendTo(from, command, {}, callback);
|
|
422
|
+
});
|
|
434
423
|
return;
|
|
435
424
|
}
|
|
436
|
-
this.zbController.remove(sysid, force, err => {
|
|
425
|
+
this.zbController.remove(sysid, force, (err) => {
|
|
437
426
|
if (!err) {
|
|
438
|
-
this.stController.deleteDeviceStates(devId, () =>
|
|
439
|
-
this.adapter.sendTo(from, command, {}, callback)
|
|
427
|
+
this.stController.deleteDeviceStates(devId, () => {
|
|
428
|
+
this.adapter.sendTo(from, command, {}, callback);
|
|
429
|
+
});
|
|
440
430
|
} else {
|
|
441
|
-
this.debug(
|
|
431
|
+
this.debug('Error on remove! ' + err);
|
|
442
432
|
this.adapter.sendTo(from, command, {error: err}, callback);
|
|
443
433
|
}
|
|
444
434
|
});
|
|
@@ -463,7 +453,7 @@ class Commands {
|
|
|
463
453
|
async getChannels(from, command, message, callback) {
|
|
464
454
|
if (this.zbController) {
|
|
465
455
|
const result = await this.zbController.getChannelsEnergy();
|
|
466
|
-
this.debug(
|
|
456
|
+
this.debug('getChannels result: ' + JSON.stringify(result));
|
|
467
457
|
this.adapter.sendTo(from, command, result, callback);
|
|
468
458
|
} else {
|
|
469
459
|
this.adapter.sendTo(
|
|
@@ -476,10 +466,10 @@ class Commands {
|
|
|
476
466
|
|
|
477
467
|
async setDeviceActivated(from, command, msg, callback) {
|
|
478
468
|
if (this.stController) {
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
469
|
+
const id = msg.id;
|
|
470
|
+
const targetstate = msg.deactivated;
|
|
471
|
+
this.stController.setDeviceActivated(id, targetstate);
|
|
472
|
+
this.adapter.sendTo(from, command, {}, callback);
|
|
483
473
|
}
|
|
484
474
|
}
|
|
485
475
|
|
|
@@ -496,7 +486,8 @@ class Commands {
|
|
|
496
486
|
);
|
|
497
487
|
this.adapter.sendTo(from, command, {}, callback);
|
|
498
488
|
} catch (error) {
|
|
499
|
-
const errmsg = `Reconfigure failed ${entity.device.ieeeAddr} ${entity.device.modelID},
|
|
489
|
+
const errmsg = `Reconfigure failed ${entity.device.ieeeAddr} ${entity.device.modelID}, ` +
|
|
490
|
+
`(${error.stack})`;
|
|
500
491
|
this.error(errmsg);
|
|
501
492
|
this.adapter.sendTo(from, command, {error: errmsg}, callback);
|
|
502
493
|
}
|
package/lib/developer.js
CHANGED
|
@@ -38,8 +38,9 @@ class Developer {
|
|
|
38
38
|
if (typeof obj === 'object' && obj.command) {
|
|
39
39
|
switch (obj.command) {
|
|
40
40
|
case 'reset':
|
|
41
|
-
this.zbController.reset(obj.message.mode, err
|
|
42
|
-
this.adapter.sendTo(obj.from, obj.command, err, obj.callback)
|
|
41
|
+
this.zbController.reset(obj.message.mode, function (err) {
|
|
42
|
+
this.adapter.sendTo(obj.from, obj.command, err, obj.callback);
|
|
43
|
+
}.bind(this));
|
|
43
44
|
break;
|
|
44
45
|
case 'sendToZigbee':
|
|
45
46
|
this.sendToZigbee(obj);
|
|
@@ -91,9 +92,11 @@ class Developer {
|
|
|
91
92
|
const zclData = obj.message.zclData;
|
|
92
93
|
if (cmdType === 'functional') {
|
|
93
94
|
cmd = zcl.Utils.getCluster(cid).getCommand(obj.message.cmd);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
}
|
|
96
|
+
else if (cmdType === 'functionalResp') {
|
|
97
|
+
cmd = zcl.Utils.getCluster(cid).getCommandResponse(obj.message.cmd);
|
|
98
|
+
}
|
|
99
|
+
else if (cmdType === 'foundation') {
|
|
97
100
|
cmd = zcl.Utils.getGlobalCommand((obj.message.cmd));
|
|
98
101
|
} else {
|
|
99
102
|
this.adapter.sendTo(obj.from, obj.command, {localErr: 'Invalid cmdType'}, obj.callback);
|
|
@@ -103,7 +106,7 @@ class Developer {
|
|
|
103
106
|
|
|
104
107
|
const publishTarget = this.zbController.getDevice(devId) ? devId : this.zbController.getGroup(parseInt(devId));
|
|
105
108
|
if (!publishTarget) {
|
|
106
|
-
this.adapter.sendTo(obj.from, obj.command, {localErr:
|
|
109
|
+
this.adapter.sendTo(obj.from, obj.command, {localErr: 'Device or group ' + devId + ' not found!'}, obj.callback);
|
|
107
110
|
return;
|
|
108
111
|
}
|
|
109
112
|
if (!cid || !cmd) {
|
|
@@ -122,7 +125,7 @@ class Developer {
|
|
|
122
125
|
}
|
|
123
126
|
result.statusCode = 0;
|
|
124
127
|
this.adapter.sendTo(obj.from, obj.command, result, obj.callback);
|
|
125
|
-
},
|
|
128
|
+
},obj.message.zclSeqNum);
|
|
126
129
|
} catch (exception) {
|
|
127
130
|
// report exceptions
|
|
128
131
|
// happens for example if user tries to send write command but did not provide value/type
|
|
@@ -134,8 +137,8 @@ class Developer {
|
|
|
134
137
|
result.statusCode = exception.code;
|
|
135
138
|
this.adapter.sendTo(obj.from, obj.command, result, obj.callback);
|
|
136
139
|
} else {
|
|
137
|
-
this.error(
|
|
138
|
-
// exception (Error class) cannot be
|
|
140
|
+
this.error('SendToZigbee failed! (' + exception + ')');
|
|
141
|
+
// exception (Error class) cannot be send to adapter, send string message instead!
|
|
139
142
|
this.adapter.sendTo(obj.from, obj.command, {msg: exception.message}, obj.callback);
|
|
140
143
|
}
|
|
141
144
|
}
|