iobroker.lorawan 1.2.0 → 1.2.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
@@ -23,6 +23,9 @@ For now there is documentation in English here: https://wiki.hafenmeister.de
23
23
  Placeholder for the next version (at the beginning of the line):
24
24
  ### **WORK IN PROGRESS**
25
25
  -->
26
+ ### 1.2.1 (2024-06-24)
27
+ * (BenAhrdt) improof building of offlinenotification >= 25 hours
28
+
26
29
  ### 1.2.0 (2024-05-28)
27
30
  * (BenAhrdt) change deviceInformations (keep old values in structure)
28
31
 
package/io-package.json CHANGED
@@ -1,8 +1,21 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "lorawan",
4
- "version": "1.2.0",
4
+ "version": "1.2.1",
5
5
  "news": {
6
+ "1.2.1": {
7
+ "en": "improof building of offlinenotification >= 25 hours",
8
+ "de": "unsicherer aufbau der offlinenotifizierung >= 25 stunden",
9
+ "ru": " im 25 часов",
10
+ "pt": "construção à prova de notificações off-line >= 25 horas",
11
+ "nl": "voor de toepassing van deze onderverdeling wordt verstaan onder:",
12
+ "fr": "improof construction de la notification hors ligne >= 25 heures",
13
+ "it": ">= 25 ore",
14
+ "es": "construcción infalible de la notificación sin conexión >= 25 horas",
15
+ "pl": "nieodporna budowa offlinenotyfikacji > = 25 godzin",
16
+ "uk": "небезпечна будівля офлайнеризації >= 25 годин",
17
+ "zh-cn": "防线外通知楼 25小时"
18
+ },
6
19
  "1.2.0": {
7
20
  "en": "change deviceInformations (keep old values in structure)",
8
21
  "de": "ändern deviceInformationen (erhalten alte Werte in der Struktur)",
@@ -80,19 +93,6 @@
80
93
  "pl": "zestaw Błąd obiektu Asynch po rozwiązaniu offline",
81
94
  "uk": "комплекти Об'єктАсинхронний помилка після офлайну",
82
95
  "zh-cn": "设定 离线后解析 ObjectAsynch 错误"
83
- },
84
- "1.0.6": {
85
- "en": "icons changed\ndevice offline notofication placed in messagehandler.js",
86
- "de": "icons geändert\ngerät offline-noofication platziert in messagehandler.js",
87
- "ru": "значки изменились\nустройство в автономном режиме, помещенное в messagehandler.js",
88
- "pt": "ícones alterados\ndispositivo off-line notofication colocado em messagehandler.js",
89
- "nl": "pictogrammen gewijzigd\napparaat offline notificatie geplaatst in messagehandler.js",
90
- "fr": "icônes changées\npériphérique hors ligne notofication placé dans messagehandler.js",
91
- "it": "icone cambiate\ndispositivo notorietà offline posto in messagehandler.js",
92
- "es": "iconos cambiados\ndispositivo offline notofication placed in messagehandler.js",
93
- "pl": "ikony zmienione\nnotyfikacja urządzenia umieszczona w messagehandler.js",
94
- "uk": "іконки змінені\nпристрій offline notofication, розміщений в повідомленняhandler.js",
95
- "zh-cn": "图标已更改\n设备离线通知放置在 messagehandler.js"
96
96
  }
97
97
  },
98
98
  "titleLang": {
@@ -31,6 +31,8 @@ class messagehandlerClass {
31
31
  };
32
32
  // Create cronjob to check timestamps (for device offline notification)
33
33
  this.cronJobs[this.cronJobIds.checkTimestamp] = schedule.scheduleJob(this.cronJosValues.checkTimestamp,this.checkTimestamps.bind(this));
34
+ this.offlineiconString = "icons/offline.png";
35
+ this.offlinetimeMax = 25 * 60 * 60 * 1000; // Time in ms
34
36
  }
35
37
 
36
38
  /*********************************************************************
@@ -47,22 +49,21 @@ class messagehandlerClass {
47
49
  if(adapterObject._id.endsWith(`${this.directoryhandler.reachableSubfolders.uplinkRaw}.json`)){
48
50
  const uplinkState = await this.adapter.getStateAsync(adapterObject._id);
49
51
  if(uplinkState){
50
- const msInOneHour = 1000 * 60 * 60;
51
- const maxDifferenceMin = 25 * msInOneHour;
52
- const maxDifferenceMax = 26 * msInOneHour;
53
- const timestampNow = Date.now();
54
- const timestampData = uplinkState.ts;
55
- const difference = timestampNow - timestampData;
56
- if(difference >= maxDifferenceMin && difference <= maxDifferenceMax){
57
- const changeInfo = await this.adapter.getChangeInfo(adapterObject._id);
58
- if(changeInfo){
59
- this.adapter.registerNotification("lorawan", "LoRaWAN device offline", `The LoRaWAN device ${changeInfo.usedDeviceId} in the application ${changeInfo.usedApplicationName} is offline`);
60
- const deviceId = adapterObject._id.substring(0,adapterObject._id.indexOf(".uplink"));
61
- const deviceObject = await this.adapter.getObjectAsync(deviceId);
62
- // Set foldericon to low / no connection
63
- if(deviceObject){
64
- deviceObject.common.icon = "icons/offline.png";
65
- await this.adapter.setObjectAsync(deviceId,deviceObject);
52
+ const difference = Date.now(); - uplinkState.ts;
53
+ // Check for timedifference
54
+ if(difference >= this.offlinetimeMax){
55
+ const deviceobjectId = adapterObject._id.substring(0,adapterObject._id.indexOf(".uplink"));
56
+ const deviceObject = await this.adapter.getObjectAsync(deviceobjectId);
57
+ // Check deviceObject and present iconpath
58
+ if(deviceObject){
59
+ if(deviceObject.common.icon !== this.offlineiconString){
60
+ deviceObject.common.icon = this.offlineiconString;
61
+ await this.adapter.setObjectAsync(deviceobjectId,deviceObject);
62
+ // create changeinfo and register notification
63
+ const changeInfo = await this.adapter.getChangeInfo(adapterObject._id);
64
+ if(changeInfo){
65
+ this.adapter.registerNotification("lorawan", "LoRaWAN device offline", `The LoRaWAN device ${changeInfo.usedDeviceId} in the application ${changeInfo.usedApplicationName} is offline`);
66
+ }
66
67
  }
67
68
  }
68
69
  }
@@ -12,17 +12,17 @@ class mqttClientClass {
12
12
  });
13
13
 
14
14
  // Variables for correct connection (disconnection) notification / logging
15
- this.interanConnectionstate = false;
15
+ this.internalConnectionstate = false;
16
16
  this.errorCountdown = 0;
17
17
  this.numberOfErrorsToLog = 10;
18
18
 
19
19
  this.client.on("connect", () => {
20
- if(!this.interanConnectionstate){
20
+ if(!this.internalConnectionstate){
21
21
  this.adapter.log.info(`Connection is active.`);
22
22
  this.adapter.registerNotification("lorawan", "LoRaWAN Network Service connected", `The LoRaWAN Network Service ${settings.ipUrl} was connected`);
23
23
  }
24
24
  this.adapter.setState("info.connection", true, true);
25
- this.interanConnectionstate = true;
25
+ this.internalConnectionstate = true;
26
26
  this.errorCountdown = this.numberOfErrorsToLog;
27
27
  // @ts-ignore
28
28
  this.client.subscribe(this.getSubscribtionArray(), (err) => {
@@ -32,9 +32,9 @@ class mqttClientClass {
32
32
  });
33
33
  });
34
34
  this.client.on("disconnect", () => {
35
- if(this.interanConnectionstate){
35
+ if(this.internalConnectionstate){
36
36
  this.adapter.setState("info.connection", false, true);
37
- this.interanConnectionstate = false;
37
+ this.internalConnectionstate = false;
38
38
  this.adapter.log.info(`disconnected`);
39
39
  }
40
40
  });
@@ -49,12 +49,12 @@ class mqttClientClass {
49
49
  });
50
50
 
51
51
  this.client.on("close", () => {
52
- if(this.interanConnectionstate){
52
+ if(this.internalConnectionstate){
53
53
  this.adapter.log.info(`Connection is closed.`);
54
54
  this.adapter.registerNotification("lorawan", "LoRaWAN Network Service disconnected", `The LoRaWAN Network Service ${settings.ipUrl} was disconnected`);
55
55
  }
56
56
  this.adapter.setState("info.connection", false, true);
57
- this.interanConnectionstate = false;
57
+ this.internalConnectionstate = false;
58
58
  });
59
59
 
60
60
  this.client.on("message", async (topic, message) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.lorawan",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "converts the desired lora gateway data to a ioBroker structure",
5
5
  "author": {
6
6
  "name": "BenAhrdt",
@@ -26,7 +26,7 @@
26
26
  "dependencies": {
27
27
  "@iobroker/adapter-core": "^3.1.4",
28
28
  "easy-crc": "^1.1.0",
29
- "mqtt": "^5.6.0",
29
+ "mqtt": "^5.7.0",
30
30
  "node-schedule": "^2.1.1"
31
31
  },
32
32
  "devDependencies": {
@@ -40,16 +40,16 @@
40
40
  "@types/chai": "^4.3.11",
41
41
  "@types/chai-as-promised": "^7.1.8",
42
42
  "@types/mocha": "^10.0.6",
43
- "@types/node": "^20.12.2",
43
+ "@types/node": "^20.13.0",
44
44
  "@types/proxyquire": "^1.3.31",
45
45
  "@types/sinon": "^17.0.3",
46
46
  "@types/sinon-chai": "^3.2.12",
47
47
  "chai": "^4.4.1",
48
- "chai-as-promised": "^7.1.1",
48
+ "chai-as-promised": "^7.1.2",
49
49
  "eslint": "^8.57.0",
50
50
  "mocha": "^10.4.0",
51
51
  "proxyquire": "^2.1.3",
52
- "sinon": "^17.0.1",
52
+ "sinon": "^18.0.0",
53
53
  "sinon-chai": "^3.7.0",
54
54
  "typescript": "~5.4.5"
55
55
  },