iobroker.lorawan 0.3.7 → 0.3.8

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.3.8 (2024-02-23)
26
+ * (BenAhrdt) write def into state in case of type changes
27
+
25
28
  ### 0.3.7 (2024-02-22)
26
29
  * (BenAhrdt) improove forbidden chars and implements join raw
27
30
 
@@ -180,7 +180,7 @@
180
180
  "label": "name",
181
181
  "tooltip": "nameTooltip",
182
182
  "default": "",
183
- "validator": "if(data.name === '' || data.name === null){return false;}else{const myRegEx = /^([0-9a-z])*$/i; return myRegEx.test(data.name);}",
183
+ "validator": "if(data.name === '' || data.name === null){return false;}else{const myRegEx = /^([0-9a-z_ ])*$/i; return myRegEx.test(data.name);}",
184
184
  "validatorNoSaveOnError": true,
185
185
  "sm":2
186
186
  },
package/io-package.json CHANGED
@@ -1,8 +1,21 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "lorawan",
4
- "version": "0.3.7",
4
+ "version": "0.3.8",
5
5
  "news": {
6
+ "0.3.8": {
7
+ "en": "write def into state in case of type changes",
8
+ "de": "schreiben def in zustand bei typänderungen",
9
+ "ru": "написать деф в состояние в случае изменения типа",
10
+ "pt": "escrever def em estado em caso de alterações de tipo",
11
+ "nl": "def in status schrijven in geval van typewijzigingen",
12
+ "fr": "écrire def dans l'état en cas de changement de type",
13
+ "it": "scrivere def in stato in caso di variazioni di tipo",
14
+ "es": "escribir def en estado en caso de cambios de tipo",
15
+ "pl": "zapis def do stanu w przypadku zmian typu",
16
+ "uk": "писати деф в стан у разі зміни типу",
17
+ "zh-cn": "在类型变化时将 def 写入状态"
18
+ },
6
19
  "0.3.7": {
7
20
  "en": "improove forbidden chars and implements join raw",
8
21
  "de": "unproove verbotene wagen und geräte roh beitreten",
@@ -80,19 +93,6 @@
80
93
  "pl": "sformułowanie otrzymane = > otrzymywane w procesie messaging",
81
94
  "uk": "javascript licenses api веб-сайт go1.13.8 отримувати повідомлення",
82
95
  "zh-cn": "重述的语句 发送信件时收到"
83
- },
84
- "0.3.1": {
85
- "en": "rebuild with better messageing",
86
- "de": "neuaufbau mit besserer botschaft",
87
- "ru": "перестроить с лучшим сообщением",
88
- "pt": "reconstruir com melhor mensagem",
89
- "nl": "herbouwen met betere berichtgeving",
90
- "fr": "reconstruire avec un meilleur message",
91
- "it": "ricostruire con messaggi migliori",
92
- "es": "reconstruir con mejor mensaje",
93
- "pl": "odbudowa dzięki lepszemu rozwiązywaniu problemów",
94
- "uk": "перебудувати краще повідомлення",
95
- "zh-cn": "以更好的信息重建"
96
96
  }
97
97
  },
98
98
  "title": "LoRaWAN",
@@ -63,7 +63,7 @@ class messagehandlerClass {
63
63
  await this.directoryhandler.generateRekursivObjects(this.directoryhandler.directories.application.devices.deviceEUI.deviceId.downlink.lastSend,`${startDirectory}.${this.directoryhandler.reachableSubfolders.downlinkLastSend}`,"","");
64
64
  }
65
65
 
66
- async fillWithDownlinkConfig(deviceStartdirectory){
66
+ async fillWithDownlinkConfig(deviceStartdirectory,options){
67
67
  const activeFunction = "fillWithDownlinkConfig";
68
68
  try{
69
69
  const changeInfo = await this.adapter.getChangeInfo(`${deviceStartdirectory}.fillDownlinkFolder`);
@@ -122,24 +122,35 @@ class messagehandlerClass {
122
122
  stateCommonMax = 1000000;
123
123
  }
124
124
  }
125
- await this.adapter.extendObjectAsync(`${deviceStartdirectory}.${this.directoryhandler.reachableSubfolders.downlinkControl}.${downlinkParameter.name}`,{
125
+ // common set into variable to read later (for options)
126
+ const common = {
127
+ name: "",
128
+ type: stateCommonType,
129
+ role: stateCommonRole,
130
+ read: stateCommonRole !== "button",
131
+ write: true,
132
+ unit: downlinkParameter.unit? downlinkParameter.unit:"",
133
+ min: stateCommonMin,
134
+ max: stateCommonMax,
135
+ def: stateCommonType === "boolean"? false : stateCommonType === "number"? stateCommonDef: "",
136
+ };
137
+ const stateId = `${deviceStartdirectory}.${this.directoryhandler.reachableSubfolders.downlinkControl}.${downlinkParameter.name}`;
138
+ await this.adapter.extendObjectAsync(stateId,{
126
139
  type: "state",
127
- common: {
128
- name: "",
129
- type: stateCommonType,
130
- role: stateCommonRole,
131
- read: stateCommonRole !== "button",
132
- write: true,
133
- unit: downlinkParameter.unit? downlinkParameter.unit:"",
134
- min: stateCommonMin,
135
- max: stateCommonMax,
136
- def: stateCommonType === "boolean"? false : stateCommonType === "number"? stateCommonDef: "",
137
- },
140
+ common: common,
138
141
  native: {},
139
142
  });
140
143
  if(downlinkDevice !=="all" && downlinkDevice !== this.adapter.downlinkConfighandler.internalDevices.baseDevice){
141
144
  foundLength[downlinkParameter.name] = downlinkDevice.length;
142
145
  }
146
+ //check for right type of data (after a possible change)
147
+ if(!options || !options.inMessage){
148
+ const state = await this.adapter.getStateAsync(stateId);
149
+ if(typeof state.val !== typeof common.def){
150
+ this.adapter.log.silly(`the defaultvale for state ${stateId} will set to ${common.def}`);
151
+ await this.adapter.setStateAsync(stateId,common.def,true);
152
+ }
153
+ }
143
154
  }
144
155
  }
145
156
  }
@@ -436,7 +447,7 @@ class messagehandlerClass {
436
447
  * ********************** downlinkConfigs ****************************
437
448
  * ******************************************************************/
438
449
  this.adapter.log.silly(`check configed downlinks`);
439
- await this.fillWithDownlinkConfig(deviceStartdirectory);
450
+ await this.fillWithDownlinkConfig(deviceStartdirectory,{inMessage: true});
440
451
  }
441
452
  catch(error){
442
453
  this.adapter.log.error(`error at ${activeFunction}: ${error} - - - Message: ${JSON.stringify(message)}`);
@@ -715,7 +726,7 @@ class messagehandlerClass {
715
726
  * ********************** downlinkConfigs ****************************
716
727
  * ******************************************************************/
717
728
  this.adapter.log.silly(`check configed downlinks`);
718
- await this.fillWithDownlinkConfig(deviceStartdirectory);
729
+ await this.fillWithDownlinkConfig(deviceStartdirectory,{inMessage: true});
719
730
 
720
731
  }
721
732
  catch(error){
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.lorawan",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "description": "converts the desired lora gateway data to a ioBroker structure",
5
5
  "author": {
6
6
  "name": "BenAhrdt",