iobroker.lorawan 0.2.1 → 0.3.1

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
@@ -22,6 +22,12 @@ For now there is documentation in English here: http://www.hafenmeister.com/Lora
22
22
  Placeholder for the next version (at the beginning of the line):
23
23
  ### **WORK IN PROGRESS**
24
24
  -->
25
+ ### 0.3.1 (2024-02-15)
26
+ * (BenAhrdt) rebuild with better messageing
27
+
28
+ ### 0.3.0 (2024-02-15)
29
+ * (BenAhrdt) define user friendly Blockly Blocks with result
30
+
25
31
  ### 0.2.1 (2024-02-13)
26
32
  * (BenAhrdt) check types of messaging values and implements more blockly blocks
27
33
 
@@ -149,4 +155,9 @@ SOFTWARE.
149
155
  The rights of the trademarks and company names,
150
156
  remain with their owners and have no relation to this adapter.
151
157
  The fairuse policy must continue to be adhered to by the operator of the adapter.
152
- If this repository is forked, it must be cited as the source.
158
+ If this repository is forked, it must be cited as the source.
159
+
160
+ LoRa® is a registered trademark or service
161
+ mark of Semtech Corporation or its affilantes.
162
+
163
+ LoRaWAN® is a licensed mark.
package/admin/blockly.js CHANGED
@@ -5,26 +5,68 @@
5
5
 
6
6
  // @ts-ignore
7
7
  if (typeof goog !== "undefined") {
8
- // @ts-ignore
9
- // eslint-disable-next-line no-undef
10
8
  goog.provide("Blockly.JavaScript.Sendto");
11
- // @ts-ignore
12
- // eslint-disable-next-line no-undef
13
9
  goog.require("Blockly.JavaScript");
14
10
  }
15
11
 
16
12
 
17
13
  // --- general translations --------------------------------------------------
18
- Blockly.Words["anyInstance"] = {"en": "all instances","pt": "todas as instâncias","pl": "wszystkie przypadki","nl": "alle instanties","it": "tutte le istanze","es": "todas las instancias","fr": "toutes les instances","de": "Alle Instanzen","ru": "На все драйвера"};
19
- Blockly.Words["lorawanDeviceEUI"] = {"en": "device EUI","de": "Geräte EUI","ru": "устройство EUI","pt": "dispositivo EUI","nl": "apparaat EUI","fr": "dispositif IUE","it": "dispositivo EUI","es": "dispositivo EUI","pl": "urządzenie EUI","uk": "пристрій EUI","zh-cn": "设备 EUI"};
14
+ Blockly.Words["anyInstance"] = {
15
+ "en": "all instances",
16
+ "pt": "todas as instâncias",
17
+ "pl": "wszystkie przypadki",
18
+ "nl": "alle instanties",
19
+ "it": "tutte le istanze",
20
+ "es": "todas las instancias",
21
+ "fr": "toutes les instances",
22
+ "de": "Alle Instanzen",
23
+ "ru": "На все драйвера"
24
+ };
25
+ Blockly.Words["lorawanDeviceEUI"] = {
26
+ "en": "device EUI",
27
+ "de": "Device EUI",
28
+ "ru": "устройство EUI",
29
+ "pt": "dispositivo EUI",
30
+ "nl": "apparaat EUI",
31
+ "fr": "dispositif IUE",
32
+ "it": "dispositivo EUI",
33
+ "es": "dispositivo EUI",
34
+ "pl": "urządzenie EUI",
35
+ "uk": "пристрій EUI",
36
+ "zh-cn": "设备 EUI"
37
+ };
20
38
 
21
39
  /**************************************************************************
22
40
  ******************************Get Device Info******************************
23
41
  **************************************************************************/
24
42
 
25
43
  // --- Get DeviceInfo translations --------------------------------------------------
26
- Blockly.Words["lorawanGetDeviceInfo"] = {"en": "lorawan Device Info", "de": "lorawan Geräteinfo", "ru": "lorawan Device Info", "pt": "lorawan Informações do dispositivo", "nl": "lorawan Apparaatinformatie", "fr": "lorawan Informations sur le périphérique", "it": "lorawan Dispositivi Info", "es": "lorawan Device Info", "pl": "informacje o urządzeniu Lorawan", "uk": "інформація про пристрій lorawan", "zh-cn": "lorawan 设备信息"};
27
- Blockly.Words["lorawanGetDeviceInfotooltip"] = {"en": "get Informations about the device with the given device EUI", "de": "informationen über das Gerät mit der angegebenen Geräte EUI", "ru": "получить информацию об устройстве с данным устройством EUI", "pt": "obter informações sobre o dispositivo com o dispositivo dado EUI", "nl": "informatie over het apparaat met het gegeven apparaat opvragen EUI", "fr": "obtenir des informations sur l'appareil avec l'appareil donné IUE", "it": "ottenere informazioni sul dispositivo con il dispositivo fornito EUI", "es": "obtener Información sobre el dispositivo con el dispositivo dado EUI", "pl": "pobierz informacje o urządzeniu z podanym urządzeniem EUI", "uk": "отримувати інформацію про пристрій з заданим пристроєм EUI", "zh-cn": "用指定的设备获取设备信息 EUI"};
44
+ Blockly.Words["lorawanGetDeviceInfo"] = {
45
+ "en": "lorawan Device Info",
46
+ "de": "lorawan Geräteinfo",
47
+ "ru": "lorawan Device Info",
48
+ "pt": "lorawan Informações do dispositivo",
49
+ "nl": "lorawan Apparaatinformatie",
50
+ "fr": "lorawan Informations sur le périphérique",
51
+ "it": "lorawan Dispositivi Info",
52
+ "es": "lorawan Device Info",
53
+ "pl": "informacje o urządzeniu Lorawan",
54
+ "uk": "інформація про пристрій lorawan",
55
+ "zh-cn": "lorawan 设备信息"
56
+ };
57
+ Blockly.Words["lorawanGetDeviceInfotooltip"] = {
58
+ "en": "get Informations about the device with the given device EUI",
59
+ "de": "Informationen über das Gerät mit der angegebenen Geräte EUI",
60
+ "ru": "получить информацию об устройстве с данным устройством EUI",
61
+ "pt": "obter informações sobre o dispositivo com o dispositivo dado EUI",
62
+ "nl": "informatie over het apparaat met het gegeven apparaat opvragen EUI",
63
+ "fr": "obtenir des informations sur l'appareil avec l'appareil donné IUE",
64
+ "it": "ottenere informazioni sul dispositivo con il dispositivo fornito EUI",
65
+ "es": "obtener Información sobre el dispositivo con el dispositivo dado EUI",
66
+ "pl": "pobierz informacje o urządzeniu z podanym urządzeniem EUI",
67
+ "uk": "отримувати інформацію про пристрій з заданим пристроєм EUI",
68
+ "zh-cn": "用指定的设备获取设备信息 EUI"
69
+ };
28
70
 
29
71
  // eslint-disable-next-line no-undef
30
72
  Blockly.Sendto.blocks["lorawanGetDeviceInfo"] =
@@ -70,15 +112,32 @@ Blockly.Blocks["lorawanGetDeviceInfo"] = {
70
112
  this.appendValueInput("deviceEUI")
71
113
  .appendField(Blockly.Translate("lorawanDeviceEUI"));
72
114
 
115
+ this.appendStatementInput("result");
116
+
117
+ this.setInputsInline(false);
118
+ this.setPreviousStatement(true, null);
119
+ this.setNextStatement(true, null);
120
+
73
121
  this.setColour(Blockly.Sendto.HUE);
74
122
  this.setTooltip(Blockly.Translate("lorawanGetDeviceInfotooltip"));
75
123
  }
76
124
  };
77
125
 
78
126
  Blockly.JavaScript["lorawanGetDeviceInfo"] = function(block){
79
- const dropdown_instance = block.getFieldValue("INSTANCE");
80
127
  const value_devEUI = Blockly.JavaScript.valueToCode(block, "deviceEUI", Blockly.JavaScript.ORDER_ATOMIC);
81
- return 'sendTo("lorawan' + dropdown_instance + '", "getDeviceInfo", {deviceEUI: ' + value_devEUI + "}, async (result) => {console.log(result);});";
128
+ const code_result = Blockly.JavaScript.statementToCode(block, "result");
129
+
130
+ // build code
131
+ const objParameter = [];
132
+ objParameter.push("deviceEUI:" + value_devEUI);
133
+ const objEnd = [];
134
+ if(code_result){
135
+ objEnd.push(`, async (result) => {${code_result}});`);
136
+ }
137
+ else{
138
+ objEnd.push(`);`);
139
+ }
140
+ return `sendTo("lorawan${block.getFieldValue("INSTANCE")}", "getDeviceInfo", {${objParameter.join(",")}}${objEnd}`;
82
141
  };
83
142
 
84
143
  /**************************************************************************
@@ -86,10 +145,58 @@ Blockly.JavaScript["lorawanGetDeviceInfo"] = function(block){
86
145
  **************************************************************************/
87
146
 
88
147
  // --- Get DeviceInfo translations --------------------------------------------------
89
- Blockly.Words["lorawanGetUplink"] = {"en": "lorawan uplinkinfo", "de": "lorawan uplinkinfo", "ru": "lorawan uplinkinfo", "pt": "o que fazer", "nl": "lorawan uplinkinfo", "fr": "lorawan uplinkinfo", "it": "condividi su google", "es": "lorawan uplinkinfo", "pl": "lorawan uplinkinfo", "uk": "український", "zh-cn": "lorawan 上行链接信息"};
90
- Blockly.Words["lorawanGetUplinktooltip"] = {"en": "get information about the given uplink", "de": "informationen zum angegebenen uplink", "ru": "получить информацию об отказе от ссылки", "pt": "obter informações sobre o link fornecido", "nl": "informatie krijgen over de opgegeven uplink", "fr": "obtenir des informations sur le lien ascendant donné", "it": "ottenere informazioni su il link up", "es": "obtener información sobre el enlace dado", "pl": "uzyskać informacje o danym łączniku", "uk": "отримувати інформацію про задану посилання", "zh-cn": "获取上行链路的信息"};
91
- Blockly.Words["lorawanUplink"] = {"en": "uplink","de": "uplink","ru": "uplink", "pt": "o que é","nl": "uplink","fr": "lien ascendant","it": "uplink","es": "subtítulos","pl": "link","uk": "посилання","zh-cn": "上行链接"};
92
- Blockly.Words["lorawanSubfolder"] = {"en": "subfolder", "de": "unterordner", "ru": "subfolder", "pt": "subpastas", "nl": "submap", "fr": "sous-dossier", "it": "sottocartella", "es": "subcarpeta", "pl": "podfolder", "uk": "підпалювач", "zh-cn": "子文件夹"};
148
+ Blockly.Words["lorawanGetUplink"] = {
149
+ "en": "lorawan uplinkinfo",
150
+ "de": "lorawan uplinkinfo",
151
+ "ru": "lorawan uplinkinfo",
152
+ "pt": "o que fazer",
153
+ "nl": "lorawan uplinkinfo",
154
+ "fr": "lorawan uplinkinfo",
155
+ "it": "condividi su google",
156
+ "es": "lorawan uplinkinfo",
157
+ "pl": "lorawan uplinkinfo",
158
+ "uk": "український",
159
+ "zh-cn": "lorawan 上行链接信息"
160
+ };
161
+ Blockly.Words["lorawanGetUplinktooltip"] = {
162
+ "en": "get information about the given uplink",
163
+ "de": "Informationen zum angegebenen uplink",
164
+ "ru": "получить информацию об отказе от ссылки",
165
+ "pt": "obter informações sobre o link fornecido",
166
+ "nl": "informatie krijgen over de opgegeven uplink",
167
+ "fr": "obtenir des informations sur le lien ascendant donné",
168
+ "it": "ottenere informazioni su il link up",
169
+ "es": "obtener información sobre el enlace dado",
170
+ "pl": "uzyskać informacje o danym łączniku",
171
+ "uk": "отримувати інформацію про задану посилання",
172
+ "zh-cn": "获取上行链路的信息"
173
+ };
174
+ Blockly.Words["lorawanUplink"] = {
175
+ "en": "uplink",
176
+ "de": "Uplink",
177
+ "ru": "uplink",
178
+ "pt": "o que é",
179
+ "nl": "uplink",
180
+ "fr": "lien ascendant",
181
+ "it": "uplink",
182
+ "es": "subtítulos",
183
+ "pl": "link",
184
+ "uk": "посилання",
185
+ "zh-cn": "上行链接"
186
+ };
187
+ Blockly.Words["lorawanSubfolder"] = {
188
+ "en": "subfolder",
189
+ "de": "Unterordner",
190
+ "ru": "subfolder",
191
+ "pt": "subpastas",
192
+ "nl": "submap",
193
+ "fr": "sous-dossier",
194
+ "it": "sottocartella",
195
+ "es": "subcarpeta",
196
+ "pl": "podfolder",
197
+ "uk": "підпалювач",
198
+ "zh-cn": "子文件夹"
199
+ };
93
200
 
94
201
  // eslint-disable-next-line no-undef
95
202
  Blockly.Sendto.blocks["lorawanGetUplink"] =
@@ -151,17 +258,36 @@ Blockly.Blocks["lorawanGetUplink"] = {
151
258
  this.appendValueInput("subfolder")
152
259
  .appendField(Blockly.Translate("lorawanSubfolder"));
153
260
 
261
+ this.appendStatementInput("result");
262
+
263
+ this.setInputsInline(false);
264
+ this.setPreviousStatement(true, null);
265
+ this.setNextStatement(true, null);
266
+
154
267
  this.setColour(Blockly.Sendto.HUE);
155
268
  this.setTooltip(Blockly.Translate("lorawanGetUplinktooltip"));
156
269
  }
157
270
  };
158
271
 
159
272
  Blockly.JavaScript["lorawanGetUplink"] = function(block){
160
- const dropdown_instance = block.getFieldValue("INSTANCE");
161
273
  const value_devEUI = Blockly.JavaScript.valueToCode(block, "deviceEUI", Blockly.JavaScript.ORDER_ATOMIC);
162
274
  const value_uplink = Blockly.JavaScript.valueToCode(block, "uplink", Blockly.JavaScript.ORDER_ATOMIC);
163
275
  const value_subfolder = Blockly.JavaScript.valueToCode(block, "subfolder", Blockly.JavaScript.ORDER_ATOMIC);
164
- return 'sendTo("lorawan' + dropdown_instance + '", "getUplink", {deviceEUI: ' + value_devEUI + ", uplink: " + value_uplink + ", subfolder: " + value_subfolder +"}, async (result) => {console.log(result);});";
276
+ const code_result = Blockly.JavaScript.statementToCode(block, "result");
277
+
278
+ // build code
279
+ const objParameter = [];
280
+ objParameter.push("deviceEUI:" + value_devEUI);
281
+ objParameter.push("uplink:" + value_uplink);
282
+ objParameter.push("subfolder:" + value_subfolder);
283
+ const objEnd = [];
284
+ if(code_result){
285
+ objEnd.push(`, async (result) => {${code_result}});`);
286
+ }
287
+ else{
288
+ objEnd.push(`);`);
289
+ }
290
+ return `sendTo("lorawan${block.getFieldValue("INSTANCE")}", "getUplink", {${objParameter.join(",")}}${objEnd}`;
165
291
  };
166
292
 
167
293
  /**************************************************************************
@@ -169,9 +295,58 @@ Blockly.JavaScript["lorawanGetUplink"] = function(block){
169
295
  **************************************************************************/
170
296
 
171
297
  // --- Get DeviceInfo translations --------------------------------------------------
172
- Blockly.Words["lorawanSetDownlink"] = {"en": "lorawan downlink", "de": "lorawan downlink", "ru": "lorawan downlink", "pt": "para baixo", "nl": "lorawan downlink", "fr": "lorawan lien descendant", "it": "lorawan downlink", "es": "lorawan downlink", "pl": "lorawan downlink", "uk": "логін", "zh-cn": "龙卷风下行链路"};
173
- Blockly.Words["lorawanSetDownlinktooltip"] = {"en": "set downlink", "de": "downlink zur lorawan instanz absetzen", "ru": "set downlink", "pt": "definir link", "nl": "downlink instellen", "fr": "définir la liaison descendante", "it": "impostare il collegamento", "es": "desplazamiento", "pl": "set downlink", "uk": "увійти", "zh-cn": "设置下行链路"};
174
- Blockly.Words["lorawanDownlink"] = {"en": "downlink","de": "downlink","ru": "downlink", "pt": "o que é","nl": "downlink","fr": "lien ascendant","it": "downlink","es": "subtítulos","pl": "link","uk": "посилання","zh-cn": "上行链接"};
298
+ Blockly.Words["lorawanSetDownlink"] = {
299
+ "en": "lorawan downlink",
300
+ "de": "lorawan downlink",
301
+ "ru": "lorawan downlink",
302
+ "pt": "para baixo",
303
+ "nl": "lorawan downlink",
304
+ "fr": "lorawan lien descendant",
305
+ "it": "lorawan downlink",
306
+ "es": "lorawan downlink",
307
+ "pl": "lorawan downlink",
308
+ "uk": "логін",
309
+ "zh-cn": "龙卷风下行链路"
310
+ };
311
+ Blockly.Words["lorawanSetDownlinktooltip"] = {
312
+ "en": "set downlink",
313
+ "de": "Downlink zur lorawan instanz absetzen",
314
+ "ru": "set downlink",
315
+ "pt": "definir link",
316
+ "nl": "downlink instellen",
317
+ "fr": "définir la liaison descendante",
318
+ "it": "impostare il collegamento",
319
+ "es": "desplazamiento",
320
+ "pl": "set downlink",
321
+ "uk": "увійти",
322
+ "zh-cn": "设置下行链路"
323
+ };
324
+ Blockly.Words["lorawanDownlink"] = {
325
+ "en": "downlink",
326
+ "de": "Downlink",
327
+ "ru": "downlink",
328
+ "pt": "o que é",
329
+ "nl": "downlink",
330
+ "fr": "lien ascendant",
331
+ "it": "downlink",
332
+ "es": "subtítulos",
333
+ "pl": "link",
334
+ "uk": "посилання",
335
+ "zh-cn": "上行链接"
336
+ };
337
+ Blockly.Words["lorawanValue"] = {
338
+ "en": "value",
339
+ "de": "Wert",
340
+ "ru": "стоимость",
341
+ "pt": "valor",
342
+ "nl": "waarde",
343
+ "fr": "valeur",
344
+ "it": "valore",
345
+ "es": "valor",
346
+ "pl": "wartość",
347
+ "uk": "значення",
348
+ "zh-cn": "价值"
349
+ };
175
350
 
176
351
  // eslint-disable-next-line no-undef
177
352
  Blockly.Sendto.blocks["lorawanSetDownlink"] =
@@ -188,9 +363,9 @@ Blockly.Sendto.blocks["lorawanSetDownlink"] =
188
363
  + " <field name='TEXT'>text</field>"
189
364
  + " </shadow>"
190
365
  + " </value>"
191
- + " <value name='xxxx'>"
366
+ + " <value name='value'>"
192
367
  + " <shadow type='text'>"
193
- + " <field name='xx'>cc</field>"
368
+ + " <field name='text'></field>"
194
369
  + " </shadow>"
195
370
  + " </value>"
196
371
  + "</block>";
@@ -229,14 +404,37 @@ Blockly.Blocks["lorawanSetDownlink"] = {
229
404
  this.appendValueInput("downlink")
230
405
  .appendField(Blockly.Translate("lorawanDownlink"));
231
406
 
407
+ this.appendValueInput("value")
408
+ .appendField(Blockly.Translate("lorawanValue"));
409
+
410
+ this.appendStatementInput("result");
411
+
412
+ this.setInputsInline(false);
413
+ this.setPreviousStatement(true, null);
414
+ this.setNextStatement(true, null);
415
+
232
416
  this.setColour(Blockly.Sendto.HUE);
233
417
  this.setTooltip(Blockly.Translate("lorawanSetDownlinktooltip"));
234
418
  }
235
419
  };
236
420
 
237
421
  Blockly.JavaScript["lorawanSetDownlink"] = function(block){
238
- const dropdown_instance = block.getFieldValue("INSTANCE");
239
422
  const value_devEUI = Blockly.JavaScript.valueToCode(block, "deviceEUI", Blockly.JavaScript.ORDER_ATOMIC);
240
423
  const value_downlink = Blockly.JavaScript.valueToCode(block, "downlink", Blockly.JavaScript.ORDER_ATOMIC);
241
- return 'sendTo("lorawan' + dropdown_instance + '", "setDownlink", {deviceEUI: ' + value_devEUI + ", downlink: " + value_downlink +"}, async (result) => {console.log(result);});";
424
+ const value_value = Blockly.JavaScript.valueToCode(block, "value", Blockly.JavaScript.ORDER_ATOMIC);
425
+ const code_result = Blockly.JavaScript.statementToCode(block, "result");
426
+
427
+ // build code
428
+ const objParameter = [];
429
+ objParameter.push("deviceEUI:" + value_devEUI);
430
+ objParameter.push("downlink:" + value_downlink);
431
+ objParameter.push("value:" + value_value);
432
+ const objEnd = [];
433
+ if(code_result){
434
+ objEnd.push(`, async (result) => {${code_result}});`);
435
+ }
436
+ else{
437
+ objEnd.push(`);`);
438
+ }
439
+ return `sendTo("lorawan${block.getFieldValue("INSTANCE")}", "setDownlink", {${objParameter.join(",")}}${objEnd}`;
242
440
  };
package/io-package.json CHANGED
@@ -1,8 +1,34 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "lorawan",
4
- "version": "0.2.1",
4
+ "version": "0.3.1",
5
5
  "news": {
6
+ "0.3.1": {
7
+ "en": "rebuild with better messageing",
8
+ "de": "neuaufbau mit besserer botschaft",
9
+ "ru": "перестроить с лучшим сообщением",
10
+ "pt": "reconstruir com melhor mensagem",
11
+ "nl": "herbouwen met betere berichtgeving",
12
+ "fr": "reconstruire avec un meilleur message",
13
+ "it": "ricostruire con messaggi migliori",
14
+ "es": "reconstruir con mejor mensaje",
15
+ "pl": "odbudowa dzięki lepszemu rozwiązywaniu problemów",
16
+ "uk": "перебудувати краще повідомлення",
17
+ "zh-cn": "以更好的信息重建"
18
+ },
19
+ "0.3.0": {
20
+ "en": "define user friendly Blockly Blocks with result",
21
+ "de": "benutzerfreundlich definieren Blockly Blocks mit Ergebnis",
22
+ "ru": "определение пользователя Блоки с результатом",
23
+ "pt": "definir amigável Blocos com resultado",
24
+ "nl": "gebruikersvriendelijk definiëren Blokkeren met resultaat",
25
+ "fr": "définir une utilisation conviviale Blocs avec résultat",
26
+ "it": "definire l'utente amichevole Blocchi Blockly con risultato",
27
+ "es": "definir fácil de usar Bloqueo bloques con resultado",
28
+ "pl": "zdefiniować przyjazny dla użytkownika Blokady z wynikiem",
29
+ "uk": "визначення дружності користувача Блокнотні блоки з результатом",
30
+ "zh-cn": "定义用户友好 块状块及结果"
31
+ },
6
32
  "0.2.1": {
7
33
  "en": "check types of messaging values and implements more blockly blocks",
8
34
  "de": "überprüfen sie die arten der messaging-werte und implementiert mehr blockweise blöcke",
@@ -67,32 +93,6 @@
67
93
  "pl": "min / max wartości dla downlink- configs (liczba)",
68
94
  "uk": "min / максимальні значення для налаштувань посилань (номер)",
69
95
  "zh-cn": "下行链路配置最小值( 数)"
70
- },
71
- "0.1.10": {
72
- "en": "default of crc changed",
73
- "de": "standard von cc geändert",
74
- "ru": "по умолчанию",
75
- "pt": "padrão de crc alterado",
76
- "nl": "default van crc gewijzigd",
77
- "fr": "défaut de changement de crc",
78
- "it": "default di crc cambiato",
79
- "es": "por defecto de crc cambiado",
80
- "pl": "domyślna zmiana crc",
81
- "uk": "за замовчуванням змінного струму",
82
- "zh-cn": "默认 crc 已更改"
83
- },
84
- "0.1.9": {
85
- "en": "crc calculation improoved",
86
- "de": "cc berechnung improoviert",
87
- "ru": "crccalc improov",
88
- "pt": "cálculo de crc improoved",
89
- "nl": "crc berekening geïmproviseerd",
90
- "fr": "calcul crc réalisé",
91
- "it": "crc calcolo improvato",
92
- "es": "crc cálculo improvido",
93
- "pl": "crc obliczenia improuved",
94
- "uk": "розрахунок обертів",
95
- "zh-cn": "crc 计算未启动"
96
96
  }
97
97
  },
98
98
  "title": "LoRaWAN",
@@ -202,7 +202,7 @@ class directorieshandlerClass {
202
202
  role: stateCommonRole,
203
203
  read: stateCommonRole !== "button",
204
204
  unit: obj[elementName]? obj[elementName].CommonStateUnit? obj[elementName].CommonStateUnit : "" : "",
205
- def: obj[elementName]? obj[elementName].stateCommonDef? obj[elementName].stateCommonDef: stateCommonType === "boolean"? false : stateCommonType === "number"? 0: "": stateCommonType === "number"? 0: "",
205
+ def: obj[elementName] || typeof obj[elementName] === "boolean" ? obj[elementName].stateCommonDef? obj[elementName].stateCommonDef: stateCommonType === "boolean"? false : stateCommonType === "number"? 0: "": stateCommonType === "number"? 0: "",
206
206
  write: stateCommonWrite
207
207
  },
208
208
  native: {},
package/main.js CHANGED
@@ -407,14 +407,40 @@ class Lorawan extends utils.Adapter {
407
407
  if(obj.message.deviceEUI){
408
408
  const changeInfo = await this.getChangeInfoFromDeviceEUI(obj.message.deviceEUI,`${this.messagehandler?.directoryhandler.reachableSubfolders.configuration}.devicetype`);
409
409
  if(changeInfo){
410
- result = {applicationId: changeInfo.applicationId, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, deviceType: changeInfo.deviceType};
410
+ result = {applicationId: changeInfo.applicationId, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, deviceType: changeInfo.deviceType, recieved:obj.message};
411
411
  }
412
412
  else{
413
- result = {error:true, message:"No device found"};
413
+ result = {error:true, message:"No device found", recieved:obj.message};
414
414
  }
415
415
  }
416
416
  else{
417
- result = {error:true, message:"No deviceEUI found"};
417
+ result = {error:true, message:"No deviceEUI found", recieved:obj.message};
418
+ }
419
+ // Send response
420
+ if (obj.callback) this.sendTo(obj.from, obj.command, result, obj.callback);
421
+ }
422
+ else if (obj.command === "getUplink"){
423
+ if(obj.message.deviceEUI && obj.message.uplink){
424
+ const folderAndUplinkId = obj.message.subfolder? `${this.messagehandler?.directoryhandler.reachableSubfolders.uplink}.${obj.message.subfolder}.${obj.message.uplink}`: obj.message.uplink;
425
+ const changeInfo = await this.getChangeInfoFromDeviceEUI(obj.message.deviceEUI,folderAndUplinkId);
426
+ if(changeInfo){
427
+ const uplinkId = changeInfo.id;
428
+ if(await this.objectExists(uplinkId)){
429
+ const stateResult = await this.getStateAsync(changeInfo.id);
430
+ if(stateResult){
431
+ result = {applicationId: changeInfo.applicationId, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, deviceType: changeInfo.deviceType, value: stateResult.val, recieved:obj.message};
432
+ }
433
+ }
434
+ else{
435
+ result = {error:true, message:"No uplink matches", recieved:obj.message};
436
+ }
437
+ }
438
+ else{
439
+ result = {error:true, message:"No device found", recieved:obj.message};
440
+ }
441
+ }
442
+ else{
443
+ result = {error:true, message:"No deviceEUI & uplink found", recieved:obj.message};
418
444
  }
419
445
  // Send response
420
446
  if (obj.callback) this.sendTo(obj.from, obj.command, result, obj.callback);
@@ -434,66 +460,45 @@ class Lorawan extends utils.Adapter {
434
460
  // Check limit
435
461
  if((!downlinkObject.common.min || obj.message.value >= downlinkObject.common.min) && (!downlinkObject.common.max || obj.message.value <= downlinkObject.common.max)){
436
462
  await this.setStateAsync(downlinkId,obj.message.value);
437
- result = {applicationId: changeInfo.applicationId, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, deviceType: changeInfo.deviceType,downlink: obj.message.downlink, value: obj.message.value};
463
+ result = {applicationId: changeInfo.applicationId, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, deviceType: changeInfo.deviceType, downlink: obj.message.downlink, value: obj.message.value, recieved:obj.message};
438
464
  }
439
465
  else{
440
- result = {error:true, message:"value is not in valid range"};
466
+ result = {error:true, message:"value is not in valid range", recieved:obj.message};
441
467
  }
442
468
  }
443
469
  else{
444
- result = {error:true, message: `downlink is type number, but recieved ${typeof obj.message.value}`};
470
+ result = {error:true, message: `downlink is type number, but recieved ${typeof obj.message.value}`, recieved:obj.message};
445
471
  }
446
472
  }
447
473
  // downlinkobject is not a number
448
474
  else{
449
- await this.setStateAsync(downlinkId,obj.message.value);
450
- result = {applicationId: changeInfo.applicationId, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, deviceType: changeInfo.deviceType, downlink: obj.message.downlink, value: obj.message.value};
475
+ if(downlinkObject.common.type !== typeof obj.message.value){
476
+ result = {error:true, message: `downlink is type ${downlinkObject.common.type}, but recieved ${typeof obj.message.value}`, recieved:obj.message};
477
+ }
478
+ else{
479
+ await this.setStateAsync(downlinkId,obj.message.value);
480
+ result = {applicationId: changeInfo.applicationId, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, deviceType: changeInfo.deviceType, downlink: obj.message.downlink, value: obj.message.value, recieved:obj.message};
481
+ }
451
482
  }
452
483
  }
453
484
  }
454
485
  else{
455
- result = {error:true, message:"No downlink matches"};
456
- }
457
- }
458
- else{
459
- result = {error:true, message:"No device found"};
460
- }
461
- }
462
- else{
463
- result = {error:true, message:"No deviceEUI, downlink & value found"};
464
- }
465
- // Send response
466
- if (obj.callback) this.sendTo(obj.from, obj.command, result, obj.callback);
467
- }
468
- else if (obj.command === "getUplink"){
469
- if(obj.message.deviceEUI && obj.message.uplink){
470
- const folderAndUplinkId = obj.message.subfolder? `${this.messagehandler?.directoryhandler.reachableSubfolders.uplink}.${obj.message.subfolder}.${obj.message.uplink}`: obj.message.uplink;
471
- const changeInfo = await this.getChangeInfoFromDeviceEUI(obj.message.deviceEUI,folderAndUplinkId);
472
- if(changeInfo){
473
- const uplinkId = changeInfo.id;
474
- if(await this.objectExists(uplinkId)){
475
- const stateResult = await this.getStateAsync(changeInfo.id);
476
- if(stateResult){
477
- result = {applicationId: changeInfo.applicationId, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, deviceType: changeInfo.deviceType, value: stateResult.val};
478
- }
479
- }
480
- else{
481
- result = {error:true, message:"No uplink matches", changeInfo: changeInfo};
486
+ result = {error:true, message:"No downlink matches", recieved:obj.message};
482
487
  }
483
488
  }
484
489
  else{
485
- result = {error:true, message:"No device found"};
490
+ result = {error:true, message:"No device found", recieved:obj.message};
486
491
  }
487
492
  }
488
493
  else{
489
- result = {error:true, message:"No deviceEUI & uplink found"};
494
+ result = {error:true, message:"No deviceEUI, downlink & value found", recieved:obj.message};
490
495
  }
491
496
  // Send response
492
497
  if (obj.callback) this.sendTo(obj.from, obj.command, result, obj.callback);
493
498
  }
494
499
  else
495
500
  {
496
- const result = {error:true, message: "No message matched"};
501
+ const result = {error:true, message: "No message matched", recieved:obj.message};
497
502
  if (obj.callback) this.sendTo(obj.from, obj.command, result, obj.callback);
498
503
  }
499
504
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.lorawan",
3
- "version": "0.2.1",
3
+ "version": "0.3.1",
4
4
  "description": "converts the desired lora gateway data to a ioBroker structure",
5
5
  "author": {
6
6
  "name": "BenAhrdt",