iobroker.zigbee 3.2.4 → 3.3.0

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/main.js CHANGED
@@ -206,8 +206,6 @@ class Zigbee extends utils.Adapter {
206
206
  }
207
207
  // external converters
208
208
  this.applyExternalConverters();
209
- // get devices from exposes
210
- this.stController.getExposes();
211
209
 
212
210
  this.subscribeStates('*');
213
211
  this.subscribeForeignStates(`system.adapter.${this.namespace}.logLevel`)
@@ -629,48 +627,46 @@ class Zigbee extends utils.Adapter {
629
627
  }
630
628
 
631
629
  await this.setState('info.connection', true, true);
632
- this.stController.CleanupRequired(false);
633
- const devicesFromObjects = (await this.getDevicesAsync()).filter(item => item.native.id.length ==16).map((item) => `0x${item.native.id}`);
634
- const devicesFromDB = this.zbController.getClientIterator(false);
635
- for (const device of devicesFromDB) {
636
- const entity = await this.zbController.resolveEntity(device);
637
- if (entity) {
638
- const model = entity.mapped ? entity.mapped.model : entity.device.modelID;
639
- const idx = devicesFromObjects.indexOf(device.ieeeAddr);
640
- if (idx > -1) devicesFromObjects.splice(idx, 1);
641
- this.stController.updateDev(zbIdorIeeetoAdId(this.adapter, device.ieeeAddr, false), model, model, () =>
642
- this.stController.syncDevStates(device, model));
643
- }
644
- else (this.log.warn('resolveEntity returned no entity'));
645
- }
646
- for (const id of devicesFromObjects) {
630
+
631
+ for (const id of await this.syncAllDeviceStates(false)) {
647
632
  try {
648
- this.log.warn(`removing object for device ${id} - it is no longer in the zigbee database`);
633
+ this.log.info(`removing object for device ${id} - it is no longer in the zigbee database`);
649
634
  await this.delObjectAsync(id.substring(2), { recursive:true })
650
635
  }
651
636
  catch {
652
637
  this.log.warn(`error removing ${id}`)
653
638
  }
654
639
  }
640
+
655
641
  await this.callPluginMethod('start', [this.zbController, this.stController]);
656
642
  }
657
643
 
644
+ async syncAllDeviceStates(resetRoles) {
645
+ this.stController.CleanupRequired(false);
646
+ if (resetRoles) this.stController.clearModelDefinitions();
647
+ const devicesFromObjects = (await this.getDevicesAsync()).filter(item => item.native.id.length ==16).map((item) => `0x${item.native.id}`);
648
+ const devicesFromDB = this.zbController.getClientIterator(false);
649
+ for (const device of devicesFromDB) {
650
+ if (resetRoles) {
651
+ const hM = await zigbeeHerdsmanConverters.findByDevice(device);
652
+ await this.stController.AddModelFromHerdsman(device, hM ? hM.model : device.modelID);
653
+ }
654
+ // remove from the Adapter device list
655
+ const idx = devicesFromObjects.indexOf(device.ieeeAddr);
656
+ if (idx > -1) devicesFromObjects.splice(idx, 1);
658
657
 
659
- /*
660
- async checkIfModelUpdate(entity) {
661
- const model = entity.mapped ? entity.mapped.model : entity.device.modelID;
662
- const device = entity.device;
663
- const devId = zbIdorIeeetoAdId(this.adapter, device.ieeeAddr, false);//device.ieeeAddr.substr(2);
664
-
665
- const obj = await this.getObjectAsync(devId);
666
- if (obj && obj.common.type !== model) {
667
- // await this.stController.deleteObj(devId);
668
- await this.stController.updateDev(devId, model, model);
669
- await this.stController.syncDevStates(device, model);
670
- await this.stController.deleteOrphanedDeviceStates();
658
+ // if it has a mapped model - update its states
659
+ const entity = await this.zbController.resolveEntity(device);
660
+ if (entity) {
661
+ const model = entity.mapped ? entity.mapped.model : entity.device.modelID;
662
+ this.stController.updateDev(zbIdorIeeetoAdId(this, device.ieeeAddr, false), model, model, () =>
663
+ this.stController.syncDevStates(device, model, resetRoles));
664
+ }
665
+ else (this.log.debug('resolveEntity returned no entity'));
671
666
  }
667
+ // return the devices in the adapter namespace which do not link to an active zigbee device.
668
+ return devicesFromObjects;
672
669
  }
673
- */
674
670
 
675
671
  acknowledgeState(deviceId, model, stateDesc, value) {
676
672
  const stateId = `${zbIdorIeeetoAdId(this, deviceId, true)}.${stateDesc.id}`;
@@ -698,24 +694,24 @@ class Zigbee extends utils.Adapter {
698
694
 
699
695
  if (this.debugActive) this.log.debug(`New device event: ${safeJsonStringify(entity)}`);
700
696
 
701
- const dev = entity.device;
702
- const model = (entity.mapped) ? entity.mapped.model : dev.modelID;
697
+ const device = entity.device;
698
+ const model = (entity.mapped) ? entity.mapped.model : device.modelID;
703
699
  this.log.debug(`New device event: ${safeJsonStringify(entity)}`);
704
700
  if (!entity.mapped && !entity.device.interviewing) {
705
- const msg = `New device: '${dev.ieeeAddr}' does not have a known model. please provide an external converter for '${dev.modelID}'.`;
701
+ const msg = `New device: '${device.ieeeAddr}' does not have a known model. please provide an external converter for '${device.modelID}'.`;
706
702
  this.log.warn(msg);
707
703
  this.logToPairing(msg, true);
708
704
  }
709
705
  await this.stController.AddModelFromHerdsman(entity.device, model)
710
- if (dev) {
711
- this.getObject(zbIdorIeeetoAdId(this.adapter, dev.ieeeAddr, false), (err, obj) => {
706
+ if (device) {
707
+ this.getObject(zbIdorIeeetoAdId(this, device.ieeeAddr, false), (err, obj) => {
712
708
  if (!obj) {
713
709
  const model = (entity.mapped) ? entity.mapped.model : entity.device.modelID;
714
- if (this.debugActive) this.log.debug(`new device ${dev.ieeeAddr} ${dev.networkAddress} ${model} `);
710
+ if (this.debugActive) this.log.debug(`new device ${device.ieeeAddr} ${device.networkAddress} ${model} `);
715
711
 
716
- this.logToPairing(`New device joined '${dev.ieeeAddr}' model ${model}`, true);
717
- this.stController.updateDev(zbIdorIeeetoAdId(this.adapter, dev.ieeeAddr, false), model, model, () =>
718
- this.stController.syncDevStates(dev, model));
712
+ this.logToPairing(`New device joined '${device.ieeeAddr}' model ${model}`, true);
713
+ this.stController.updateDev(zbIdorIeeetoAdId(this, device.ieeeAddr, false), model, model, () =>
714
+ this.stController.syncDevStates(device, model, false));
719
715
  }
720
716
  else if (this.debugActive) this.log.debug(`Device ${safeJsonStringify(entity)} rejoined, no new device`);
721
717
  });
@@ -725,7 +721,7 @@ class Zigbee extends utils.Adapter {
725
721
  leaveDevice(ieeeAddr) {
726
722
  if (this.debugActive) this.log.debug(`Leave device event: ${ieeeAddr}`);
727
723
  if (ieeeAddr) {
728
- const devId = zbIdorIeeetoAdId(this.adapter, ieeeAddr, false);
724
+ const devId = zbIdorIeeetoAdId(this, ieeeAddr, false);
729
725
  if (this.debugActive) this.log.debug(`Delete device ${devId} from iobroker.`);
730
726
  this.stController.deleteObj(devId);
731
727
  }
@@ -845,7 +841,7 @@ class Zigbee extends utils.Adapter {
845
841
  this.setState('info.pairingMode', false, true);
846
842
  }
847
843
  if (data) {
848
- this.logToPairing(`${message}: ${data.toString()}`);
844
+ this.logToPairing(`${message}: ${typeof data === 'string' ? data: data.toString()}`);
849
845
  } else {
850
846
  this.logToPairing(`${message}`);
851
847
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.zigbee",
3
- "version": "3.2.4",
3
+ "version": "3.3.0",
4
4
  "author": {
5
5
  "name": "Kirov Ilya",
6
6
  "email": "kirovilya@gmail.com"
@@ -22,28 +22,27 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@iobroker/adapter-core": "^3.3.2",
25
- "@iobroker/dm-utils": "^1.0.10",
26
- "humanize-duration": "^3.33.0",
27
- "tar": "^7.4.3",
25
+ "@iobroker/dm-utils": "^1.0.13",
26
+ "humanize-duration": "^3.33.1",
27
+ "tar": "^7.5.2",
28
28
  "ajv": "^8.17.1",
29
29
  "uri-js": "^4.4.1",
30
- "typescript": "^5.9.2",
31
- "zigbee-herdsman": "^6.0.0",
32
- "zigbee-herdsman-converters": "^25.50.0"
30
+ "typescript": "^5.9.3",
31
+ "zigbee-herdsman": "^7.0.0",
32
+ "zigbee-herdsman-converters": "25.84.0"
33
33
  },
34
34
  "description": "Zigbee devices",
35
35
  "devDependencies": {
36
- "@alcalzone/release-script": "^3.8.0",
37
- "@alcalzone/release-script-plugin-iobroker": "^3.7.2",
38
- "@alcalzone/release-script-plugin-license": "^3.7.0",
39
- "@alcalzone/release-script-plugin-manual-review": "^3.7.0",
40
- "@iobroker/testing": "^5.1.1",
41
- "chai": "^5.2.1",
42
- "eslint": "^9.36.0",
36
+ "@alcalzone/release-script": "^5.0.0",
37
+ "@alcalzone/release-script-plugin-iobroker": "^4.0.0",
38
+ "@alcalzone/release-script-plugin-license": "^4.0.0",
39
+ "@alcalzone/release-script-plugin-manual-review": "^4.0.0",
40
+ "@iobroker/testing": "^5.2.2",
41
+ "eslint": "^9.39.1",
43
42
  "eslint-config-prettier": "^9.1.0",
44
43
  "eslint-plugin-prettier": "^5.5.4",
45
44
  "mixin-deep": "^2.0.1",
46
- "@iobroker/dev-server": "^0.7.8"
45
+ "@iobroker/dev-server": "^0.8.0"
47
46
  },
48
47
  "homepage": "https://github.com/ioBroker/ioBroker.zigbee",
49
48
  "keywords": [