iobroker.lorawan 1.18.23 → 1.18.24

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,9 @@ 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.24 (2025-11-27)
27
+ * (BenAhrdt) add dataExchange between Adapter and Bridge-Partner (Complex JSON possible)
28
+
26
29
  ### 1.18.23 (2025-11-26)
27
30
  * (BenAhrdt) Notify Adapter Version to Bridge with connection
28
31
 
package/io-package.json CHANGED
@@ -1,8 +1,21 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "lorawan",
4
- "version": "1.18.23",
4
+ "version": "1.18.24",
5
5
  "news": {
6
+ "1.18.24": {
7
+ "en": "add dataExchange between Adapter and Bridge-Partner (Complex JSON possible)",
8
+ "de": "daten hinzufügen Austausch zwischen Adapter und Bridge-Partner (Komplex JSON möglich)",
9
+ "ru": "добавить данные Обмен между адаптером и Bridge-Partner (комплекс JSON)",
10
+ "pt": "adicionar dados Troca entre adaptador e parceiro de ponte (complexo JSON possível)",
11
+ "nl": "gegevens toevoegen Uitwisseling tussen Adapter en Bridge-Partner (complex JSON mogelijk)",
12
+ "fr": "ajouter des données Échange entre Adaptateur et Bridge-Partner (Complex JSON possible)",
13
+ "it": "aggiungere i dati Scambio tra adattatore e Bridge-Partner (Complex JSON possibile)",
14
+ "es": "añadir datos Intercambio entre Adaptador y Bridge-Partner (Complejo JSON posible)",
15
+ "pl": "dodaj dane Wymiana między Adapterem a partnerem Bridge- (możliwy kompleks JSON)",
16
+ "uk": "додати дані Обмін між адаптером і Bridge-Partner (Комплексний JSON можливо)",
17
+ "zh-cn": "添加数据 适配器与Bridge-Partner之间的交换(可能复杂JSON)"
18
+ },
6
19
  "1.18.23": {
7
20
  "en": "Notify Adapter Version to Bridge with connection",
8
21
  "de": "Benachrichtigen Adapter Version auf Brücke mit Anschluss",
@@ -80,19 +93,6 @@
80
93
  "pl": "Temat limit bugfix do stanu _ topic",
81
94
  "uk": "Виправлення ліміту висихання до стану_topic",
82
95
  "zh-cn": "错误fix 将 sitch 话题限制为状态_ title"
83
- },
84
- "1.18.17": {
85
- "en": "Bugfix limit switch closed",
86
- "de": "Bugfix Endschalter geschlossen",
87
- "ru": "Переключатель Bugfix Limit закрыт",
88
- "pt": "Interruptor de limite de correção de erros fechado",
89
- "nl": "Bugfix limietschakelaar gesloten",
90
- "fr": "Interrupteur limite de bogue fermé",
91
- "it": "Interruttore di limite Bugfix chiuso",
92
- "es": "Interruptor de límite de fallo cerrado",
93
- "pl": "Graniczny wyłącznik Bugfix zamknięty",
94
- "uk": "Перемикач ліміту попереку",
95
- "zh-cn": "关闭错误修正限制开关"
96
96
  }
97
97
  },
98
98
  "titleLang": {
@@ -579,6 +579,19 @@
579
579
  "def": ""
580
580
  },
581
581
  "native": {}
582
+ },
583
+ {
584
+ "_id": "bridge.dataExchange",
585
+ "type": "state",
586
+ "common": {
587
+ "type": "string",
588
+ "role": "json",
589
+ "name": "dataexchange with bridge",
590
+ "read": true,
591
+ "write": true,
592
+ "def": ""
593
+ },
594
+ "native": {}
582
595
  }
583
596
  ]
584
597
  }
@@ -260,9 +260,16 @@ class bridgeClass {
260
260
 
261
261
  // Check for namespace and write own, oder foreign state
262
262
  if (this.SubscribedTopics[topic].id.startsWith(this.adapter.namespace)) {
263
- await this.adapter.setState(this.SubscribedTopics[topic].id, message);
263
+ if (this.SubscribedTopics[topic].dataExchange) {
264
+ if (typeof message === 'object') {
265
+ message = JSON.stringify(message);
266
+ }
267
+ await this.adapter.setState(this.SubscribedTopics[topic].id, message);
268
+ } else {
269
+ await this.adapter.setState(this.SubscribedTopics[topic].id, message);
270
+ }
264
271
  } else {
265
- if (message.id && message.val) {
272
+ if (this.SubscribedTopics[topic].message) {
266
273
  await this.adapter.setForeignStateAsync(message.id, message.val);
267
274
  } else {
268
275
  await this.adapter.setForeignStateAsync(this.SubscribedTopics[topic].id, message);
@@ -1158,22 +1165,35 @@ class bridgeClass {
1158
1165
  const activeFunction = 'bridge.js - getDiscoveryObject';
1159
1166
  this.adapter.log.debug(`Function ${activeFunction} started.`);
1160
1167
  try {
1161
- let indexOfStatebegin = changeInfo.id.indexOf(
1162
- this.adapter.messagehandler.directoryhandler.reachableSubfolders.uplinkDecoded,
1163
- );
1164
- if (indexOfStatebegin === -1) {
1168
+ let indexOfStatebegin = -1;
1169
+ // Check for state discover outsid the applications
1170
+ if (options && options.internal) {
1171
+ indexOfStatebegin = changeInfo.id.indexOf(options.internal.folder);
1172
+ indexOfStatebegin = options.internal.folder.length + 1;
1173
+ } else {
1165
1174
  indexOfStatebegin = changeInfo.id.indexOf(
1166
- this.adapter.messagehandler.directoryhandler.reachableSubfolders.downlinkControl,
1175
+ this.adapter.messagehandler.directoryhandler.reachableSubfolders.uplinkDecoded,
1167
1176
  );
1168
- indexOfStatebegin +=
1169
- this.adapter.messagehandler.directoryhandler.reachableSubfolders.downlinkControl.length + 1;
1170
- } else {
1171
- indexOfStatebegin +=
1172
- this.adapter.messagehandler.directoryhandler.reachableSubfolders.uplinkDecoded.length + 1;
1177
+ if (indexOfStatebegin === -1) {
1178
+ indexOfStatebegin = changeInfo.id.indexOf(
1179
+ this.adapter.messagehandler.directoryhandler.reachableSubfolders.downlinkControl,
1180
+ );
1181
+ indexOfStatebegin +=
1182
+ this.adapter.messagehandler.directoryhandler.reachableSubfolders.downlinkControl.length + 1;
1183
+ } else {
1184
+ indexOfStatebegin +=
1185
+ this.adapter.messagehandler.directoryhandler.reachableSubfolders.uplinkDecoded.length + 1;
1186
+ }
1173
1187
  }
1174
1188
  const StateName = changeInfo.id.substring(indexOfStatebegin, changeInfo.id.length);
1189
+ this.adapter.log.warn(StateName);
1175
1190
  //const normalizedStateName = this.normalizeString(StateName); 08.11.2025 BeSc dont needed anymore with chenge below
1176
- const DeviceIdentifier = this.getDeviceIdentifier(changeInfo, this.adapter.config.DeviceIdentifiers);
1191
+ let DeviceIdentifier;
1192
+ if (options && options.internal) {
1193
+ DeviceIdentifier = options.internal.deviceidentifier;
1194
+ } else {
1195
+ DeviceIdentifier = this.getDeviceIdentifier(changeInfo, this.adapter.config.DeviceIdentifiers);
1196
+ }
1177
1197
  const normalizedDeviceIdentifier = this.normalizeString(DeviceIdentifier);
1178
1198
  const uniqueString = await this.getUniqueString(
1179
1199
  `${this.adapter.namespace}.${changeInfo.id}`,
@@ -1668,6 +1688,8 @@ class bridgeClass {
1668
1688
  //this.adapter.log.error(JSON.stringify(this.oldDiscoveredDevices));
1669
1689
  await this.discoverGeneralNotification();
1670
1690
 
1691
+ await this.discoverDataExchange();
1692
+
1671
1693
  // Get all ids in adapterfolder
1672
1694
  // Generate Infos of all devices and decoded folders
1673
1695
  const adapterObjects = await this.adapter.getAdapterObjectsAsync();
@@ -1722,6 +1744,59 @@ class bridgeClass {
1722
1744
  }
1723
1745
  }
1724
1746
 
1747
+ /**
1748
+ * Discovery of DataExchange state
1749
+ */
1750
+ async discoverDataExchange() {
1751
+ const options = {};
1752
+ const id = `${this.adapter.namespace}.bridge.dataExchange`;
1753
+ const deviceObject = await this.adapter.getForeignObjectAsync(id);
1754
+ options.common = deviceObject.common;
1755
+ this.adapter.log.warn(JSON.stringify(options));
1756
+ const changeInfo = await this.adapter.getChangeInfo(id);
1757
+ options.Bridgestate = {
1758
+ discover: true,
1759
+ publish: true,
1760
+ subscribe: true,
1761
+ };
1762
+ options.internal = { folder: `bridge`, deviceidentifier: this.adapter.namespace };
1763
+ const DiscoveryObject = await this.getDiscoveryObject(changeInfo, options);
1764
+ this.assignIdStructure(
1765
+ this.PublishedIds,
1766
+ id,
1767
+ {
1768
+ usedDeviceId: this.adapter.namespace,
1769
+ },
1770
+ DiscoveryObject?.topic,
1771
+ DiscoveryObject?.payload,
1772
+ DiscoveryObject?.payload.state_topic,
1773
+ { dataExchange: true },
1774
+ );
1775
+
1776
+ this.assignTopicStructure(
1777
+ this.SubscribedTopics,
1778
+ DiscoveryObject?.payload.command_topic,
1779
+ {
1780
+ usedDeviceId: this.adapter.namespace,
1781
+ },
1782
+ DiscoveryObject?.topic,
1783
+ DiscoveryObject?.payload,
1784
+ id,
1785
+ { dataExchange: true },
1786
+ );
1787
+ await this.publishDiscovery(id, {
1788
+ topic: DiscoveryObject?.topic,
1789
+ payload: structuredClone(DiscoveryObject?.payload),
1790
+ informations: {
1791
+ usedDeviceId: this.adapter.namespace,
1792
+ },
1793
+ });
1794
+ // Delay for publish new entity
1795
+ setTimeout(async () => {
1796
+ await this.publishId(id, undefined, {});
1797
+ }, 1000);
1798
+ }
1799
+
1725
1800
  /**
1726
1801
  * check discovery for old entries
1727
1802
  */
package/main.js CHANGED
@@ -714,6 +714,9 @@ class Lorawan extends utils.Adapter {
714
714
  await this.setState('bridge.debug.payload', payload.val, true);
715
715
  }
716
716
  await this.setState(id, false, true);
717
+ } else if (id.endsWith('.bridge.dataExchange')) {
718
+ await this.bridge?.publishId(id, state.val, {});
719
+ await this.setState(id, state.val, true);
717
720
  }
718
721
  } else {
719
722
  // Query for 0_userdata or alias => states also publish with ack = false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.lorawan",
3
- "version": "1.18.23",
3
+ "version": "1.18.24",
4
4
  "description": "converts the desired lora gateway data to a ioBroker structure",
5
5
  "author": {
6
6
  "name": "BenAhrdt",