iobroker.zigbee 1.9.1 → 1.9.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.
package/README.md CHANGED
@@ -134,6 +134,17 @@ You can thank the authors by these links:
134
134
  -----------------------------------------------------------------------------------------------------
135
135
 
136
136
  ## Changelog
137
+ ### 1.9.4 (2023-12-29)
138
+ * (arteck) type
139
+
140
+ ### 1.9.3 (2023-12-26)
141
+ * (arteck) last zhc Version 16.x
142
+ * (arteck) corr reboot in statecontroller
143
+
144
+ ### 1.9.2 (2023-12-25)
145
+ * (arteck) gen states from exposes as function
146
+ * (arteck) rebuild dev_names.json with state cleanup button
147
+
137
148
  ### 1.9.1 (2023-12-23)
138
149
  * (arteck) corr TypeError: Cannot read properties of undefined (reading 'state')
139
150
 
package/io-package.json CHANGED
@@ -1,8 +1,47 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "zigbee",
4
- "version": "1.9.1",
4
+ "version": "1.9.4",
5
5
  "news": {
6
+ "1.9.4": {
7
+ "en": "type",
8
+ "de": "typ",
9
+ "ru": "тип",
10
+ "pt": "tipo",
11
+ "nl": "type type type type type type type type type type type type type type type type type type type type type type type type type type type type type typety type type type type type type type type type type type type type type type typety type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type typety type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type type",
12
+ "fr": "type",
13
+ "it": "tipo",
14
+ "es": "tipo",
15
+ "pl": "typ",
16
+ "uk": "тип",
17
+ "zh-cn": "类型"
18
+ },
19
+ "1.9.3": {
20
+ "en": "last zhc Version 16.x\ncorr reboot in statecontroller",
21
+ "de": "letzte Version 16.x\nkorr reboot in statecontroller",
22
+ "ru": "последняя версия zhc 16.x\nкорр перезагрузка в государственный контролер",
23
+ "pt": "última versão zhc 16.x\nreboot de corr no controlador de estado",
24
+ "nl": "laatste Zhc Version 16\ncorr reboot in staatscontroller",
25
+ "fr": "dernière version zhc 16.x\ncorr reboot in statecontroller",
26
+ "it": "ultima versione zhc 16.x\nreboot corr in statocontroller",
27
+ "es": "última versión 16.x\nreboot de corr en statecontroller",
28
+ "pl": "ostatnia wersja 16.x\nkor reboot w systemie kontroli państwa",
29
+ "uk": "остання версія jc 16.x\nперезавантаження коренів в держконтролері",
30
+ "zh-cn": "上一次zhc Version 16x\n州控制容忍的报复"
31
+ },
32
+ "1.9.2": {
33
+ "en": "gen states from exposes as function\nrebuild dev_names.json with state cleanup button",
34
+ "de": "gen-staaten von exponiert als funktion\ndev_names neu aufbauen. json with state cleanup taste",
35
+ "ru": "гены из экспозиций как функция\nперестроить dev_names. json с государственной кнопкой очистки",
36
+ "pt": "gen estados de exposições como função\nreconstruir dev_names. json com botão de limpeza do estado",
37
+ "nl": "gen staten van blootstelling als functioneren\nherbouwde dev namen. json met staatsopruimknop",
38
+ "fr": "gen states from exposes as function\nreconstruire dev_names. json avec bouton de nettoyage de l'état",
39
+ "it": "gen stati da espone come funzione\nricostruire dev_names. json con il pulsante di pulizia dello stato",
40
+ "es": "gen estados de expone como función\nreconstruir dev_names. json con botón de limpieza del estado",
41
+ "pl": "państwa genowe zjawiają się jako funkcje\nodbudowa nazw. json z przyciskiem czystego przycisku",
42
+ "uk": "генні стани від вибухів як функції\nrebuild dev_names. json з державною кнопкою очищення",
43
+ "zh-cn": "根塔里斯·奥古尔(签名)\n页:1 j. 有国家清洁,但顿"
44
+ },
6
45
  "1.9.1": {
7
46
  "en": "corr TypeError: Cannot read properties of undefined (reading 'state')",
8
47
  "de": "korpustyp Fehler: Kann Eigenschaften von undefinierten (Lesezustand) nicht lesen",
@@ -54,45 +93,6 @@
54
93
  "pl": "kor toZigbee message\ndodać manager",
55
94
  "uk": "corr toZigbee повідомлення\nдодати пристрій Менеджер",
56
95
  "zh-cn": "信\n增加装置 管理人员"
57
- },
58
- "1.8.25": {
59
- "en": "zhc 16.x \ncorr group from exclude dialog",
60
- "de": "zhc 16.x\nkorr gruppe aus ausschluss dialog",
61
- "ru": "жк 16.x\nгруппа корр от исключает диалог",
62
- "pt": "zhc 16.x\ncorr grupo de excluir diálogo",
63
- "nl": "zhc 16\ncorr groep uitgesloten dialog",
64
- "fr": "zhc 16.x\ngroupe corr de l'exclusion du dialogue",
65
- "it": "zhc 16.x\ngruppo corr da escludere finestra di dialogo",
66
- "es": "zhc 16.x\ngrupo de corr de excluir diálogo",
67
- "pl": "żc 16.x\ngrupa kor z wyłączeniem dialogu",
68
- "uk": "жк 16.x\nгрупа з виключення діалогу",
69
- "zh-cn": "页: 1\n集团排除了口号"
70
- },
71
- "1.8.24": {
72
- "en": "switch to exposes tab for some Aqara Devices",
73
- "de": "schalter, um die Registerkarte für einige Aqara-Geräte freizusetzen",
74
- "ru": "перейти на вкладку exposes для некоторых устройств Aqara",
75
- "pt": "mudar para expor guia para alguns dispositivos Aqara",
76
- "nl": "vertaling:",
77
- "fr": "commutation pour exposer l'onglet pour certains appareils Aqara",
78
- "it": "interruttore per esporre la scheda per alcuni dispositivi Aqara",
79
- "es": "interruptor para exponer ficha para algunos dispositivos Aqara",
80
- "pl": "zamienił tablicę dla niektórych Aqara Devices",
81
- "uk": "перемикач для установки для деяких пристроїв Aqara",
82
- "zh-cn": "对某些Aqara Devic的表格的转换"
83
- },
84
- "1.8.23": {
85
- "en": "query from xiaomi is now better",
86
- "de": "anfrage von xiaomi ist jetzt besser",
87
- "ru": "запрос от xiaomi теперь лучше",
88
- "pt": "consulta de xiaomi é agora melhor",
89
- "nl": "quee van xiaomi is nu beter",
90
- "fr": "la question de xiaomi est maintenant mieux",
91
- "it": "query da xiaomi è ora meglio",
92
- "es": "la consulta de xiaomi ahora es mejor",
93
- "pl": "wykorzystywanie z xiaomi jest obecnie lepsze",
94
- "uk": "запиту від xiaomi тепер краще",
95
- "zh-cn": "来自米亚米的询问现在更好。"
96
96
  }
97
97
  },
98
98
  "titleLang": {
package/lib/commands.js CHANGED
@@ -88,7 +88,6 @@ class Commands {
88
88
  break;
89
89
  case 'setState':
90
90
  if (obj && obj.message && typeof obj.message === 'object' && obj.message.id) {
91
- // this.adapter.setState(obj.message.id, obj.message.val, false, obj.callback);
92
91
  this.stController.setState_typed(obj.message.id, obj.message.val, false, undefined, obj.callback);
93
92
  }
94
93
  break;
@@ -107,7 +106,6 @@ class Commands {
107
106
  this.setDeviceActivated(obj.from, obj.command, obj.message, obj.callback);
108
107
  }
109
108
  break;
110
-
111
109
  }
112
110
  }
113
111
  }
@@ -474,13 +472,17 @@ class Commands {
474
472
  async cleanDeviceStates(from, command, msg, callback) {
475
473
  this.info(`State cleanup with ${JSON.stringify(msg)}`);
476
474
  const devicesFromDB = await this.zbController.getClients(false);
475
+
477
476
  for (const device of devicesFromDB) {
478
477
  const entity = await this.zbController.resolveEntity(device);
478
+
479
479
  if (entity) {
480
480
  const model = (entity.mapped) ? entity.mapped.model : entity.device.modelID;
481
481
  await this.stController.deleteOrphanedDeviceStates(device.ieeeAddr, model, msg.force);
482
482
  }
483
483
  }
484
+ // rebuild retainDeviceNamesDB
485
+ this.stController.rebuildRetainDeviceNames();
484
486
  this.adapter.sendTo(from, command, {}, callback);
485
487
  }
486
488
 
package/lib/devicemgmt.js CHANGED
@@ -1,4 +1,4 @@
1
- const dmUtils = require('@jey-cee/dm-utils');
1
+ const dmUtils = require('@iobroker/dm-utils');
2
2
  const humanizeDuration = require('humanize-duration');
3
3
 
4
4
  class dmZigbee extends dmUtils.DeviceManagement {
@@ -8,25 +8,6 @@ class dmZigbee extends dmUtils.DeviceManagement {
8
8
  ...super.getInstanceInfo(),
9
9
  apiVersion: 'v1',
10
10
  actions: [
11
- {
12
- id: 'refresh',
13
- icon: 'fas fa-redo-alt',
14
- title: '',
15
- description: {
16
- en: 'Refresh device list',
17
- de: 'Geräteliste aktualisieren',
18
- ru: 'Обновить список устройств',
19
- pt: 'Atualizar lista de dispositivos',
20
- nl: 'Vernieuw apparaatlijst',
21
- fr: 'Actualiser la liste des appareils',
22
- it: 'Aggiorna elenco dispositivi',
23
- es: 'Actualizar lista de dispositivos',
24
- pl: 'Odśwież listę urządzeń',
25
-
26
- uk: 'Оновити список пристроїв'
27
- },
28
- handler: this.handleRefresh.bind(this)
29
- },
30
11
  {
31
12
  id: 'newDevice',
32
13
  icon: 'fas fa-plus',
package/lib/exposes.js CHANGED
@@ -248,9 +248,37 @@ function createFromExposes(model, def) {
248
248
  }
249
249
 
250
250
  const icon = utils.getDeviceIcon(def);
251
- for (const expose of def.exposes) {
252
- let state;
253
251
 
252
+ if (typeof def.exposes == 'object') {
253
+ for (const expose of def.exposes) {
254
+ genStateFromExpose(expose);
255
+
256
+
257
+ }
258
+ }
259
+
260
+ // maybee here check manufacturerName for tuya devices
261
+ if (typeof def.exposes == 'function') {
262
+ const expFunction = def.exposes(def, {}); // maybee here check manufacturerName for tuya devices
263
+
264
+ for (const expose of expFunction) {
265
+ genStateFromExpose(expose);
266
+ }
267
+ }
268
+
269
+ const newDev = {
270
+ models: [model],
271
+ icon,
272
+ states,
273
+ exposed: true,
274
+ };
275
+
276
+ return newDev;
277
+
278
+
279
+
280
+ function genStateFromExpose(expose) {
281
+ let state;
254
282
  switch (expose.type) {
255
283
  case 'light':
256
284
  for (const prop of expose.features) {
@@ -362,7 +390,7 @@ function createFromExposes(model, def) {
362
390
  x: xy[0],
363
391
  y: xy[1]
364
392
  };
365
- */
393
+ */
366
394
  let xy = [0, 0];
367
395
  const rgbcolor = colors.ParseColor(value);
368
396
 
@@ -851,22 +879,20 @@ function createFromExposes(model, def) {
851
879
  }
852
880
  }
853
881
  break;
882
+ case 'list':
883
+ // is not mapped
884
+ // for (const prop of expose) {
885
+ // let nam = prop.name;
886
+
887
+ // }
888
+ break;
854
889
  default:
855
890
  console.log(`Unhandled expose type ${expose.type} for device ${model}`);
891
+
856
892
  }
857
893
  }
858
- const newDev = {
859
- models: [model],
860
- icon,
861
- states,
862
- exposed: true,
863
- };
864
- // make the function code printable in log
865
- //console.log(`Created mapping for device ${model}: ${JSON.stringify(newDev, function(key, value) {
866
- // if (typeof value === 'function') {return value.toString() } else { return value } }, ' ')}`);
867
- return newDev;
868
- }
869
894
 
895
+ }
870
896
  function applyExposes(mappedDevices, byModel, allExcludesObj) {
871
897
  // for exclude search
872
898
  const allExcludesStr = JSON.stringify(allExcludesObj);
@@ -890,6 +916,7 @@ function applyExposes(mappedDevices, byModel, allExcludesObj) {
890
916
  function applyDeviceDef(mappedDevices, byModel, allExcludesStr, deviceDef) {
891
917
  const stripModel = utils.getModelRegEx(deviceDef.model);
892
918
  // check if device is mapped
919
+
893
920
  const existsMap = byModel.get(stripModel);
894
921
 
895
922
  if ((deviceDef.hasOwnProperty('exposes') && (!existsMap || !existsMap.hasOwnProperty('states'))) || allExcludesStr.indexOf(stripModel) > 0) {
@@ -7,7 +7,7 @@ const getZbId = require('./utils').getZbId;
7
7
  const fs = require('fs');
8
8
  const request = require('request');
9
9
 
10
- let savedDeviceNames = {};
10
+ let savedDeviceNamesDB = {};
11
11
  const knownUndefinedDevices = {};
12
12
 
13
13
  class StatesController extends EventEmitter {
@@ -23,9 +23,9 @@ class StatesController extends EventEmitter {
23
23
  fs.readFile(this.dev_names_fn, (err, data) => {
24
24
  if (!err) {
25
25
  try {
26
- savedDeviceNames = JSON.parse(data);
26
+ savedDeviceNamesDB = JSON.parse(data);
27
27
  } catch {
28
- savedDeviceNames = {};
28
+ savedDeviceNamesDB = {};
29
29
  }
30
30
  }
31
31
  });
@@ -54,7 +54,7 @@ class StatesController extends EventEmitter {
54
54
  retainDeviceNames() {
55
55
  clearTimeout(this.retTimeoutHandle);
56
56
  this.retTimeoutHanlde = setTimeout(() => {
57
- fs.writeFile(this.dev_names_fn, JSON.stringify(savedDeviceNames, null, 2), err => {
57
+ fs.writeFile(this.dev_names_fn, JSON.stringify(savedDeviceNamesDB, null, 2), err => {
58
58
  if (err) {
59
59
  this.error(`error saving device names: ${JSON.stringify(err)}`);
60
60
  } else {
@@ -272,18 +272,30 @@ class StatesController extends EventEmitter {
272
272
  this.adapter.extendObject(id, {common: {deactivated: active}});
273
273
  }
274
274
 
275
+ async rebuildRetainDeviceNames() {
276
+ savedDeviceNamesDB = {};
277
+ const devList = await this.adapter.getAdapterObjectsAsync();
278
+
279
+ for (const key in devList) {
280
+ if (devList[key].type == 'device') {
281
+ savedDeviceNamesDB[devList[key]._id.replace(`${this.adapter.namespace}.`, '')] = devList[key].common.name;
282
+ }
283
+ }
284
+ this.retainDeviceNames();
285
+ }
286
+
275
287
  storeDeviceName(id, name) {
276
- savedDeviceNames[id.replace(`${this.adapter.namespace}.`, '')] = name;
288
+ savedDeviceNamesDB[id.replace(`${this.adapter.namespace}.`, '')] = name;
277
289
  this.retainDeviceNames();
278
290
  }
279
291
 
280
292
  verifyDeviceName(id, name) {
281
293
  const savedId = id.replace(`${this.adapter.namespace}.`, '');
282
- if (!savedDeviceNames.hasOwnProperty(savedId)) {
283
- savedDeviceNames[savedId] = name;
294
+ if (!savedDeviceNamesDB.hasOwnProperty(savedId)) {
295
+ savedDeviceNamesDB[savedId] = name;
284
296
  this.retainDeviceNames();
285
297
  }
286
- return savedDeviceNames[savedId];
298
+ return savedDeviceNamesDB[savedId];
287
299
  }
288
300
 
289
301
  deleteDeviceStates(devId, callback) {
@@ -597,8 +609,11 @@ class StatesController extends EventEmitter {
597
609
  let has_debug = false;
598
610
  if (this.debugDevices === undefined) this.getDebugDevices();
599
611
  for (const addressPart of this.debugDevices) {
600
- if (typeof devId === 'string' && devId.includes(addressPart)) {
601
- if (payload.hasOwnProperty('msg_from_zigbee')) break;
612
+ if (typeof(devId) == 'string' && devId.indexOf(addressPart) > -1) {
613
+ if (payload.hasOwnProperty('msg_from_zigbee')) {
614
+ break;
615
+ }
616
+
602
617
  this.warn(`ELEVATED publishToState: message received '${JSON.stringify(payload)}' from device ${devId} type '${model}'`);
603
618
  has_debug = true;
604
619
  break;
@@ -99,40 +99,39 @@ class DeviceConfigure extends BaseExtension {
99
99
 
100
100
  async configure(device, mappedDevice) {
101
101
  try {
102
- if (this.configuring.has(device.ieeeAddr) || this.attempts[device.ieeeAddr] >= 5) {
103
- return false;
104
- }
102
+ if (mappedDevice !== undefined && device !== undefined) {
103
+ if (this.configuring.has(device.ieeeAddr) || this.attempts[device.ieeeAddr] >= 5) {
104
+ return false;
105
+ }
105
106
 
106
- this.configuring.add(device.ieeeAddr);
107
+ this.configuring.add(device.ieeeAddr);
107
108
 
108
- if (!this.attempts.hasOwnProperty(device.ieeeAddr)) {
109
- this.attempts[device.ieeeAddr] = 0;
110
- }
111
- try {
112
- if (mappedDevice && device) {
109
+ if (!this.attempts.hasOwnProperty(device.ieeeAddr)) {
110
+ this.attempts[device.ieeeAddr] = 0;
111
+ }
112
+
113
+ try {
113
114
  await this.doConfigure(device, mappedDevice);
115
+ this.configuring.delete(device.ieeeAddr);
116
+ } catch (error) {
117
+ this.sendError(error);
118
+ this.warn(
119
+ `DeviceConfigure failed ${device.ieeeAddr} ${device.modelID}, ` +
120
+ `attempt ${this.attempts[device.ieeeAddr] + 1} (${error.stack})`,
121
+ );
122
+ this.attempts[device.ieeeAddr]++;
114
123
  }
115
- } catch (error) {
116
- this.sendError(error);
117
- this.warn(
118
- `DeviceConfigure failed ${device.ieeeAddr} ${device.modelID}, ` +
119
- `attempt ${this.attempts[device.ieeeAddr] + 1} (${error.stack})`,
120
- );
121
- this.attempts[device.ieeeAddr]++;
122
124
  }
123
- this.configuring.delete(device.ieeeAddr);
124
125
  } catch (error) {
125
126
  this.sendError(error);
126
- this.error(
127
- `Failed to DeviceConfigure.configure ${device.ieeeAddr} ${device.modelID} (${error.stack})`,
128
- );
127
+ this.error(`Failed to DeviceConfigure.configure ${device.ieeeAddr} ${device.modelID} stack: (${error.stack})`);
129
128
  }
130
129
  }
131
130
 
132
131
  async doConfigure(device, mappedDevice) {
133
132
  const coordinatorEndpoint = await this.zigbee.getDevicesByType('Coordinator')[0].endpoints[0];
134
133
  try {
135
- if (mappedDevice !== undefined) {
134
+ if (mappedDevice) {
136
135
  this.info(`Configuring ${device.ieeeAddr} ${device.modelID}`);
137
136
  await mappedDevice.configure(device, coordinatorEndpoint, this);
138
137
  device.meta.configured = zigbeeHerdsmanConverters.getConfigureKey(mappedDevice);
@@ -141,9 +140,7 @@ class DeviceConfigure extends BaseExtension {
141
140
  }
142
141
  } catch (error) {
143
142
  this.sendError(error);
144
- this.error(
145
- `Failed to DeviceConfigure.configure ${device.ieeeAddr} ${device.modelID} (${error.stack})`,
146
- );
143
+ this.error(`Failed to DeviceConfigure.configure ${device.ieeeAddr} ${device.modelID} (${error.stack})`);
147
144
  }
148
145
  }
149
146
  }
package/main.js CHANGED
@@ -283,7 +283,7 @@ class Zigbee extends utils.Adapter {
283
283
  try {
284
284
  zigbeeHerdsmanConverters.addDeviceDefinition(toAdd);
285
285
  } catch {
286
- this.log.error(`unable to apply external converter ${JSON.stringfy(toAdd)}`);
286
+ this.log.error(`unable to apply external converter ${JSON.stringify(toAdd)}`);
287
287
  }
288
288
  }
289
289
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.zigbee",
3
- "version": "1.9.1",
3
+ "version": "1.9.4",
4
4
  "author": {
5
5
  "name": "Kirov Ilya",
6
6
  "email": "kirovilya@gmail.com"
@@ -22,12 +22,12 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@iobroker/adapter-core": "^3.0.4",
25
- "@jey-cee/dm-utils": "^0.0.5",
25
+ "@iobroker/dm-utils": "^0.1.8",
26
26
  "humanize-duration": "^3.31.0",
27
27
  "tar": "^6.2.0",
28
28
  "typescript": "^5.3.3",
29
- "zigbee-herdsman": "0.27.1",
30
- "zigbee-herdsman-converters": "16.17.0"
29
+ "zigbee-herdsman": "0.28.0",
30
+ "zigbee-herdsman-converters": "16.18.0"
31
31
  },
32
32
  "description": "Zigbee devices",
33
33
  "devDependencies": {