iobroker.lorawan 0.3.2 → 0.3.3
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 +3 -0
- package/io-package.json +14 -27
- package/lib/modules/directorieshandler.js +111 -108
- package/lib/modules/downlinkConfighandler.js +1 -1
- package/lib/modules/messagehandler.js +2 -2
- package/main.js +6 -17
- package/package.json +1 -1
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.3.3 (2024-02-19)
|
|
26
|
+
* (BenAhrdt) set infos into native
|
|
27
|
+
|
|
25
28
|
### 0.3.2 (2024-02-16)
|
|
26
29
|
* (BenAhrdt) wording recieved => received in messageing
|
|
27
30
|
|
package/io-package.json
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"name": "lorawan",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.3",
|
|
5
5
|
"news": {
|
|
6
|
+
"0.3.3": {
|
|
7
|
+
"en": "set infos into native",
|
|
8
|
+
"de": "informationen in die heimat",
|
|
9
|
+
"ru": "установить информацию на родной",
|
|
10
|
+
"pt": "definir informações em nativo",
|
|
11
|
+
"nl": "info's instellen in native",
|
|
12
|
+
"fr": "définir les infos dans native",
|
|
13
|
+
"it": "impostare le informazioni in nativo",
|
|
14
|
+
"es": "set infos into native",
|
|
15
|
+
"pl": "zestaw infos do rodzimej",
|
|
16
|
+
"uk": "встановити інформацію на рідні",
|
|
17
|
+
"zh-cn": "设置为本地信息"
|
|
18
|
+
},
|
|
6
19
|
"0.3.2": {
|
|
7
20
|
"en": "wording recieved => received in messageing",
|
|
8
21
|
"de": "zurückgegeben => in der mitteilung empfangen",
|
|
@@ -80,19 +93,6 @@
|
|
|
80
93
|
"pl": "budowa zmienionych katalogów i wdrożona wiadomość",
|
|
81
94
|
"uk": "створення каталогу змінено та повідомлення",
|
|
82
95
|
"zh-cn": "更改目录构建并执行消息"
|
|
83
|
-
},
|
|
84
|
-
"0.1.12": {
|
|
85
|
-
"en": "default value crc config bug fixed",
|
|
86
|
-
"de": "standardwert crc config bug behoben",
|
|
87
|
-
"ru": "по умолчанию",
|
|
88
|
-
"pt": "valor padrão crc config bug corrigido",
|
|
89
|
-
"nl": "standaard waarde crc config bug vast",
|
|
90
|
-
"fr": "valeur par défaut crc config bug corrigé",
|
|
91
|
-
"it": "valore predefinito crc config bug fisso",
|
|
92
|
-
"es": "valor predeterminado crc config error fijo",
|
|
93
|
-
"pl": "wartość domyślna błąd konfiguracyjny crc",
|
|
94
|
-
"uk": "за замовчуванням значення crc config fix",
|
|
95
|
-
"zh-cn": "默认值 crc 配置错误已修正"
|
|
96
96
|
}
|
|
97
97
|
},
|
|
98
98
|
"title": "LoRaWAN",
|
|
@@ -195,19 +195,6 @@
|
|
|
195
195
|
"def": false
|
|
196
196
|
},
|
|
197
197
|
"native": {}
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
"_id": "info.logAvailableConfignames",
|
|
201
|
-
"type": "state",
|
|
202
|
-
"common": {
|
|
203
|
-
"role": "button",
|
|
204
|
-
"name": "logs the names of available device configurations",
|
|
205
|
-
"type": "boolean",
|
|
206
|
-
"read": true,
|
|
207
|
-
"write": true,
|
|
208
|
-
"def": false
|
|
209
|
-
},
|
|
210
|
-
"native": {}
|
|
211
198
|
}
|
|
212
199
|
]
|
|
213
200
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const { isDeepStrictEqual } = require("util");
|
|
1
2
|
const fs = require("fs");
|
|
2
3
|
|
|
3
4
|
class directorieshandlerClass {
|
|
@@ -6,8 +7,9 @@ class directorieshandlerClass {
|
|
|
6
7
|
|
|
7
8
|
// used dataentries in directory structurt
|
|
8
9
|
this.searchableAttributeNames = {
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
applicationId: "applicationId",
|
|
11
|
+
applicationName: "applicationName",
|
|
12
|
+
deviceEUI: "deviceEui",
|
|
11
13
|
deviceId: "deviceId"
|
|
12
14
|
};
|
|
13
15
|
|
|
@@ -34,17 +36,26 @@ class directorieshandlerClass {
|
|
|
34
36
|
// declare the directory structre
|
|
35
37
|
this.directories = {
|
|
36
38
|
application:{
|
|
37
|
-
|
|
38
|
-
return
|
|
39
|
+
objectId : (topic,message) =>{
|
|
40
|
+
return this.getAttributValue(topic,message,this.searchableAttributeNames.applicationId);
|
|
41
|
+
},
|
|
42
|
+
objectCommonFromNative: {name:"applicationName"},
|
|
43
|
+
objectNative : (topic,message) =>{
|
|
44
|
+
return {
|
|
45
|
+
applicationName : this.getAttributValue(topic,message,this.searchableAttributeNames.applicationName)
|
|
46
|
+
};
|
|
39
47
|
},
|
|
40
|
-
objectCommonName: "application",
|
|
41
48
|
devices:{
|
|
42
49
|
deviceEUI:{
|
|
43
|
-
|
|
44
|
-
return
|
|
50
|
+
objectId : (topic,message) =>{
|
|
51
|
+
return this.getAttributValue(topic,message,this.searchableAttributeNames.deviceEUI);
|
|
45
52
|
},
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
objectCommonFromNative: {name:"deviceId"},
|
|
54
|
+
objectNative : (topic,message) =>{
|
|
55
|
+
return {
|
|
56
|
+
applicationName : this.getAttributValue(topic,message,this.searchableAttributeNames.applicationName),
|
|
57
|
+
deviceId : this.getAttributValue(topic,message,this.searchableAttributeNames.deviceId)
|
|
58
|
+
};
|
|
48
59
|
},
|
|
49
60
|
objectType: "device",
|
|
50
61
|
configuration:{
|
|
@@ -90,9 +101,11 @@ class directorieshandlerClass {
|
|
|
90
101
|
}
|
|
91
102
|
};
|
|
92
103
|
this.ignoredElementNames ={
|
|
93
|
-
|
|
104
|
+
objectId: "objectId",
|
|
94
105
|
objectCommonName: "objectCommonName",
|
|
95
|
-
|
|
106
|
+
objectCommonFromNative: "objectCommonFromNative",
|
|
107
|
+
objectType: "objectType",
|
|
108
|
+
objectNative : "objectNative"
|
|
96
109
|
};
|
|
97
110
|
}
|
|
98
111
|
|
|
@@ -131,38 +144,79 @@ class directorieshandlerClass {
|
|
|
131
144
|
if(!this.ignoredElementNames[elementName] && !options?.ignoredElementNames[elementName]){
|
|
132
145
|
// Check if the element is an object
|
|
133
146
|
if(typeof obj[elementName] === "object" && obj[elementName] && !obj[elementName].isState){
|
|
134
|
-
//
|
|
147
|
+
// Generate the desired id
|
|
135
148
|
let objectId = `${startDirectory}.${elementName}`;
|
|
136
149
|
let internalObjectId = elementName;
|
|
137
|
-
if(obj[elementName].
|
|
138
|
-
internalObjectId = `${
|
|
150
|
+
if(obj[elementName].objectId){
|
|
151
|
+
internalObjectId = `${obj[elementName].objectId(topic,message)}`;
|
|
139
152
|
objectId = `${startDirectory}.${internalObjectId}`;
|
|
140
153
|
}
|
|
141
154
|
if(objectId.indexOf(".") === 0){
|
|
142
155
|
objectId = objectId.substring(1,objectId.length);
|
|
143
156
|
}
|
|
144
|
-
let
|
|
157
|
+
let myObject = {};
|
|
158
|
+
// check object exists
|
|
159
|
+
if(await this.adapter.objectExists(objectId)){
|
|
160
|
+
myObject = await this.adapter.getObjectAsync(objectId);
|
|
161
|
+
}
|
|
162
|
+
const myObjectBefore = structuredClone(myObject);
|
|
163
|
+
|
|
164
|
+
//Set type of object
|
|
165
|
+
if(!myObject.type){
|
|
166
|
+
myObject.type = obj[elementName].objectType? obj[elementName].objectType : "folder";
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
//check for common
|
|
170
|
+
if(!myObject.common){
|
|
171
|
+
myObject.common = {};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// check whether a common name was specified
|
|
145
175
|
if(obj[elementName].objectCommonName && typeof obj[elementName].objectCommonName === "function"){
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
176
|
+
if(typeof obj[elementName].objectCommonName === "function"){
|
|
177
|
+
myObject.common.name = obj[elementName].objectCommonName(topic,message);
|
|
178
|
+
}
|
|
179
|
+
else{
|
|
180
|
+
myObject.common.name = obj[elementName].objectCommonName;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Check wheter a native content was specified
|
|
185
|
+
if(!myObject.native){
|
|
186
|
+
myObject.native = {};
|
|
154
187
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
188
|
+
if(obj[elementName].objectNative){
|
|
189
|
+
const objectNative = obj[elementName].objectNative(topic,message);
|
|
190
|
+
for(const attribute in objectNative){
|
|
191
|
+
myObject.native[attribute] = objectNative[attribute];
|
|
158
192
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
193
|
+
|
|
194
|
+
// Assigne to common, if there are values specified
|
|
195
|
+
if(obj[elementName].objectCommonFromNative){
|
|
196
|
+
for(const attribute in obj[elementName].objectCommonFromNative){
|
|
197
|
+
// Check, whether the actual native is present
|
|
198
|
+
if(myObject.native[obj[elementName].objectCommonFromNative[attribute]]){
|
|
199
|
+
// check for old common => existing object
|
|
200
|
+
if(myObjectBefore.common){
|
|
201
|
+
//check for content
|
|
202
|
+
if(myObjectBefore.common[attribute] === myObjectBefore.native[obj[elementName].objectCommonFromNative[attribute]] ||
|
|
203
|
+
myObjectBefore.common[attribute] === ""){
|
|
204
|
+
myObject.common[attribute] = myObject.native[obj[elementName].objectCommonFromNative[attribute]];
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
else{
|
|
208
|
+
myObject.common[attribute] = myObject.native[obj[elementName].objectCommonFromNative[attribute]];
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
// Check for name
|
|
215
|
+
if(!myObject.common.name){
|
|
216
|
+
myObject.common.name = "";
|
|
217
|
+
}
|
|
218
|
+
if(!isDeepStrictEqual(myObject,myObjectBefore)){
|
|
219
|
+
await this.adapter.setObject(objectId,myObject);
|
|
166
220
|
}
|
|
167
221
|
// Jump into next step (next directory / attribute)
|
|
168
222
|
await this.generateRekursivObjects(obj[elementName],objectId,topic,message);
|
|
@@ -183,8 +237,8 @@ class directorieshandlerClass {
|
|
|
183
237
|
stateCommonWrite = obj[elementName].stateCommonWrite ? obj[elementName].stateCommonWrite : stateCommonWrite;
|
|
184
238
|
stateCommonRole = obj[elementName].stateCommonRole ? obj[elementName].stateCommonRole : stateCommonRole;
|
|
185
239
|
}
|
|
186
|
-
if(obj[elementName].
|
|
187
|
-
internalObjectId = `${
|
|
240
|
+
if(obj[elementName].objectId){
|
|
241
|
+
internalObjectId = `${obj[elementName].objectId(topic,message)}`;
|
|
188
242
|
objectId = `${startDirectory}.${internalObjectId}`;
|
|
189
243
|
}
|
|
190
244
|
}
|
|
@@ -227,15 +281,15 @@ class directorieshandlerClass {
|
|
|
227
281
|
* ************************** Attribute ******************************
|
|
228
282
|
* ******************************************************************/
|
|
229
283
|
|
|
230
|
-
|
|
284
|
+
getAttributValue(topic,message,resolvetype){
|
|
231
285
|
const activeFunction = "getAttributValue";
|
|
232
286
|
try{
|
|
233
287
|
// Select search in case of origin
|
|
234
288
|
switch(this.adapter.config.origin){
|
|
235
289
|
case this.adapter.origin.ttn:
|
|
236
|
-
return
|
|
290
|
+
return this.getTtnAttributValue(topic,message,resolvetype);
|
|
237
291
|
case this.adapter.origin.chirpstack:
|
|
238
|
-
return
|
|
292
|
+
return this.getChirpstackAttributValue(topic,message,resolvetype);
|
|
239
293
|
}
|
|
240
294
|
}
|
|
241
295
|
catch(error){
|
|
@@ -244,19 +298,15 @@ class directorieshandlerClass {
|
|
|
244
298
|
}
|
|
245
299
|
|
|
246
300
|
/*********************************************************************
|
|
247
|
-
*
|
|
301
|
+
* ******************** Object Start Directory ***********************
|
|
248
302
|
* ******************************************************************/
|
|
249
303
|
|
|
250
|
-
|
|
251
|
-
const activeFunction = "
|
|
304
|
+
getDeviceStartDirectory(topic,message){
|
|
305
|
+
const activeFunction = "getDeviceStartDirectory";
|
|
252
306
|
try{
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
return await this.getTtnObjectDirectory(topic,message,resolvetype);
|
|
257
|
-
case this.adapter.origin.chirpstack:
|
|
258
|
-
return await this.getChirpstackObjectDirectory(topic,message,resolvetype);
|
|
259
|
-
}
|
|
307
|
+
const applicationId = `${this.getAttributValue(topic,message,this.searchableAttributeNames.applicationId)}`;
|
|
308
|
+
const deviceEUI = `${this.getAttributValue(topic,message,this.searchableAttributeNames.deviceEUI)}`;
|
|
309
|
+
return `${applicationId}.devices.${deviceEUI}`;
|
|
260
310
|
}
|
|
261
311
|
catch(error){
|
|
262
312
|
this.adapter.log.error(`error at ${activeFunction}: ${error} - - - Message: ${JSON.stringify(message)}`);
|
|
@@ -291,15 +341,18 @@ class directorieshandlerClass {
|
|
|
291
341
|
* ************************** Attribute ******************************
|
|
292
342
|
* ******************************************************************/
|
|
293
343
|
|
|
294
|
-
|
|
344
|
+
getTtnAttributValue(topic,message,resolvetype){
|
|
295
345
|
const activeFunction = "getTtnAttributValue";
|
|
296
346
|
try{
|
|
297
347
|
this.adapter.log.silly(`attribute ${resolvetype} is requested for ttn`);
|
|
298
348
|
const topicResolved = this.getTopicResolved(topic);
|
|
299
349
|
switch(resolvetype){
|
|
300
|
-
case this.searchableAttributeNames.
|
|
350
|
+
case this.searchableAttributeNames.applicationId:
|
|
301
351
|
return topicResolved?.applicationId;
|
|
302
352
|
|
|
353
|
+
case this.searchableAttributeNames.applicationName:
|
|
354
|
+
return topicResolved?.applicationName;
|
|
355
|
+
|
|
303
356
|
case this.searchableAttributeNames.deviceEUI:
|
|
304
357
|
return message.end_device_ids.dev_eui;
|
|
305
358
|
|
|
@@ -316,33 +369,6 @@ class directorieshandlerClass {
|
|
|
316
369
|
}
|
|
317
370
|
}
|
|
318
371
|
|
|
319
|
-
/*********************************************************************
|
|
320
|
-
* ************************ Object Directory *************************
|
|
321
|
-
* ******************************************************************/
|
|
322
|
-
|
|
323
|
-
async getTtnObjectDirectory(topic,message,resolvetype){
|
|
324
|
-
const activeFunction = "getTtnObjectDirectory";
|
|
325
|
-
try{
|
|
326
|
-
this.adapter.log.silly(`directory ${resolvetype} is requested for ttn`);
|
|
327
|
-
const topicResolved = this.getTopicResolved(topic);
|
|
328
|
-
if(typeof message !== "string"){
|
|
329
|
-
switch(resolvetype){
|
|
330
|
-
case this.searchableAttributeNames.deviceEUI:
|
|
331
|
-
return `${topicResolved?.applicationId}.devices.${message.end_device_ids.dev_eui}`;
|
|
332
|
-
|
|
333
|
-
default:
|
|
334
|
-
return message;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
else{
|
|
338
|
-
return message;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
catch(error){
|
|
342
|
-
this.adapter.log.error(`error at ${activeFunction}: ${error} - - - Message: ${JSON.stringify(message)}`);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
372
|
/*********************************************************************
|
|
347
373
|
* ************************ Object Directory *************************
|
|
348
374
|
* ******************************************************************/
|
|
@@ -352,6 +378,7 @@ class directorieshandlerClass {
|
|
|
352
378
|
try{
|
|
353
379
|
const topicElements = topic.split("/");
|
|
354
380
|
const topicResolved = {
|
|
381
|
+
applicationName: "",
|
|
355
382
|
applicationId: topicElements[1],
|
|
356
383
|
deviceId: topicElements[3],
|
|
357
384
|
messageType: topicElements[topicElements.length - 1]
|
|
@@ -359,6 +386,7 @@ class directorieshandlerClass {
|
|
|
359
386
|
// clean up application id
|
|
360
387
|
const indexOfOrigin = topicResolved.applicationId.indexOf("@");
|
|
361
388
|
if(indexOfOrigin !== -1){
|
|
389
|
+
topicResolved.applicationName = topicResolved.applicationId;
|
|
362
390
|
topicResolved.applicationId = topicResolved.applicationId.substring(0,indexOfOrigin);
|
|
363
391
|
}
|
|
364
392
|
return topicResolved;
|
|
@@ -379,15 +407,19 @@ class directorieshandlerClass {
|
|
|
379
407
|
* ******************************************************************/
|
|
380
408
|
|
|
381
409
|
|
|
382
|
-
|
|
410
|
+
// !!! Dont use resoletypes with message.deviceInfo in down => No deviceInfo in down message present
|
|
411
|
+
getChirpstackAttributValue(topic,message,resolvetype){
|
|
383
412
|
const activeFunction = "getChirpstackAttributValue";
|
|
384
413
|
try{
|
|
385
414
|
this.adapter.log.silly(`attribute ${resolvetype} is requested for chirpstack`);
|
|
386
415
|
const topicResolved = this.getTopicResolved(topic);
|
|
387
416
|
switch(resolvetype){
|
|
388
|
-
case this.searchableAttributeNames.
|
|
417
|
+
case this.searchableAttributeNames.applicationId:
|
|
389
418
|
return topicResolved?.applicationId;
|
|
390
419
|
|
|
420
|
+
case this.searchableAttributeNames.applicationName:
|
|
421
|
+
return message.deviceInfo.applicationName;
|
|
422
|
+
|
|
391
423
|
case this.searchableAttributeNames.deviceEUI:
|
|
392
424
|
return topicResolved?.deviceEUI;
|
|
393
425
|
|
|
@@ -404,35 +436,6 @@ class directorieshandlerClass {
|
|
|
404
436
|
}
|
|
405
437
|
}
|
|
406
438
|
|
|
407
|
-
/*********************************************************************
|
|
408
|
-
* ************************ Object Directory *************************
|
|
409
|
-
* ******************************************************************/
|
|
410
|
-
|
|
411
|
-
async getChirpstackObjectDirectory(topic,message,resolvetype){
|
|
412
|
-
const activeFunction = "getChirpstackObjectDirectory";
|
|
413
|
-
try{
|
|
414
|
-
this.adapter.log.silly(`directory ${resolvetype} is requested for chirpstack`);
|
|
415
|
-
const topicResolved = this.getTopicResolved(topic);
|
|
416
|
-
let devUid = undefined;
|
|
417
|
-
if(topicResolved?.messageType !== "down"){
|
|
418
|
-
devUid = message.deviceInfo.devEui;
|
|
419
|
-
}
|
|
420
|
-
else{
|
|
421
|
-
devUid = message.devEui;
|
|
422
|
-
}
|
|
423
|
-
switch(resolvetype){
|
|
424
|
-
case this.searchableAttributeNames.deviceEUI:
|
|
425
|
-
return `${topicResolved?.applicationId}.devices.${devUid}`;
|
|
426
|
-
|
|
427
|
-
default:
|
|
428
|
-
return message;
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
catch(error){
|
|
432
|
-
this.adapter.log.error(`error at ${activeFunction}: ${error} - - - Message: ${JSON.stringify(message)}`);
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
|
|
436
439
|
/*********************************************************************
|
|
437
440
|
* ************************ Resolved Topic ***************************
|
|
438
441
|
* ******************************************************************/
|
|
@@ -38,7 +38,7 @@ class downlinkConfighandlerClass {
|
|
|
38
38
|
// generate the Config without own objects
|
|
39
39
|
const ownConfig = [];
|
|
40
40
|
for(const downlinkConfig of Object.values(this.activeDownlinkConfigs)){
|
|
41
|
-
ownConfig.push(JSON.parse(JSON.stringify(downlinkConfig)));
|
|
41
|
+
ownConfig.push(structuredClone(downlinkConfig));//JSON.parse(JSON.stringify(downlinkConfig)));
|
|
42
42
|
delete ownConfig[ownConfig.length - 1].downlinkState;
|
|
43
43
|
}
|
|
44
44
|
// Add internal base downlinks
|
|
@@ -169,7 +169,7 @@ class messagehandlerClass {
|
|
|
169
169
|
const messageType = topic.substring(topic.lastIndexOf("/") + 1 ,topic.length);
|
|
170
170
|
this.adapter.log.silly(`the messagetype ${messageType} was determined`);
|
|
171
171
|
// generate startdirectory of device
|
|
172
|
-
const deviceStartdirectory =
|
|
172
|
+
const deviceStartdirectory = this.directoryhandler.getDeviceStartDirectory(topic,message);
|
|
173
173
|
this.adapter.log.silly(`the startdirectory ${deviceStartdirectory} was determined`);
|
|
174
174
|
|
|
175
175
|
/*********************************************************************
|
|
@@ -418,7 +418,7 @@ class messagehandlerClass {
|
|
|
418
418
|
const messageType = topic.substring(topic.lastIndexOf("/") + 1 ,topic.length);
|
|
419
419
|
this.adapter.log.silly(`the messagetype ${messageType} was determined`);
|
|
420
420
|
// generate startdirectory of device
|
|
421
|
-
const deviceStartdirectory =
|
|
421
|
+
const deviceStartdirectory = this.directoryhandler.getDeviceStartDirectory(topic,message);
|
|
422
422
|
this.adapter.log.silly(`the startdirectory ${deviceStartdirectory} was determined`);
|
|
423
423
|
|
|
424
424
|
/*********************************************************************
|
package/main.js
CHANGED
|
@@ -214,18 +214,6 @@ class Lorawan extends utils.Adapter {
|
|
|
214
214
|
}
|
|
215
215
|
this.setStateAsync(id,state.val,true);
|
|
216
216
|
}
|
|
217
|
-
// logging of the actual available configs
|
|
218
|
-
else if(id.indexOf(".logAvailableConfignames") !== -1){
|
|
219
|
-
this.log.info(`The following devicenames has an existing downlink-config`);
|
|
220
|
-
let index = 0;
|
|
221
|
-
for(const devicename in this.downlinkConfighandler?.activeDownlinkConfigs){
|
|
222
|
-
index++;
|
|
223
|
-
if(devicename !== this.downlinkConfighandler.internalDevices.baseDevice){
|
|
224
|
-
this.log.info(`Device ${index}: ${devicename}`);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
this.setStateAsync(id,state.val,true);
|
|
228
|
-
}
|
|
229
217
|
}
|
|
230
218
|
} else {
|
|
231
219
|
// The state was deleted
|
|
@@ -340,7 +328,8 @@ class Lorawan extends utils.Adapter {
|
|
|
340
328
|
// Get Obect from startdirectory
|
|
341
329
|
const startDirectoryObject = await this.getObjectAsync(changeInfo.objectStartDirectory);
|
|
342
330
|
if(startDirectoryObject){
|
|
343
|
-
changeInfo.
|
|
331
|
+
changeInfo.applicationName = startDirectoryObject.native.applicationName;
|
|
332
|
+
changeInfo.deviceId = startDirectoryObject.native.deviceId;
|
|
344
333
|
}
|
|
345
334
|
// Get deviceType
|
|
346
335
|
const deviceTypeIdState = await this.getStateAsync(myId);
|
|
@@ -407,7 +396,7 @@ class Lorawan extends utils.Adapter {
|
|
|
407
396
|
if(obj.message.deviceEUI){
|
|
408
397
|
const changeInfo = await this.getChangeInfoFromDeviceEUI(obj.message.deviceEUI,`${this.messagehandler?.directoryhandler.reachableSubfolders.configuration}.devicetype`);
|
|
409
398
|
if(changeInfo){
|
|
410
|
-
result = {applicationId: changeInfo.applicationId, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, deviceType: changeInfo.deviceType, received:obj.message};
|
|
399
|
+
result = {applicationId: changeInfo.applicationId, applicationName: changeInfo.applicationName, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, deviceType: changeInfo.deviceType, received:obj.message};
|
|
411
400
|
}
|
|
412
401
|
else{
|
|
413
402
|
result = {error:true, message:"No device found", received:obj.message};
|
|
@@ -428,7 +417,7 @@ class Lorawan extends utils.Adapter {
|
|
|
428
417
|
if(await this.objectExists(uplinkId)){
|
|
429
418
|
const stateResult = await this.getStateAsync(changeInfo.id);
|
|
430
419
|
if(stateResult){
|
|
431
|
-
result = {applicationId: changeInfo.applicationId, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, deviceType: changeInfo.deviceType, value: stateResult.val, received:obj.message};
|
|
420
|
+
result = {applicationId: changeInfo.applicationId, applicationName: changeInfo.applicationName, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, deviceType: changeInfo.deviceType, value: stateResult.val, received:obj.message};
|
|
432
421
|
}
|
|
433
422
|
}
|
|
434
423
|
else{
|
|
@@ -460,7 +449,7 @@ class Lorawan extends utils.Adapter {
|
|
|
460
449
|
// Check limit
|
|
461
450
|
if((!downlinkObject.common.min || obj.message.value >= downlinkObject.common.min) && (!downlinkObject.common.max || obj.message.value <= downlinkObject.common.max)){
|
|
462
451
|
await this.setStateAsync(downlinkId,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, received:obj.message};
|
|
452
|
+
result = {applicationId: changeInfo.applicationId, applicationName: changeInfo.applicationName, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, deviceType: changeInfo.deviceType, downlink: obj.message.downlink, value: obj.message.value, received:obj.message};
|
|
464
453
|
}
|
|
465
454
|
else{
|
|
466
455
|
result = {error:true, message:"value is not in valid range", received:obj.message};
|
|
@@ -477,7 +466,7 @@ class Lorawan extends utils.Adapter {
|
|
|
477
466
|
}
|
|
478
467
|
else{
|
|
479
468
|
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, received:obj.message};
|
|
469
|
+
result = {applicationId: changeInfo.applicationId, applicationName: changeInfo.applicationName, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, deviceType: changeInfo.deviceType, downlink: obj.message.downlink, value: obj.message.value, received:obj.message};
|
|
481
470
|
}
|
|
482
471
|
}
|
|
483
472
|
}
|