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