iobroker.lorawan 0.6.0 → 0.6.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,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.6.1 (2024-03-02)
26
+ * (BenAhrdt) better concept to write values and change setObjectNotExists to extendObject
27
+
25
28
  ### 0.6.0 (2024-03-02)
26
29
  * (BenAhrdt) change concept of assigning roles, values and writecommands
27
30
 
package/io-package.json CHANGED
@@ -1,8 +1,21 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "lorawan",
4
- "version": "0.6.0",
4
+ "version": "0.6.1",
5
5
  "news": {
6
+ "0.6.1": {
7
+ "en": "better concept to write values and change setObjectNotExists to extendObject",
8
+ "de": "besseres Konzept zum Schreiben von Werten und Änderungsset ObjectNotExists to erweitern Gegenstand",
9
+ "ru": "лучшее понятие для написания ценностей и изменения набора ObjectNotExists Объект",
10
+ "pt": "melhor conceito para escrever valores e alterar o conjunto ObjectNotExists para estender Objeto",
11
+ "nl": "beter concept om waarden en verandering set te schrijven ObjectNotBestaat om uit te breiden Doel",
12
+ "fr": "meilleur concept pour écrire des valeurs et changer ensemble ObjectNotExiste à étendre Objet",
13
+ "it": "migliore concetto per scrivere valori e cambiare set ObjectNotEsiste per estendere Oggetto",
14
+ "es": "mejor concepto para escribir valores y cambiar conjunto ObjectNotExists to extend Objeto",
15
+ "pl": "lepsza koncepcja zapisu wartości i zestaw zmian ObjectNotExists rozszerzyć Obiekt",
16
+ "uk": "краща концепція для написання значень та змін Об'єктNotExists для розширення Об'єкт",
17
+ "zh-cn": "更好的写值和更改集的概念 要扩展的对象不包含 对象"
18
+ },
6
19
  "0.6.0": {
7
20
  "en": "change concept of assigning roles, values and writecommands",
8
21
  "de": "änderungskonzept der zuordnung von rollen, werten und schreibbefehlen",
@@ -80,19 +93,6 @@
80
93
  "pl": "wykrywanie zmienionych tryggerwords",
81
94
  "uk": "виявлення змінених фраз",
82
95
  "zh-cn": "检测触发词已更改"
83
- },
84
- "0.5.0": {
85
- "en": "trigger for devicetype implemented",
86
- "de": "trigger für implementierte gerätetypen",
87
- "ru": "триггер для реализованного устройства",
88
- "pt": "gatilho para o tipo de dispositivo implementado",
89
- "nl": "trigger voor apparaattype geïmplementeerd",
90
- "fr": "déclencheur pour le type d'appareil implémenté",
91
- "it": "trigger per il tipo di dispositivo implementato",
92
- "es": "disparador para el tipo de dispositivo implementado",
93
- "pl": "wyzwalacz dla wdrożonego typu devicetype",
94
- "uk": "тригер для установки",
95
- "zh-cn": "已执行设备类型的触发器"
96
96
  }
97
97
  },
98
98
  "title": "LoRaWAN",
@@ -56,24 +56,28 @@ class directorieshandlerClass {
56
56
  * ************************** writecommands *************************
57
57
  * ******************************************************************/
58
58
 
59
- this.executeWritecommand = async (elementName,sourceId,value) =>{
59
+ //general function for writecommands
60
+ this.executeWritecommand = async (writecommand,elementName,sourceId,value) =>{
60
61
  // Check, if there is a writetrigger and the stateval is not euqal its releaseVal(still present)
61
- const writecommand = this.writeCommand[elementName];
62
- if(writecommand && writecommand.releaseValue !== value){
62
+ if(writecommand.releaseValue !== value){
63
63
  const baseInfo = this.adapter.getBaseDeviceInfo(sourceId);
64
64
  const subfolder = sourceId.slice(baseInfo.objectStartDirectory.length + 1,sourceId.length - baseInfo.changedState.length - 1);
65
65
  if(!writecommand.approvedFolders || writecommand.approvedFolders[subfolder]){
66
66
  const destinationId = `${baseInfo.objectStartDirectory}.${writecommand.destination}`;
67
67
  const destinationState = await this.adapter.getStateAsync(destinationId);
68
68
  if(destinationState?.val === writecommand.releaseValue){
69
- this.adapter.log.debug(`writetrigger ${elementName} recogniced. value ${value} will be written into ${this.writeCommand[elementName].destination}`);
69
+ this.adapter.log.debug(`writecommand ${elementName} recogniced. value ${value} will be written into ${writecommand.destination}`);
70
70
  await this.adapter.setStateAsync(destinationId,value);
71
71
  }
72
72
  }
73
73
  }
74
74
  };
75
75
 
76
- this.writeCommandDeviceType = {destination:"configuration.devicetype",releaseValue:"",approvedFolders:{"uplink.decoded":true}};
76
+ // Define settings for writecommand devicetype
77
+ this.writeCommandDeviceType = async (elementName,sourceId,value) =>{
78
+ const writecommand = {destination:"configuration.devicetype",releaseValue:"",approvedFolders:{"uplink.decoded":true}};
79
+ return await this.executeWritecommand(writecommand,elementName,sourceId,value);
80
+ };
77
81
 
78
82
  this.writeCommand = {
79
83
  Devicetype: this.writeCommandDeviceType,
@@ -271,10 +275,6 @@ class directorieshandlerClass {
271
275
  unit: obj[elementName]? obj[elementName].CommonStateUnit? obj[elementName].CommonStateUnit : "" : "",
272
276
  write: false
273
277
  };
274
- /*let stateCommonType = typeof obj[elementName];
275
- let stateCommonName = "";
276
- let stateCommonWrite = false;
277
- let stateCommonRole = "value";*/
278
278
  let stateVal = obj[elementName];
279
279
  let objectId = `${startDirectory}.${elementName}`;
280
280
  let internalObjectId = elementName;
@@ -301,7 +301,7 @@ class directorieshandlerClass {
301
301
  }
302
302
  common.read = common.role !== "button";
303
303
  common.def = obj[elementName] || typeof obj[elementName] === "boolean" ? obj[elementName].stateCommonDef? obj[elementName].stateCommonDef: common.type === "boolean"? false : common.type === "number"? 0: "": common.type === "number"? 0: "";
304
- await this.adapter.setObjectNotExistsAsync(objectId,{
304
+ await this.adapter.extendObjectAsync(objectId,{
305
305
  type: "state",
306
306
  common: common,
307
307
  native: {},
@@ -312,7 +312,10 @@ class directorieshandlerClass {
312
312
  if(stateVal !== undefined){
313
313
  // Set State from Objectpath
314
314
  await this.adapter.setStateAsync(`${objectId}`,stateVal,true);
315
- await this.executeWritecommand(elementName,objectId,stateVal);
315
+ //Check for writecommand
316
+ if(this.writeCommand[elementName]){
317
+ await this.writeCommand[elementName](elementName,objectId,stateVal);
318
+ }
316
319
  }
317
320
  }
318
321
  }
@@ -90,55 +90,51 @@ class messagehandlerClass {
90
90
  }
91
91
  // check found length
92
92
  if(downlinkDevice.length > foundLength[downlinkParameter.name]){
93
- let stateCommonRole = "level";
94
- let stateCommonType = downlinkParameter.type;
93
+ const common = {
94
+ role: "level",
95
+ type: downlinkParameter.type
96
+ };
95
97
  // Assign role (if present)
96
- if(this.downlinkRoles[stateCommonType]){
97
- stateCommonRole = this.downlinkRoles[stateCommonType];
98
+ if(this.downlinkRoles[common.type]){
99
+ common.role = this.downlinkRoles[common.type];
98
100
  }
99
101
  // Reassign type
100
- if(stateCommonType === "button"){
101
- stateCommonType = "boolean";
102
+ if(common.type === "button"){
103
+ common.type = "boolean";
102
104
  }
103
- else if(stateCommonType === "ascii"){
104
- stateCommonType = "string";
105
+ else if(common.type === "ascii"){
106
+ common.type = "string";
105
107
  }
106
108
  // declare def / min / max
107
- let stateCommonMin = undefined;
108
- let stateCommonDef = 0; //just numbers
109
- let stateCommonMax = undefined;
110
- if(stateCommonType === "number"){
109
+ common.min = undefined;
110
+ common.def = 0; //just numbers
111
+ common.max = undefined;
112
+ if(common.type === "number"){
111
113
  if(downlinkParameter.limitMin){
112
- stateCommonMin = downlinkParameter.limitMinValue;
113
- if(stateCommonMin > stateCommonDef){
114
- stateCommonDef = stateCommonMin;
114
+ common.min = downlinkParameter.limitMinValue;
115
+ if(common.min > common.def){
116
+ common.def = common.min;
115
117
  }
116
118
  }
117
- else if(stateCommonType === "number"){
118
- stateCommonMin = -1000000;
119
+ else if(common.type === "number"){
120
+ common.min = -1000000;
119
121
  }
120
122
  if(downlinkParameter.limitMax){
121
- stateCommonMax = downlinkParameter.limitMaxValue;
122
- if(stateCommonMax < stateCommonDef){
123
- stateCommonDef = stateCommonMax;
123
+ common.max = downlinkParameter.limitMaxValue;
124
+ if(common.max < common.def){
125
+ common.def = common.max;
124
126
  }
125
127
  }
126
- else if(stateCommonType === "number"){
127
- stateCommonMax = 1000000;
128
+ else if(common.type === "number"){
129
+ common.max = 1000000;
128
130
  }
129
131
  }
132
+ common.name = "";
133
+ common.read = common.role !== "button";
134
+ common.write = true;
135
+ common.unit = downlinkParameter.unit? downlinkParameter.unit:"";
136
+ common.def = common.type === "boolean"? false : common.type === "number"? common.def: "";
130
137
  // common set into variable to read later (for options)
131
- const common = {
132
- name: "",
133
- type: stateCommonType,
134
- role: stateCommonRole,
135
- read: stateCommonRole !== "button",
136
- write: true,
137
- unit: downlinkParameter.unit? downlinkParameter.unit:"",
138
- min: stateCommonMin,
139
- max: stateCommonMax,
140
- def: stateCommonType === "boolean"? false : stateCommonType === "number"? stateCommonDef: "",
141
- };
142
138
  const stateId = `${deviceStartdirectory}.${this.directoryhandler.reachableSubfolders.downlinkControl}.${downlinkParameter.name}`;
143
139
  await this.adapter.extendObjectAsync(stateId,{
144
140
  type: "state",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.lorawan",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "converts the desired lora gateway data to a ioBroker structure",
5
5
  "author": {
6
6
  "name": "BenAhrdt",