iobroker.lorawan 1.18.56 → 1.18.58

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
@@ -23,6 +23,12 @@ For now there is documentation in English here: https://wiki.hafenmeister.de
23
23
  Placeholder for the next version (at the beginning of the line):
24
24
  ### **WORK IN PROGRESS**
25
25
  -->
26
+ ### 1.18.58 (2025-12-31)
27
+ * (BenAhrdt) serialize and cache the config messagens
28
+
29
+ ### 1.18.57 (2025-12-31)
30
+ * (BenAhrdt) cache Infos in config for more performance
31
+
26
32
  ### 1.18.56 (2025-12-30)
27
33
  * (BenAhrdt) remoove namespace twice remooved
28
34
  * (BenAhrdt) serialize getConfigStates
package/io-package.json CHANGED
@@ -1,8 +1,34 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "lorawan",
4
- "version": "1.18.56",
4
+ "version": "1.18.58",
5
5
  "news": {
6
+ "1.18.58": {
7
+ "en": "serialize and cache the config messagens",
8
+ "de": "serialisieren und kache die config messagens",
9
+ "ru": "сериализировать и кэшировать config messagens",
10
+ "pt": "serialize e cache as mensagens de configuração",
11
+ "nl": "serialiseren en cache de config messages",
12
+ "fr": "sérialisez et cachez les messages de configuration",
13
+ "it": "serializzare e memorizzare i messaggi di configurazione",
14
+ "es": "serialize y cache los mensajes de config",
15
+ "pl": "serializuj i buforuj wiadomości konfiguracyjne",
16
+ "uk": "послідовність і кешування конфігураційних повідомлень",
17
+ "zh-cn": "序列化和缓存配置信件"
18
+ },
19
+ "1.18.57": {
20
+ "en": "cache Infos in config for more performance",
21
+ "de": "cache Infos in config für mehr Leistung",
22
+ "ru": "cache Infos in Config для повышения производительности",
23
+ "pt": "informações de cache em configuração para mais desempenho",
24
+ "nl": "cache-informatie in configuratie voor meer prestaties",
25
+ "fr": "cache Infos en configuration pour plus de performances",
26
+ "it": "cache Infos in config per maggiori prestazioni",
27
+ "es": "cache Infos en config para más rendimiento",
28
+ "pl": "cache Infos w konfiguracji dla większej wydajności",
29
+ "uk": "cache Infos в конфігурації для більшої продуктивності",
30
+ "zh-cn": "为更多性能在配置中缓存信息"
31
+ },
6
32
  "1.18.56": {
7
33
  "en": "remoove namespace twice remooved\nserialize getConfigStates",
8
34
  "de": "remoove namespace zweimal remooved\nserialisieren getConfigStates",
@@ -67,32 +93,6 @@
67
93
  "pl": "dodać możliwość ustawienia Devicesuffix w państwach LoraWAN",
68
94
  "uk": "додати можливість встановити Devicesuffix в LoraWAN",
69
95
  "zh-cn": "添加在 LoraWAN 州设置设备后缀的可能性"
70
- },
71
- "1.18.51": {
72
- "en": "add \"Temperatur\" to autmatic assign",
73
- "de": "\"Temperatur\" zu autmatic assign hinzufügen",
74
- "ru": "добавить \"Temperatur\" в аутматическое назначение",
75
- "pt": "adicionar \"Temperatur\" à atribuição autmática",
76
- "nl": "\"Temperatur\" toevoegen aan autmatisch toewijzen",
77
- "fr": "ajouter \"Temperatur\" à l'attribut autmatique",
78
- "it": "aggiungere \"Temperatur\" all'assegnazione autmatica",
79
- "es": "añadir \"Temperatur\" a la asignación autmática",
80
- "pl": "dodaj \"Temperatur\" do przypisania automatycznego",
81
- "uk": "додати \"Temperatur\" до тематичного знака",
82
- "zh-cn": "在自定义中添加“临时”"
83
- },
84
- "1.18.50": {
85
- "en": "filter in Debug mode (dev tool)",
86
- "de": "filter im Debug-Modus (dev tool)",
87
- "ru": "фильтр в режиме Debug (dev tool)",
88
- "pt": "filtro no modo de depuração (ferramenta de dev)",
89
- "nl": "filter in debugmodus (dev tool)",
90
- "fr": "filtre en mode Debug (outil dv)",
91
- "it": "filtro in modalità Debug (attrezzo di sviluppo)",
92
- "es": "filtro en modo Debug (herramienta dev)",
93
- "pl": "filtr w trybie debugowania (narzędzie dev)",
94
- "uk": "фільтр в режимі Debug (розробний інструмент)",
95
- "zh-cn": "调试模式中的过滤器( dev 工具)"
96
96
  }
97
97
  },
98
98
  "titleLang": {
package/main.js CHANGED
@@ -52,6 +52,7 @@ class Lorawan extends utils.Adapter {
52
52
  // Serialize getStateConfig
53
53
  this._configQueue = Promise.resolve();
54
54
  this._changeInfoCache = new Map();
55
+ this._adapterObjectsCache = null;
55
56
  }
56
57
 
57
58
  onFileChange(_id, _fileName, _size) {
@@ -1360,78 +1361,84 @@ class Lorawan extends utils.Adapter {
1360
1361
  obj.command === 'getApplicationsForClimateModeConfig'
1361
1362
  ) {
1362
1363
  try {
1363
- let myCount = 0;
1364
- const applications = [];
1365
- if (obj.command === 'getApplicationsForConfig') {
1366
- applications[myCount] = { label: '* (Wildcard)', value: '*' };
1367
- myCount++;
1368
- } else if (obj.command === 'getApplicationsForClimateModeConfig') {
1369
- applications[myCount] = { label: '* Not Present (Virtual)', value: 'NotPresent' };
1370
- myCount++;
1371
- }
1372
- const currentApplications = {};
1373
- const adapterObjects = await this.getAdapterObjectsAsync();
1374
- for (const adapterObject of Object.values(adapterObjects)) {
1375
- if (adapterObject.type === 'folder' && adapterObject._id.endsWith('uplink')) {
1376
- adapterObject._id = this.removeNamespace(adapterObject._id);
1377
- const changeInfo = await this.getChangeInfo(adapterObject._id);
1378
- const label = changeInfo?.usedApplicationName;
1379
- const value = changeInfo?.applicationId;
1380
- if (!currentApplications[value]) {
1381
- currentApplications[value] = value;
1382
- applications[myCount] = { label: label, value: value };
1383
- myCount++;
1364
+ await this.runSerializedMessages(async () => {
1365
+ let myCount = 0;
1366
+ const applications = [];
1367
+ if (obj.command === 'getApplicationsForConfig') {
1368
+ applications[myCount] = { label: '* (Wildcard)', value: '*' };
1369
+ myCount++;
1370
+ } else if (obj.command === 'getApplicationsForClimateModeConfig') {
1371
+ applications[myCount] = { label: '* Not Present (Virtual)', value: 'NotPresent' };
1372
+ myCount++;
1373
+ }
1374
+ const currentApplications = {};
1375
+ const adapterObjects = await this.getAdapterObjectsCached();
1376
+ for (const adapterObject of Object.values(adapterObjects)) {
1377
+ if (adapterObject.type === 'folder' && adapterObject._id.endsWith('uplink')) {
1378
+ adapterObject._id = this.removeNamespace(adapterObject._id);
1379
+ const changeInfo = await this.getChangeInfoCached(adapterObject._id);
1380
+ const label = changeInfo?.usedApplicationName;
1381
+ const value = changeInfo?.applicationId;
1382
+ if (!currentApplications[value]) {
1383
+ currentApplications[value] = value;
1384
+ applications[myCount] = { label: label, value: value };
1385
+ myCount++;
1386
+ }
1384
1387
  }
1385
1388
  }
1386
- }
1387
- applications.sort(this.sortByLabel);
1388
- this.sendTo(obj.from, obj.command, applications, obj.callback);
1389
+ applications.sort(this.sortByLabel);
1390
+ this.sendTo(obj.from, obj.command, applications, obj.callback);
1391
+ });
1389
1392
  } catch (error) {
1390
1393
  this.log.error(error);
1391
1394
  }
1392
1395
  } else if (obj.command === 'getDevicesForConfig' || obj.command === 'getDevicesForClimateConfig') {
1393
1396
  try {
1394
- let myCount = 0;
1395
- const devices = [];
1396
- if (obj.command === 'getDevicesForConfig') {
1397
- devices[myCount] = { label: '* (Wildcard)', value: '*' };
1398
- myCount++;
1399
- }
1400
- const adapterObjects = await this.getAdapterObjectsAsync();
1401
- for (const adapterObject of Object.values(adapterObjects)) {
1402
- if (
1403
- adapterObject.type === 'folder' &&
1404
- (adapterObject._id.includes(obj.message.application) ||
1405
- obj.message.application === '*') &&
1406
- adapterObject._id.endsWith('uplink')
1407
- ) {
1408
- adapterObject._id = this.removeNamespace(adapterObject._id);
1409
- const changeInfo = await this.getChangeInfo(adapterObject._id);
1410
- const label = changeInfo?.usedDeviceId;
1411
- const value = changeInfo?.deviceEUI;
1412
- devices[myCount] = { label: label, value: value };
1397
+ await this.runSerializedMessages(async () => {
1398
+ let myCount = 0;
1399
+ const devices = [];
1400
+ if (obj.command === 'getDevicesForConfig') {
1401
+ devices[myCount] = { label: '* (Wildcard)', value: '*' };
1413
1402
  myCount++;
1414
1403
  }
1415
- }
1416
- devices.sort(this.sortByLabel);
1417
- this.sendTo(obj.from, obj.command, devices, obj.callback);
1404
+ const adapterObjects = await this.getAdapterObjectsCached();
1405
+ for (const adapterObject of Object.values(adapterObjects)) {
1406
+ if (
1407
+ adapterObject.type === 'folder' &&
1408
+ (adapterObject._id.includes(obj.message.application) ||
1409
+ obj.message.application === '*') &&
1410
+ adapterObject._id.endsWith('uplink')
1411
+ ) {
1412
+ adapterObject._id = this.removeNamespace(adapterObject._id);
1413
+ const changeInfo = await this.getChangeInfoCached(adapterObject._id);
1414
+ const label = changeInfo?.usedDeviceId;
1415
+ const value = changeInfo?.deviceEUI;
1416
+ devices[myCount] = { label: label, value: value };
1417
+ myCount++;
1418
+ }
1419
+ }
1420
+ devices.sort(this.sortByLabel);
1421
+ this.sendTo(obj.from, obj.command, devices, obj.callback);
1422
+ });
1418
1423
  } catch (error) {
1419
1424
  this.log.error(error);
1420
1425
  }
1421
1426
  } else if (obj.command === 'getFoldersForConfig') {
1422
1427
  try {
1423
- const devices = [
1424
- { label: '* (Wildcard)', value: '*' },
1425
- { label: 'uplink.decoded', value: 'uplink.decoded' },
1426
- { label: 'downlink.control', value: 'downlink.control' },
1427
- ];
1428
- this.sendTo(obj.from, obj.command, devices, obj.callback);
1428
+ await this.runSerializedMessages(async () => {
1429
+ const devices = [
1430
+ { label: '* (Wildcard)', value: '*' },
1431
+ { label: 'uplink.decoded', value: 'uplink.decoded' },
1432
+ { label: 'downlink.control', value: 'downlink.control' },
1433
+ ];
1434
+ this.sendTo(obj.from, obj.command, devices, obj.callback);
1435
+ });
1429
1436
  } catch (error) {
1430
1437
  this.log.error(error);
1431
1438
  }
1432
1439
  } else if (obj.command === 'getStatesForConfig' || obj.command === 'getStatesForClimateConfig') {
1433
1440
  try {
1434
- await this.runSerializedMessage(async () => {
1441
+ await this.runSerializedMessages(async () => {
1435
1442
  let myCount = 0;
1436
1443
  const states = [];
1437
1444
  const possibleTypes = { state: true };
@@ -1441,7 +1448,7 @@ class Lorawan extends utils.Adapter {
1441
1448
  possibleTypes.folder = true;
1442
1449
  }
1443
1450
  const currentStates = {};
1444
- const adapterObjects = await this.getAdapterObjectsAsync();
1451
+ const adapterObjects = await this.getAdapterObjectsCached();
1445
1452
  for (const adapterObject of Object.values(adapterObjects)) {
1446
1453
  if (
1447
1454
  possibleTypes[adapterObject.type] === true &&
@@ -1620,7 +1627,7 @@ class Lorawan extends utils.Adapter {
1620
1627
  return false;
1621
1628
  }
1622
1629
 
1623
- async runSerializedMessage(fn) {
1630
+ async runSerializedMessages(fn) {
1624
1631
  const run = async () => fn();
1625
1632
 
1626
1633
  // Queue verlängern
@@ -1633,22 +1640,38 @@ class Lorawan extends utils.Adapter {
1633
1640
  }
1634
1641
 
1635
1642
  async getChangeInfoCached(id) {
1636
- const cleanId = this.removeNamespace(id);
1637
1643
  const now = Date.now();
1638
1644
 
1639
- const cached = this._changeInfoCache.get(cleanId);
1645
+ const cached = this._changeInfoCache.get(id);
1640
1646
  if (cached && cached.expires > now) {
1641
1647
  return cached.value;
1642
1648
  }
1643
1649
 
1644
- const value = await this.getChangeInfo(cleanId);
1645
- this._changeInfoCache.set(cleanId, {
1650
+ const value = await this.getChangeInfo(id);
1651
+ this._changeInfoCache.set(id, {
1646
1652
  value,
1647
1653
  expires: now + 30_000, // 10 Sekunden
1648
1654
  });
1649
1655
 
1650
1656
  return value;
1651
1657
  }
1658
+
1659
+ async getAdapterObjectsCached() {
1660
+ const now = Date.now();
1661
+
1662
+ if (this._adapterObjectsCache && this._adapterObjectsCache.expires > now) {
1663
+ return this._adapterObjectsCache.value;
1664
+ }
1665
+
1666
+ const value = await this.getAdapterObjectsAsync();
1667
+
1668
+ this._adapterObjectsCache = {
1669
+ value,
1670
+ expires: now + 30_000, // z.B. 30s
1671
+ };
1672
+
1673
+ return value;
1674
+ }
1652
1675
  }
1653
1676
 
1654
1677
  if (require.main !== module) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.lorawan",
3
- "version": "1.18.56",
3
+ "version": "1.18.58",
4
4
  "description": "converts the desired lora gateway data to a ioBroker structure",
5
5
  "author": {
6
6
  "name": "BenAhrdt",