iobroker.zigbee 2.0.0 → 2.0.2
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 +40 -10
- package/admin/admin.js +312 -125
- package/admin/img/PTM 215Z.png +0 -0
- package/admin/img/group_0.png +0 -0
- package/admin/img/group_x.png +0 -0
- package/admin/img/philips_hue_lom001.png +0 -0
- package/admin/index_m.html +95 -45
- package/admin/tab_m.html +116 -48
- package/docs/de/img/Zigbee_config_de.png +0 -0
- package/docs/de/img/Zigbee_tab_de.png +0 -0
- package/docs/de/readme.md +21 -28
- package/docs/en/img/Zigbee_config_en.png +0 -0
- package/docs/en/img/Zigbee_tab_en.png +0 -0
- package/docs/tutorial/groups-1.png +0 -0
- package/docs/tutorial/groups-2.png +0 -0
- package/docs/tutorial/tab-dev-1.png +0 -0
- package/io-package.json +55 -41
- package/lib/binding.js +1 -1
- package/lib/colors.js +7 -0
- package/lib/commands.js +136 -20
- package/lib/developer.js +0 -0
- package/lib/devices.js +88 -74
- package/lib/exclude.js +30 -54
- package/lib/exposes.js +247 -290
- package/lib/groups.js +84 -29
- package/lib/localConfig.js +301 -0
- package/lib/ota.js +5 -4
- package/lib/statescontroller.js +452 -185
- package/lib/utils.js +5 -3
- package/lib/zbDeviceAvailability.js +16 -30
- package/lib/zbDeviceConfigure.js +55 -28
- package/lib/zbDeviceEvent.js +2 -13
- package/lib/zigbeecontroller.js +335 -214
- package/main.js +181 -65
- package/package.json +8 -7
package/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
*
|
|
3
3
|
* Zigbee devices adapter
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
@@ -31,6 +31,8 @@ const ZigbeeController = require('./lib/zigbeecontroller');
|
|
|
31
31
|
const StatesController = require('./lib/statescontroller');
|
|
32
32
|
const ExcludePlugin = require('./lib/exclude');
|
|
33
33
|
const zigbeeHerdsmanConverters = require('zigbee-herdsman-converters');
|
|
34
|
+
const zigbeeHerdsmanConvertersPackage = require('zigbee-herdsman-converters/package.json')
|
|
35
|
+
const zigbeeHerdsmanPackage = require('zigbee-herdsman/package.json')
|
|
34
36
|
const vm = require('vm');
|
|
35
37
|
const util = require('util');
|
|
36
38
|
const dmZigbee = require('./lib/devicemgmt.js');
|
|
@@ -68,6 +70,7 @@ class Zigbee extends utils.Adapter {
|
|
|
68
70
|
this.on('ready', () => this.onReady());
|
|
69
71
|
this.on('unload', callback => this.onUnload(callback));
|
|
70
72
|
this.on('message', obj => this.onMessage(obj));
|
|
73
|
+
this.uploadRequired = false;
|
|
71
74
|
|
|
72
75
|
this.query_device_block = [];
|
|
73
76
|
|
|
@@ -193,9 +196,8 @@ class Zigbee extends utils.Adapter {
|
|
|
193
196
|
|
|
194
197
|
// external converters
|
|
195
198
|
this.applyExternalConverters();
|
|
196
|
-
// get
|
|
197
|
-
this.
|
|
198
|
-
this.stController.getExcludeExposes(state));
|
|
199
|
+
// get devices from exposes
|
|
200
|
+
this.stController.getExposes();
|
|
199
201
|
|
|
200
202
|
this.subscribeStates('*');
|
|
201
203
|
// set connection false before connect to zigbee
|
|
@@ -218,6 +220,62 @@ class Zigbee extends utils.Adapter {
|
|
|
218
220
|
this.doConnect();
|
|
219
221
|
}
|
|
220
222
|
|
|
223
|
+
sandboxAdd(sandbox, item, module) {
|
|
224
|
+
const multipleItems = item.split(',');
|
|
225
|
+
if (multipleItems.length > 1) {
|
|
226
|
+
for(const singleItem of multipleItems) {
|
|
227
|
+
this.log.warn(`trying to add "${singleItem.trim()} = require(${module})[${singleItem.trim()}]" to sandbox`)
|
|
228
|
+
sandbox[singleItem.trim()] = require(module)[singleItem.trim()];
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
this.log.warn(`trying to add "${item} = require(${module})" to sandbox`)
|
|
233
|
+
sandbox[item] = require(module);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
SandboxRequire(sandbox, items) {
|
|
238
|
+
if (!items) return true;
|
|
239
|
+
let converterLoaded = true;
|
|
240
|
+
for (const item of items) {
|
|
241
|
+
const modulePath = item[2].replace(/['"]/gm, '');
|
|
242
|
+
|
|
243
|
+
let zhcm1 = modulePath.match(/^zigbee-herdsman-converters\//);
|
|
244
|
+
if (zhcm1) {
|
|
245
|
+
const i2 = modulePath.replace(/^zigbee-herdsman-converters\//, `../zigbee-herdsman-converters/`);
|
|
246
|
+
try {
|
|
247
|
+
this.sandboxAdd(sandbox, item[1], i2);
|
|
248
|
+
}
|
|
249
|
+
catch (error) {
|
|
250
|
+
this.log.error(`Sandbox error: ${(error && error.message ? error.message : 'no error message given')}`);
|
|
251
|
+
}
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
zhcm1 = modulePath.match(/^..\//);
|
|
255
|
+
if (zhcm1) {
|
|
256
|
+
const i2 = modulePath.replace(/^..\//, `../zigbee-herdsman-converters/`);
|
|
257
|
+
try {
|
|
258
|
+
this.sandboxAdd(sandbox, item[1], i2);
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
this.log.error(`Sandbox error: ${(error && error.message ? error.message : 'no error message given')}`);
|
|
262
|
+
converterLoaded = false;
|
|
263
|
+
}
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
try {
|
|
267
|
+
this.sandboxAdd(sandbox, item[1], modulePath);
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
this.log.error(`Sandbox error: ${(error && error.message ? error.message : 'no error message given')}`);
|
|
271
|
+
converterLoaded = false;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
}
|
|
275
|
+
return converterLoaded;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
|
|
221
279
|
* getExternalDefinition() {
|
|
222
280
|
if (this.config.external === undefined) {
|
|
223
281
|
return;
|
|
@@ -236,34 +294,48 @@ class Zigbee extends utils.Adapter {
|
|
|
236
294
|
else {
|
|
237
295
|
const converterCode = fs.readFileSync(mN, {encoding: 'utf8'}).toString();
|
|
238
296
|
let converterLoaded = true;
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
297
|
+
let modifiedCode = converterCode.replace(/\s+\/\/.+/gm, ''); // remove all lines starting with // (with the exception of the first.)
|
|
298
|
+
//fs.writeFileSync(mN+'.tmp1', modifiedCode)
|
|
299
|
+
modifiedCode = modifiedCode.replace(/^\/\/.+/gm, ''); // remove the fist line if it starts with //
|
|
300
|
+
//fs.writeFileSync(mN+'.tmp2', modifiedCode)
|
|
301
|
+
|
|
302
|
+
converterLoaded &= this.SandboxRequire(sandbox,[...modifiedCode.matchAll(/import\s+\*\s+as\s+(\S+)\s+from\s+(\S+);/gm)]);
|
|
303
|
+
modifiedCode = modifiedCode.replace(/import\s+\*\s+as\s+\S+\s+from\s+\S+;/gm, '')
|
|
304
|
+
//fs.writeFileSync(mN+'.tmp3', modifiedCode)
|
|
305
|
+
converterLoaded &= this.SandboxRequire(sandbox,[...modifiedCode.matchAll(/import\s+\{(.+)\}\s+from\s+(\S+);/gm)]);
|
|
306
|
+
modifiedCode = modifiedCode.replace(/import\s+\{.+\}\s+from\s+\S+;/gm, '');
|
|
307
|
+
|
|
308
|
+
converterLoaded &= this.SandboxRequire(sandbox,[...modifiedCode.matchAll(/import\s+(.+)\s+from\s+(\S+);/gm)]);
|
|
309
|
+
modifiedCode = modifiedCode.replace(/import\s+.+\s+from\s+\S+;/gm, '');
|
|
310
|
+
//fs.writeFileSync(mN+'.tmp4', modifiedCode)
|
|
311
|
+
converterLoaded &= this.SandboxRequire(sandbox,[...modifiedCode.matchAll(/const\s+\{(.+)\}\s+=\s+require\((.+)\)/gm)]);
|
|
312
|
+
modifiedCode = modifiedCode.replace(/const\s+\{.+\}\s+=\s+require\(.+\)/gm, '');
|
|
313
|
+
//fs.writeFileSync(mN+'.tmp5', modifiedCode)
|
|
314
|
+
converterLoaded &= this.SandboxRequire(sandbox,[...modifiedCode.matchAll(/const\s+(\S+)\s+=\s+require\((.+)\)/gm)]);
|
|
315
|
+
modifiedCode = modifiedCode.replace(/const\s+\S+\s+=\s+require\(.+\)/gm, '');
|
|
316
|
+
//fs.writeFileSync(mN+'.tmp6', modifiedCode)
|
|
317
|
+
|
|
318
|
+
for(const component of modifiedCode.matchAll(/const (.+):(.+)=/gm)) {
|
|
319
|
+
modifiedCode = modifiedCode.replace(component[0], `const ${component[1]} = `);
|
|
257
320
|
}
|
|
321
|
+
modifiedCode = modifiedCode.replace(/export .+;/gm, '');
|
|
322
|
+
|
|
323
|
+
fs.writeFileSync(mN+'.tmp', modifiedCode)
|
|
324
|
+
|
|
258
325
|
if (converterLoaded) {
|
|
259
|
-
this.log.info(`Apply converter from module: ${mN}`);
|
|
260
|
-
//this.log.warn(converterCode.replace(/const (\w+) += +require\(['"](\S+)['"]\);/gm, ''));
|
|
261
326
|
try {
|
|
262
|
-
|
|
327
|
+
this.log.warn('Trying to run sandbox for ' + mN);
|
|
328
|
+
vm.runInNewContext(modifiedCode, sandbox);
|
|
263
329
|
const converter = sandbox.module.exports;
|
|
264
330
|
|
|
265
|
-
if (Array.isArray(converter)) for (const item of converter)
|
|
266
|
-
|
|
331
|
+
if (Array.isArray(converter)) for (const item of converter) {
|
|
332
|
+
this.log.info('Model ' + item.model + ' defined in external converter ' + mN);
|
|
333
|
+
yield item;
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
this.log.info('Model ' + converter.model + ' defined in external converter ' + mN);
|
|
337
|
+
yield converter;
|
|
338
|
+
}
|
|
267
339
|
}
|
|
268
340
|
catch (e) {
|
|
269
341
|
this.log.error(`Unable to apply converter from module: ${mN} - the code does not run: ${e}`);
|
|
@@ -281,10 +353,27 @@ class Zigbee extends utils.Adapter {
|
|
|
281
353
|
const toAdd = {...definition};
|
|
282
354
|
delete toAdd['homeassistant'];
|
|
283
355
|
try {
|
|
284
|
-
zigbeeHerdsmanConverters.
|
|
356
|
+
if (zigbeeHerdsmanConverters.hasOwnProperty('addExternalDefinition')) {
|
|
357
|
+
zigbeeHerdsmanConverters.addExternalDefinition(toAdd);
|
|
358
|
+
this.log.info('added external converter using addExternalDefinition')
|
|
359
|
+
}
|
|
360
|
+
else if (zigbeeHerdsmanConverters.hasOwnProperty('addDefinition')) {
|
|
361
|
+
zigbeeHerdsmanConverters.addDefinition(toAdd);
|
|
362
|
+
this.log.info('added external converter using addDefinition')
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/*
|
|
366
|
+
for (const zigbeeModel of toAdd.zigbeeModel)
|
|
367
|
+
{
|
|
368
|
+
try {
|
|
369
|
+
zigbeeHerdsmanConverters.addToExternalDefinitionsLookup(zigbeeModel, toAdd.toAdd);
|
|
370
|
+
} catch (e) {
|
|
371
|
+
this.log.error(`unable to apply external converter ${JSON.stringify(toAdd)} for device ${zigbeeModel}: ${e && e.message ? e.message : 'no error message available'}`);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
*/
|
|
285
375
|
} catch (e) {
|
|
286
|
-
this.log.error(`unable to apply external converter ${JSON.stringify(toAdd)}`);
|
|
287
|
-
this.log.error(`${e}`);
|
|
376
|
+
this.log.error(`unable to apply external converter for ${JSON.stringify(toAdd.model)}: ${e && e.message ? e.message : 'no error message available'}`);
|
|
288
377
|
}
|
|
289
378
|
}
|
|
290
379
|
}
|
|
@@ -295,25 +384,25 @@ class Zigbee extends utils.Adapter {
|
|
|
295
384
|
const DebugIdentify = require('./debugidentify');
|
|
296
385
|
debugversion = DebugIdentify.ReportIdentifier();
|
|
297
386
|
} catch {
|
|
298
|
-
debugversion = '
|
|
387
|
+
debugversion = 'npm ...';
|
|
299
388
|
}
|
|
300
389
|
|
|
301
390
|
// installed version
|
|
302
391
|
let gitVers = '';
|
|
303
392
|
try {
|
|
304
|
-
this.log.info(`Starting
|
|
393
|
+
this.log.info(`Starting Adapter ${debugversion}`);
|
|
305
394
|
|
|
306
|
-
|
|
395
|
+
this.getForeignObject(`system.adapter.${this.namespace}`,async (err, obj) => {
|
|
307
396
|
if (!err && obj && obj.common.installedFrom && obj.common.installedFrom.includes('://')) {
|
|
308
397
|
const instFrom = obj.common.installedFrom;
|
|
309
398
|
gitVers = gitVers + instFrom.replace('tarball', 'commit');
|
|
310
399
|
} else {
|
|
311
400
|
gitVers = obj.common.installedFrom;
|
|
312
401
|
}
|
|
313
|
-
this.log.info(`Installed Version: ${gitVers}`);
|
|
402
|
+
this.log.info(`Installed Version: ${gitVers} (Converters ${zigbeeHerdsmanConvertersPackage.version} Herdsman ${zigbeeHerdsmanPackage.version})`);
|
|
403
|
+
await this.zbController.start();
|
|
314
404
|
});
|
|
315
405
|
|
|
316
|
-
await this.zbController.start();
|
|
317
406
|
} catch (error) {
|
|
318
407
|
this.setState('info.connection', false, true);
|
|
319
408
|
this.log.error(`Failed to start Zigbee`);
|
|
@@ -330,6 +419,11 @@ class Zigbee extends utils.Adapter {
|
|
|
330
419
|
}
|
|
331
420
|
}
|
|
332
421
|
|
|
422
|
+
UploadRequired(status) {
|
|
423
|
+
this.uploadRequired = (typeof status === 'boolean' ? status : this.uploadRequired) ;
|
|
424
|
+
return status;
|
|
425
|
+
}
|
|
426
|
+
|
|
333
427
|
async onZigbeeAdapterDisconnected() {
|
|
334
428
|
this.reconnectCounter = 5;
|
|
335
429
|
this.log.error('Adapter disconnected, stopping');
|
|
@@ -365,7 +459,7 @@ class Zigbee extends utils.Adapter {
|
|
|
365
459
|
const configExtPanId = this.config.extPanID ? `0x${this.config.extPanID.toLowerCase()}` : '0xdddddddddddddddd';
|
|
366
460
|
let networkExtPanId = (await this.zbController.herdsman.getNetworkParameters()).extendedPanID;
|
|
367
461
|
let needChange = false;
|
|
368
|
-
this.log.
|
|
462
|
+
this.log.info(`Config value ${configExtPanId} : Network value ${networkExtPanId}`);
|
|
369
463
|
const adapterType = this.config.adapterType || 'zstack';
|
|
370
464
|
if (adapterType === 'zstack') {
|
|
371
465
|
if (configExtPanId !== networkExtPanId) {
|
|
@@ -410,16 +504,18 @@ class Zigbee extends utils.Adapter {
|
|
|
410
504
|
}
|
|
411
505
|
}
|
|
412
506
|
|
|
413
|
-
this.setState('info.connection', true, true);
|
|
414
|
-
|
|
415
|
-
const devicesFromDB =
|
|
507
|
+
await this.setState('info.connection', true, true);
|
|
508
|
+
this.stController.CleanupRequired(false);
|
|
509
|
+
const devicesFromDB = this.zbController.getClientIterator(false);
|
|
416
510
|
for (const device of devicesFromDB) {
|
|
417
511
|
const entity = await this.zbController.resolveEntity(device);
|
|
418
512
|
if (entity) {
|
|
513
|
+
// this.log.warn('sync dev states for ' + (entity.mapped ? entity.mapped.model : entity.device.modelID));
|
|
419
514
|
const model = entity.mapped ? entity.mapped.model : entity.device.modelID;
|
|
420
515
|
this.stController.updateDev(device.ieeeAddr.substr(2), model, model, () =>
|
|
421
516
|
this.stController.syncDevStates(device, model));
|
|
422
517
|
}
|
|
518
|
+
else (this.log.warn('resolveEntity returned no entity'));
|
|
423
519
|
}
|
|
424
520
|
await this.callPluginMethod('start', [this.zbController, this.stController]);
|
|
425
521
|
}
|
|
@@ -477,7 +573,7 @@ class Zigbee extends utils.Adapter {
|
|
|
477
573
|
shortMessage.device = device.ieeeAddr;
|
|
478
574
|
shortMessage.meta = undefined;
|
|
479
575
|
shortMessage.endpoint = (message.endpoint.ID ? message.endpoint.ID: -1);
|
|
480
|
-
this.log.warn(`ELEVATED
|
|
576
|
+
this.log.warn(`ELEVATED I00: Zigbee Event of Type ${type} from device ${safeJsonStringify(device.ieeeAddr)}, incoming event: ${safeJsonStringify(shortMessage)}`);
|
|
481
577
|
}
|
|
482
578
|
// this assigment give possibility to use iobroker logger in code of the converters, via meta.logger
|
|
483
579
|
meta.logger = this.log;
|
|
@@ -561,7 +657,7 @@ class Zigbee extends utils.Adapter {
|
|
|
561
657
|
if (type !== 'readResponse') {
|
|
562
658
|
this.log.debug(`No converter available for '${mappedModel.model}' '${devId}' with cluster '${cluster}' and type '${type}'`);
|
|
563
659
|
if (has_elevated_debug)
|
|
564
|
-
this.log.warn(`ELEVATED
|
|
660
|
+
this.log.warn(`ELEVATED IE00: No converter available for '${mappedModel.model}' '${devId}' with cluster '${cluster}' and type '${type}'`);
|
|
565
661
|
}
|
|
566
662
|
return;
|
|
567
663
|
}
|
|
@@ -643,11 +739,11 @@ class Zigbee extends utils.Adapter {
|
|
|
643
739
|
}
|
|
644
740
|
try {
|
|
645
741
|
const entity = await this.zbController.resolveEntity(deviceId);
|
|
646
|
-
|
|
647
|
-
const mappedModel =
|
|
742
|
+
this.log.debug(`entity: ${deviceId} ${model} ${safeJsonStringify(entity)}`);
|
|
743
|
+
const mappedModel = entity ? entity.mapped : undefined;
|
|
648
744
|
|
|
649
745
|
if (!mappedModel) {
|
|
650
|
-
this.log.debug(`No mapped model for ${
|
|
746
|
+
this.log.debug(`No mapped model for ${model}`);
|
|
651
747
|
if (has_elevated_debug) this.log.error(`ELEVATED OE01: No mapped model ${deviceId} (model ${model})`)
|
|
652
748
|
return;
|
|
653
749
|
}
|
|
@@ -677,9 +773,17 @@ class Zigbee extends utils.Adapter {
|
|
|
677
773
|
return;
|
|
678
774
|
}
|
|
679
775
|
|
|
680
|
-
if (stateDesc.isOption) {
|
|
776
|
+
if (stateDesc.isOption || stateDesc.compositeState) {
|
|
681
777
|
// acknowledge state with given value
|
|
778
|
+
if (has_elevated_debug)
|
|
779
|
+
this.log.warn('ELEVATED OC: changed state: ' + JSON.stringify(changedState));
|
|
780
|
+
else
|
|
781
|
+
this.log.debug('changed composite state: ' + JSON.stringify(changedState));
|
|
782
|
+
|
|
682
783
|
this.acknowledgeState(deviceId, model, stateDesc, value);
|
|
784
|
+
if (stateDesc.compositeState && stateDesc.compositeTimeout) {
|
|
785
|
+
this.stController.triggerComposite(deviceId, model, stateDesc, changedState.source.includes('.admin.'));
|
|
786
|
+
}
|
|
683
787
|
// process sync state list
|
|
684
788
|
//this.processSyncStatesList(deviceId, modelId, syncStateList);
|
|
685
789
|
// if this is the device query state => trigger the device query
|
|
@@ -687,19 +791,20 @@ class Zigbee extends utils.Adapter {
|
|
|
687
791
|
// on activation of the 'device_query' state trigger hardware query where possible
|
|
688
792
|
if (stateDesc.id === 'device_query') {
|
|
689
793
|
if (this.query_device_block.indexOf(deviceId) > -1) {
|
|
690
|
-
this.log.
|
|
794
|
+
this.log.warn(`Device query for '${entity.device.ieeeAddr}' blocked`);
|
|
691
795
|
return;
|
|
692
796
|
}
|
|
693
797
|
if (mappedModel) {
|
|
694
798
|
this.query_device_block.push(deviceId);
|
|
695
799
|
if (has_elevated_debug)
|
|
696
800
|
this.log.warn(`ELEVATED O06: Device query for '${entity.device.ieeeAddr}/${entity.device.endpoints[0].ID}' triggered`);
|
|
697
|
-
|
|
801
|
+
else
|
|
802
|
+
this.log.debug(`Device query for '${entity.device.ieeeAddr}' started`);
|
|
698
803
|
for (const converter of mappedModel.toZigbee) {
|
|
699
804
|
if (converter.hasOwnProperty('convertGet')) {
|
|
700
805
|
for (const ckey of converter.key) {
|
|
701
806
|
try {
|
|
702
|
-
await converter.convertGet(entity.device.endpoints[0], ckey, {
|
|
807
|
+
await converter.convertGet(entity.device.endpoints[0], ckey, {});
|
|
703
808
|
} catch (error) {
|
|
704
809
|
if (has_elevated_debug) {
|
|
705
810
|
this.log.warn(`ELEVATED OE02.1 Failed to read state '${JSON.stringify(ckey)}'of '${entity.device.ieeeAddr}/${entity.device.endpoints[0].ID}' from query with '${error && error.message ? error.message : 'no error message'}`);
|
|
@@ -713,8 +818,7 @@ class Zigbee extends utils.Adapter {
|
|
|
713
818
|
if (has_elevated_debug)
|
|
714
819
|
this.log.warn(`ELEVATED O07: Device query for '${entity.device.ieeeAddr}/${entity.device.endpoints[0].ID}' complete`);
|
|
715
820
|
else
|
|
716
|
-
this.log.info(`Device query for '${entity.device.ieeeAddr}
|
|
717
|
-
|
|
821
|
+
this.log.info(`Device query for '${entity.device.ieeeAddr}' done`);
|
|
718
822
|
const idToRemove = deviceId;
|
|
719
823
|
setTimeout(() => {
|
|
720
824
|
const idx = this.query_device_block.indexOf(idToRemove);
|
|
@@ -729,7 +833,7 @@ class Zigbee extends utils.Adapter {
|
|
|
729
833
|
}
|
|
730
834
|
|
|
731
835
|
let converter = undefined;
|
|
732
|
-
let
|
|
836
|
+
let msg_counter = 0;
|
|
733
837
|
for (const c of mappedModel.toZigbee) {
|
|
734
838
|
|
|
735
839
|
if (!c.hasOwnProperty('convertSet')) continue;
|
|
@@ -739,23 +843,30 @@ class Zigbee extends utils.Adapter {
|
|
|
739
843
|
if (c.hasOwnProperty('convertSet') && converter === undefined)
|
|
740
844
|
{
|
|
741
845
|
converter = c;
|
|
742
|
-
if (has_elevated_debug)
|
|
743
|
-
this.log.warn(`ELEVATED
|
|
744
|
-
|
|
745
|
-
|
|
846
|
+
if (has_elevated_debug)
|
|
847
|
+
this.log.warn(`ELEVATED O04.${msg_counter}: Setting converter to keyless converter for ${deviceId} of type ${model}`)
|
|
848
|
+
else
|
|
849
|
+
this.log.debug(`Setting converter to keyless converter for ${deviceId} of type ${model}`)
|
|
850
|
+
msg_counter++;
|
|
746
851
|
}
|
|
747
852
|
else
|
|
748
853
|
{
|
|
749
|
-
if (has_elevated_debug)
|
|
750
|
-
|
|
854
|
+
if (has_elevated_debug)
|
|
855
|
+
this.log.warn(`ELEVATED O04.${msg_counter}: ignoring keyless converter for ${deviceId} of type ${model}`)
|
|
856
|
+
else
|
|
857
|
+
this.log.debug(`ignoring keyless converter for ${deviceId} of type ${model}`)
|
|
858
|
+
msg_counter++;
|
|
751
859
|
}
|
|
752
860
|
continue;
|
|
753
861
|
}
|
|
754
862
|
if (c.key.includes(stateDesc.prop) || c.key.includes(stateDesc.setattr) || c.key.includes(stateDesc.id))
|
|
755
863
|
{
|
|
756
|
-
|
|
757
|
-
|
|
864
|
+
if (has_elevated_debug)
|
|
865
|
+
this.log.warn(`ELEVATED O04.${msg_counter}: ${(converter===undefined?'Setting':'Overriding')}' converter to converter with key(s)'${JSON.stringify(c.key)}}`)
|
|
866
|
+
else
|
|
867
|
+
this.log.debug(`${(converter===undefined?'Setting':'Overriding')}' converter to converter with key(s)'${JSON.stringify(c.key)}}`)
|
|
758
868
|
converter = c;
|
|
869
|
+
msg_counter++;
|
|
759
870
|
}
|
|
760
871
|
}
|
|
761
872
|
if (converter === undefined) {
|
|
@@ -779,8 +890,10 @@ class Zigbee extends utils.Adapter {
|
|
|
779
890
|
|
|
780
891
|
const epName = stateDesc.epname !== undefined ? stateDesc.epname : (stateDesc.prop || stateDesc.id);
|
|
781
892
|
const key = stateDesc.setattr || stateDesc.prop || stateDesc.id;
|
|
782
|
-
|
|
783
|
-
|
|
893
|
+
if (has_elevated_debug)
|
|
894
|
+
this.log.warn(`ELEVATED O04: convert ${key}, ${safeJsonStringify(preparedValue)}, ${safeJsonStringify(preparedOptions)} for device ${deviceId} with Endpoint ${epName}`);
|
|
895
|
+
else
|
|
896
|
+
this.log.debug(`convert ${key}, ${safeJsonStringify(preparedValue)}, ${safeJsonStringify(preparedOptions)}`);
|
|
784
897
|
|
|
785
898
|
let target;
|
|
786
899
|
if (model === 'group') {
|
|
@@ -819,8 +932,10 @@ class Zigbee extends utils.Adapter {
|
|
|
819
932
|
|
|
820
933
|
try {
|
|
821
934
|
const result = await converter.convertSet(target, key, preparedValue, meta);
|
|
822
|
-
|
|
823
|
-
|
|
935
|
+
if (has_elevated_debug)
|
|
936
|
+
this.log.warn(`ELEVATED O05: convert result ${safeJsonStringify(result)} for device ${deviceId}`);
|
|
937
|
+
else
|
|
938
|
+
this.log.debug(`convert result ${safeJsonStringify(result)}`);
|
|
824
939
|
if (result !== undefined) {
|
|
825
940
|
if (stateModel && !isGroup) {
|
|
826
941
|
this.acknowledgeState(deviceId, model, stateDesc, value);
|
|
@@ -840,7 +955,7 @@ class Zigbee extends utils.Adapter {
|
|
|
840
955
|
}
|
|
841
956
|
});
|
|
842
957
|
} catch (err) {
|
|
843
|
-
this.log.error(`No entity for ${deviceId} : ${err && err.message ? err.message : ''}`);
|
|
958
|
+
this.log.error(`No entity for ${deviceId} : ${err && err.message ? err.message : 'no error message'}`);
|
|
844
959
|
}
|
|
845
960
|
}
|
|
846
961
|
|
|
@@ -934,6 +1049,7 @@ class Zigbee extends utils.Adapter {
|
|
|
934
1049
|
|
|
935
1050
|
newDevice(entity) {
|
|
936
1051
|
this.log.debug(`New device event: ${safeJsonStringify(entity)}`);
|
|
1052
|
+
this.stController.AddModelFromHerdsman(entity.device, entity.mapped.model)
|
|
937
1053
|
const dev = entity.device;
|
|
938
1054
|
if (dev) {
|
|
939
1055
|
this.getObject(dev.ieeeAddr.substr(2), (err, obj) => {
|
|
@@ -944,7 +1060,7 @@ class Zigbee extends utils.Adapter {
|
|
|
944
1060
|
this.stController.updateDev(dev.ieeeAddr.substr(2), model, model, () =>
|
|
945
1061
|
this.stController.syncDevStates(dev, model));
|
|
946
1062
|
}
|
|
947
|
-
|
|
1063
|
+
else this.log.debug(`Device ${safeJsonStringify(entity)} rejoined, no new device`);
|
|
948
1064
|
});
|
|
949
1065
|
}
|
|
950
1066
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iobroker.zigbee",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Kirov Ilya",
|
|
6
6
|
"email": "kirovilya@gmail.com"
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@iobroker/adapter-core": "^3.2.2",
|
|
25
|
-
"@iobroker/dm-utils": "^
|
|
25
|
+
"@iobroker/dm-utils": "^0.5.0",
|
|
26
26
|
"humanize-duration": "^3.32.1",
|
|
27
27
|
"tar": "^7.4.3",
|
|
28
28
|
"ajv": "^8.17.1",
|
|
29
29
|
"uri-js": "^4.4.1",
|
|
30
|
-
"typescript": "^5.
|
|
31
|
-
"zigbee-herdsman": "2.
|
|
32
|
-
"zigbee-herdsman-converters": "
|
|
30
|
+
"typescript": "^5.6.3",
|
|
31
|
+
"zigbee-herdsman": "3.2.7",
|
|
32
|
+
"zigbee-herdsman-converters": "21.38.0"
|
|
33
33
|
},
|
|
34
34
|
"description": "Zigbee devices",
|
|
35
35
|
"devDependencies": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"chai-as-promised": "^7.1.1",
|
|
43
43
|
"eslint": "^9.19.0",
|
|
44
44
|
"eslint-config-prettier": "^9.1.0",
|
|
45
|
-
"eslint-plugin-prettier": "^5.2.
|
|
45
|
+
"eslint-plugin-prettier": "^5.2.3",
|
|
46
46
|
"gulp": "^4.0.2",
|
|
47
47
|
"gulp-jsdoc3": "^3.0.0",
|
|
48
48
|
"gulp-replace": "^1.1.4",
|
|
@@ -91,6 +91,7 @@
|
|
|
91
91
|
"release": "release-script",
|
|
92
92
|
"release-patch": "release-script patch --yes --no-update-lockfile",
|
|
93
93
|
"release-minor": "release-script minor --yes --no-update-lockfile",
|
|
94
|
-
"release-major": "release-script major --yes --no-update-lockfile"
|
|
94
|
+
"release-major": "release-script major --yes --no-update-lockfile",
|
|
95
|
+
"dev-server": "dev-server"
|
|
95
96
|
}
|
|
96
97
|
}
|