iobroker.lorawan 0.1.13 → 0.2.0

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,9 @@ 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.2.0 (2024-02-12)
26
+ * (BenAhrdt) more functionality in messageing
27
+
25
28
  ### 0.1.13 (2024-02-12)
26
29
  * (BenAhrdt) building of directory changed and message implemented
27
30
 
package/io-package.json CHANGED
@@ -1,8 +1,21 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "lorawan",
4
- "version": "0.1.13",
4
+ "version": "0.2.0",
5
5
  "news": {
6
+ "0.2.0": {
7
+ "en": "more functionality in messageing",
8
+ "de": "mehr funktionalität in der meldung",
9
+ "ru": "больше функциональности в сообщении",
10
+ "pt": "mais funcionalidade em mensagens",
11
+ "nl": "meer functionaliteit in berichtgeving",
12
+ "fr": "plus de fonctionnalité dans la messagerie",
13
+ "it": "più funzionalità nel messaggio",
14
+ "es": "más funcionalidad en el mensaje",
15
+ "pl": "większa funkcjonalność w zakresie rozwiązywania problemów",
16
+ "uk": "більше функцій в повідомленнях",
17
+ "zh-cn": "信件中更多的功能"
18
+ },
6
19
  "0.1.13": {
7
20
  "en": "building of directory changed and message implemented",
8
21
  "de": "aufbau des geänderten verzeichnisses und der implementierten meldung",
@@ -80,19 +93,6 @@
80
93
  "pl": "implementation crc calculation",
81
94
  "uk": "реалізація розрахунку кришки",
82
95
  "zh-cn": "执行计算"
83
- },
84
- "0.1.7": {
85
- "en": "change filter on statechange",
86
- "de": "änderungsfilter auf statechange",
87
- "ru": "изменение фильтра для изменения состояния",
88
- "pt": "filtro de mudança de estado",
89
- "nl": "filter wijzigen bij statusverandering",
90
- "fr": "modifier le filtre sur le changement d'état",
91
- "it": "cambiare il filtro sul cambio di stato",
92
- "es": "filtro de cambio en el cambio de estado",
93
- "pl": "zmienić filtr na statechange",
94
- "uk": "зміна фільтра на державну зміну",
95
- "zh-cn": "状态更改过滤器"
96
96
  }
97
97
  },
98
98
  "title": "LoRaWAN",
package/main.js CHANGED
@@ -375,6 +375,20 @@ class Lorawan extends utils.Adapter {
375
375
  return id;
376
376
  }
377
377
 
378
+ // Get Chnageinfo in case of device EUI (used more times in onMessage)
379
+ async getChangeInfoFromDeviceEUI(deviceUI,subId){
380
+ let changeInfo = undefined;
381
+ const adapterObjects = await this.getAdapterObjectsAsync();
382
+ for(const adapterObject of Object.values(adapterObjects)){
383
+ if(adapterObject.type === "device"){
384
+ if(adapterObject._id.indexOf(deviceUI) !== -1){
385
+ changeInfo = await this.getChangeInfo(`${adapterObject._id}.${subId}`);
386
+ break;
387
+ }
388
+ }
389
+ }
390
+ return changeInfo;
391
+ }
378
392
 
379
393
  // If you need to accept messages in your adapter, uncomment the following block and the corresponding line in the constructor.
380
394
  // /**
@@ -389,18 +403,9 @@ class Lorawan extends utils.Adapter {
389
403
  let result = {};
390
404
  if(obj.command === "getDeviceInfo"){
391
405
  if(obj.message.deviceEUI){
392
- let changeInfo = undefined;
393
- const adapterObjects = await this.getAdapterObjectsAsync();
394
- for(const adapterObject of Object.values(adapterObjects)){
395
- if(adapterObject.type === "device"){
396
- if(adapterObject._id.indexOf(obj.message.deviceEUI) !== -1){
397
- changeInfo = await this.getChangeInfo(`${adapterObject._id}.${this.messagehandler?.directoryhandler.reachableSubfolders.configuration}.devicetype`);
398
- break;
399
- }
400
- }
401
- }
406
+ const changeInfo = await this.getChangeInfoFromDeviceEUI(obj.message.deviceEUI,`${this.messagehandler?.directoryhandler.reachableSubfolders.configuration}.devicetype`);
402
407
  if(changeInfo){
403
- result = {applicationId: changeInfo.applicationId, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId};
408
+ result = {applicationId: changeInfo.applicationId, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, deviceType: changeInfo.deviceType};
404
409
  }
405
410
  else{
406
411
  result = {error:true, message:"No device found"};
@@ -414,18 +419,9 @@ class Lorawan extends utils.Adapter {
414
419
  }
415
420
  else if (obj.command === "sendDownlink"){
416
421
  if(obj.message.deviceEUI && obj.message.downlink && (obj.message.value || obj.message.value === false)){
417
- let changeInfo = undefined;
418
- const adapterObjects = await this.getAdapterObjectsAsync();
419
- for(const adapterObject of Object.values(adapterObjects)){
420
- if(adapterObject.type === "device"){
421
- if(adapterObject._id.indexOf(obj.message.deviceEUI) !== -1){
422
- changeInfo = await this.getChangeInfo(`${adapterObject._id}.${this.messagehandler?.directoryhandler.reachableSubfolders.downlinkControl}.${obj.message.downlink}`);
423
- break;
424
- }
425
- }
426
- }
422
+ const changeInfo = await this.getChangeInfoFromDeviceEUI(obj.message.deviceEUI,`${this.messagehandler?.directoryhandler.reachableSubfolders.downlinkControl}.${obj.message.downlink}`);
427
423
  if(changeInfo){
428
- const downlinkId = `${changeInfo.id}`;
424
+ const downlinkId = changeInfo.id;
429
425
  if(await this.objectExists(downlinkId)){
430
426
  const downlinkParameter = this.downlinkConfighandler?.getDownlinkParameter(changeInfo);
431
427
  // downlinkvalue is type number
@@ -433,7 +429,7 @@ class Lorawan extends utils.Adapter {
433
429
  // Check limit
434
430
  if((!downlinkParameter.limitMin || obj.message.value >= downlinkParameter.limitMinValue) && (!downlinkParameter.limitMax || obj.message.value <= downlinkParameter.limitMaxValue)){
435
431
  await this.setStateAsync(downlinkId,obj.message.value);
436
- result = {applicationId: changeInfo.applicationId, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, downlink: obj.message.downlink, value: obj.message.value};
432
+ result = {applicationId: changeInfo.applicationId, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, deviceType: changeInfo.deviceType,downlink: obj.message.downlink, value: obj.message.value};
437
433
  }
438
434
  else{
439
435
  result = {error:true, message:"value is not in valid range"};
@@ -442,7 +438,7 @@ class Lorawan extends utils.Adapter {
442
438
  // downlinkvalue not a number
443
439
  else{
444
440
  await this.setStateAsync(downlinkId,obj.message.value);
445
- result = {applicationId: changeInfo.applicationId, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, downlink: obj.message.downlink, value: obj.message.value};
441
+ result = {applicationId: changeInfo.applicationId, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, deviceType: changeInfo.deviceType, downlink: obj.message.downlink, value: obj.message.value};
446
442
  }
447
443
  }
448
444
  else{
@@ -459,7 +455,33 @@ class Lorawan extends utils.Adapter {
459
455
  // Send response
460
456
  if (obj.callback) this.sendTo(obj.from, obj.command, result, obj.callback);
461
457
  }
462
- else{
458
+ else if (obj.command === "getUplinkDecoded"){
459
+ if(obj.message.deviceEUI && obj.message.uplink){
460
+ const changeInfo = await this.getChangeInfoFromDeviceEUI(obj.message.deviceEUI,`${this.messagehandler?.directoryhandler.reachableSubfolders.uplinkDecoded}.${obj.message.uplink}`);
461
+ if(changeInfo){
462
+ const uplinkId = changeInfo.id;
463
+ if(await this.objectExists(uplinkId)){
464
+ const stateResult = await this.getStateAsync(changeInfo.id);
465
+ if(stateResult){
466
+ result = {applicationId: changeInfo.applicationId, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, deviceType: changeInfo.deviceType, value: stateResult.val};
467
+ }
468
+ }
469
+ else{
470
+ result = {error:true, message:"No uplink matches"};
471
+ }
472
+ }
473
+ else{
474
+ result = {error:true, message:"No device found"};
475
+ }
476
+ }
477
+ else{
478
+ result = {error:true, message:"No deviceEUI & uplink found"};
479
+ }
480
+ // Send response
481
+ if (obj.callback) this.sendTo(obj.from, obj.command, result, obj.callback);
482
+ }
483
+ else
484
+ {
463
485
  const result = {error:true, message: "No message matched"};
464
486
  if (obj.callback) this.sendTo(obj.from, obj.command, result, obj.callback);
465
487
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.lorawan",
3
- "version": "0.1.13",
3
+ "version": "0.2.0",
4
4
  "description": "converts the desired lora gateway data to a ioBroker structure",
5
5
  "author": {
6
6
  "name": "BenAhrdt",