iobroker.lorawan 1.18.34 → 1.18.35

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.35 (2025-11-28)
27
+ * (BenAhrdt) internal code improovment for better reading
28
+
26
29
  ### 1.18.34 (2025-11-28)
27
30
  * (BenAhrdt) translation changed
28
31
 
package/io-package.json CHANGED
@@ -1,8 +1,21 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "lorawan",
4
- "version": "1.18.34",
4
+ "version": "1.18.35",
5
5
  "news": {
6
+ "1.18.35": {
7
+ "en": "internal code improovment for better reading",
8
+ "de": "interner code improovement für besseres lesen",
9
+ "ru": "импровизация внутреннего кода для лучшего чтения",
10
+ "pt": "improvisação de código interno para melhor leitura",
11
+ "nl": "interne code improvisatie voor beter lezen",
12
+ "fr": "imprégnation du code interne pour une meilleure lecture",
13
+ "it": "codice interno improovment per una migliore lettura",
14
+ "es": "improvimento de código interno para una mejor lectura",
15
+ "pl": "improwizacja kodu wewnętrznego dla lepszego czytania",
16
+ "uk": "внутрішня обробка коду для кращого читання",
17
+ "zh-cn": "内部代码即兴读取"
18
+ },
6
19
  "1.18.34": {
7
20
  "en": "translation changed",
8
21
  "de": "übersetzung geändert",
@@ -80,19 +93,6 @@
80
93
  "pl": "set ack = true, przed push data Giełda",
81
94
  "uk": "встановити ack = true, перш ніж натиснути дані Обмін",
82
95
  "zh-cn": "在按下数据前设置 ack = true 交换"
83
- },
84
- "1.18.28": {
85
- "en": "assign comment 'from bridge' to state, if the value is set by bridge",
86
- "de": "kommentar 'von der brücke' zum zustand zuordnen, wenn der wert von der brücke gesetzt wird",
87
- "ru": "присвоить комментарий «от моста» государству, если значение установлено мостом",
88
- "pt": "atribuir o comentário 'da ponte' ao estado, se o valor for definido pela ponte",
89
- "nl": "commentaar 'van brug' toewijzen aan status, als de waarde door brug wordt ingesteld",
90
- "fr": "assigner le commentaire 'from bridge' à l'état, si la valeur est définie par bridge",
91
- "it": "assegnare commento 'da ponte' a stato, se il valore è impostato da ponte",
92
- "es": "asignar comentario 'de puente' a estado, si el valor se establece por puente",
93
- "pl": "przypisz komentarz \"z mostu\" do stanu, jeśli wartość jest ustawiona przez most",
94
- "uk": "призначте коментар «з місту» до держави, якщо значення встановлене містом",
95
- "zh-cn": "如果值由桥来设定, 则将注释“ 从桥” 指定为状态"
96
96
  }
97
97
  },
98
98
  "titleLang": {
@@ -221,6 +221,8 @@ class bridgeClass {
221
221
  await this.publishId(this.SubscribedTopics[topic].id, message, {});
222
222
  return;
223
223
  }
224
+
225
+ // Light
224
226
  if (this.SubscribedTopics[topic].light) {
225
227
  if (message.state) {
226
228
  message.state = message.state === 'ON' ? true : false;
@@ -253,6 +255,8 @@ class bridgeClass {
253
255
  }
254
256
  return;
255
257
  }
258
+
259
+ // Cover
256
260
  if (this.SubscribedTopics[topic].cover) {
257
261
  if (this.SubscribedTopics[topic].messageAssign) {
258
262
  if (this.SubscribedTopics[topic].messageAssign[message]) {
@@ -265,6 +269,8 @@ class bridgeClass {
265
269
  }
266
270
  }
267
271
  }
272
+
273
+ // Lock
268
274
  if (this.SubscribedTopics[topic].lock) {
269
275
  if (this.SubscribedTopics[topic].messageAssign) {
270
276
  if (this.SubscribedTopics[topic].messageAssign[message]) {
@@ -280,6 +286,7 @@ class bridgeClass {
280
286
 
281
287
  // Check for namespace and write own, oder foreign state
282
288
  if (this.SubscribedTopics[topic].id.startsWith(this.adapter.namespace)) {
289
+ // Special DataExchange
283
290
  if (this.SubscribedTopics[topic].dataExchange) {
284
291
  if (typeof message === 'object') {
285
292
  message = JSON.stringify(message);
@@ -289,15 +296,19 @@ class bridgeClass {
289
296
  { val: message, c: 'from bridge' },
290
297
  true,
291
298
  );
299
+ // All Adapter internal States
292
300
  } else {
293
301
  await this.adapter.setState(this.SubscribedTopics[topic].id, {
294
302
  val: message,
295
303
  c: 'from bridge',
296
304
  });
297
305
  }
306
+ // Foreign States
298
307
  } else {
308
+ // Assignable Topics => id & val
299
309
  if (this.SubscribedTopics[topic].messageAssign) {
300
310
  await this.adapter.setForeignStateAsync(message.id, { val: message.val, c: 'from bridge' });
311
+ // Write in the desired id
301
312
  } else {
302
313
  await this.adapter.setForeignStateAsync(this.SubscribedTopics[topic].id, {
303
314
  val: message,
@@ -795,59 +806,49 @@ class bridgeClass {
795
806
  }
796
807
 
797
808
  // Iterate the state_topics
798
- for (const publishTopic in this.PublishedIds[id].publish) {
799
- if (this.PublishedIds[id].publish[publishTopic].light) {
809
+ for (const element in this.PublishedIds[id].publish) {
810
+ const topic = element;
811
+ const publish = this.PublishedIds[id].publish[element];
812
+
813
+ // Light
814
+ if (publish.light) {
800
815
  val = {};
801
- val.state = (
802
- await this.adapter.getForeignStateAsync(
803
- this.PublishedIds[id].publish[publishTopic].LightIds.onOff,
804
- )
805
- ).val;
816
+ val.state = (await this.adapter.getForeignStateAsync(publish.LightIds.onOff)).val;
806
817
  val.state = val.state === true ? 'ON' : 'OFF';
807
- if (this.PublishedIds[id].publish[publishTopic].LightIds.brightness) {
808
- val.brightness = (
809
- await this.adapter.getForeignStateAsync(
810
- this.PublishedIds[id].publish[publishTopic].LightIds.brightness,
811
- )
812
- ).val;
818
+ if (publish.LightIds.brightness) {
819
+ val.brightness = (await this.adapter.getForeignStateAsync(publish.LightIds.brightness)).val;
813
820
  }
814
- if (this.PublishedIds[id].publish[publishTopic].LightIds.color) {
821
+ if (publish.LightIds.color) {
815
822
  val.color_mode = 'rgb';
816
823
  val.color = this.hexToRgb(
817
- (
818
- await this.adapter.getForeignStateAsync(
819
- this.PublishedIds[id].publish[publishTopic].LightIds.color,
820
- )
821
- ).val,
824
+ (await this.adapter.getForeignStateAsync(publish.LightIds.color)).val,
822
825
  );
823
826
  }
824
- if (this.PublishedIds[id].publish[publishTopic].LightIds.effects) {
825
- const effect = (
826
- await this.adapter.getForeignStateAsync(
827
- this.PublishedIds[id].publish[publishTopic].LightIds.effects,
828
- )
829
- ).val;
827
+ if (publish.LightIds.effects) {
828
+ const effect = (await this.adapter.getForeignStateAsync(publish.LightIds.effects)).val;
830
829
  val.effect = '';
831
- if (this.PublishedIds[id].publish[publishTopic].effects[effect]) {
832
- val.effect = this.PublishedIds[id].publish[publishTopic].effects[effect];
830
+ if (publish.effects[effect]) {
831
+ val.effect = publish.effects[effect];
833
832
  }
834
833
  }
835
834
  }
836
835
 
837
- if (this.PublishedIds[id].publish[publishTopic].cover) {
838
- if (this.PublishedIds[id].publish[publishTopic].messageAssign) {
839
- if (this.PublishedIds[id].publish[publishTopic].messageAssign[val]) {
840
- val = this.PublishedIds[id].publish[publishTopic].messageAssign[val];
836
+ // Cover
837
+ if (publish.cover) {
838
+ if (publish.messageAssign) {
839
+ if (publish.messageAssign[val]) {
840
+ val = publish.messageAssign[val];
841
841
  } else {
842
842
  return;
843
843
  }
844
844
  }
845
845
  }
846
846
 
847
- if (this.PublishedIds[id].publish[publishTopic].lock) {
848
- if (this.PublishedIds[id].publish[publishTopic].messageAssign) {
849
- if (this.PublishedIds[id].publish[publishTopic].messageAssign[val]) {
850
- val = this.PublishedIds[id].publish[publishTopic].messageAssign[val];
847
+ // Lock
848
+ if (publish.lock) {
849
+ if (publish.messageAssign) {
850
+ if (publish.messageAssign[val]) {
851
+ val = publish.messageAssign[val];
851
852
  } else {
852
853
  return;
853
854
  }
@@ -855,23 +856,21 @@ class bridgeClass {
855
856
  }
856
857
 
857
858
  // safe old values (5 last values)
858
- if (this.PublishedIds[id].publish[publishTopic].values) {
859
- if (!this.PublishedIds[id].publish[publishTopic].oldValues) {
860
- this.PublishedIds[id].publish[publishTopic].oldValues = [];
859
+ if (publish.values) {
860
+ if (!publish.oldValues) {
861
+ publish.oldValues = [];
861
862
  }
862
- if (this.PublishedIds[id].publish[publishTopic].oldValues.length >= this.MaxValueCount) {
863
- this.PublishedIds[id].publish[publishTopic].oldValues.pop();
863
+ if (publish.oldValues.length >= this.MaxValueCount) {
864
+ publish.oldValues.pop();
864
865
  }
865
- this.PublishedIds[id].publish[publishTopic].oldValues.unshift(
866
- structuredClone(this.PublishedIds[id].publish[publishTopic].values),
867
- );
866
+ publish.oldValues.unshift(structuredClone(publish.values));
868
867
  }
869
- if (!this.PublishedIds[id].publish[publishTopic].values) {
870
- this.PublishedIds[id].publish[publishTopic].values = {};
868
+ if (!publish.values) {
869
+ publish.values = {};
871
870
  }
872
- this.PublishedIds[id].publish[publishTopic].values.val = val;
873
- this.PublishedIds[id].publish[publishTopic].values.ts = Date.now();
874
- this.PublishedIds[id].publish[publishTopic].values.time = new Date(Date.now()).toLocaleString(
871
+ publish.values.val = val;
872
+ publish.values.ts = Date.now();
873
+ publish.values.time = new Date(Date.now()).toLocaleString(
875
874
  this.Timeoutput.Argument,
876
875
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
877
876
  // @ts-expect-error
@@ -885,7 +884,7 @@ class bridgeClass {
885
884
  } else if (options.retain === undefined) {
886
885
  options.retain = true;
887
886
  }
888
- await this.bridgeMqttClient.publish(publishTopic, val, options);
887
+ await this.bridgeMqttClient.publish(topic, val, options);
889
888
  await this.adapter.setState('info.publishedIds', JSON.stringify(this.PublishedIds), true);
890
889
  }
891
890
 
@@ -1310,10 +1309,7 @@ class bridgeClass {
1310
1309
  if (!this.oldDiscoveredDevices[normalizedDeficeIdentifier]) {
1311
1310
  // Only messegae with ne fiscovered dewvice, if not in old discovered devices
1312
1311
  returnValue.newDevice = DiscoveryObject;
1313
- let device =
1314
- DiscoveryObject.informations.usedDeviceId ??
1315
- DiscoveryObject.informations[0]?.usedDeviceId ??
1316
- 'unknown';
1312
+ let device = DiscoveryObject.payload.device.name;
1317
1313
  let message = `${this.adapter.i18nTranslation['new device discovered']}.\n${this.adapter.i18nTranslation['Device']}: ${device}`;
1318
1314
  if (DiscoveryObject.informations.usedApplicationName) {
1319
1315
  const application = DiscoveryObject.informations.usedApplicationName;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.lorawan",
3
- "version": "1.18.34",
3
+ "version": "1.18.35",
4
4
  "description": "converts the desired lora gateway data to a ioBroker structure",
5
5
  "author": {
6
6
  "name": "BenAhrdt",