Skip to content

Commit

Permalink
icons changed
Browse files Browse the repository at this point in the history
  • Loading branch information
BenAhrdt committed May 10, 2024
1 parent fe8b4d2 commit 910c7ce
Show file tree
Hide file tree
Showing 25 changed files with 67 additions and 68 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ For now there is documentation in English here: https://wiki.hafenmeister.de
Placeholder for the next version (at the beginning of the line):
### **WORK IN PROGRESS**
-->
### **WORK IN PROGRESS**
* (BenAhrdt) icons changed

### 1.0.5 (2024-05-10)
* (BenAhrdt) device offline location changed

Expand Down
Binary file modified admin/icons/wifiSf12_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified admin/icons/wifiSf12_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified admin/icons/wifiSf12_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified admin/icons/wifiSf12_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified admin/icons/wifiSf12_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified admin/icons/wifiSf7_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified admin/icons/wifiSf7_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified admin/icons/wifiSf7_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified admin/icons/wifiSf7_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified admin/icons/wifiSf7_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified admin/icons/wifiSf7_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified admin/icons/wifiSf9_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified admin/icons/wifiSf9_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified admin/icons/wifiSf9_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified admin/icons/wifiSf9_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified admin/icons/wifiSf9_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified admin/icons/wifiSfX_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified admin/icons/wifiSfX_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified admin/icons/wifiSfX_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified admin/icons/wifiSfX_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified admin/icons/wifiSfX_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 0 additions & 67 deletions lib/modules/directorieshandler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { isDeepStrictEqual } = require("util");
const schedule = require("node-schedule");

class directorieshandlerClass {
constructor(adapter) {
Expand Down Expand Up @@ -33,14 +32,6 @@ class directorieshandlerClass {
wifi: "wifi"
};

this.cronJobs = {};
this.cronJobIds = {
checkTimestamp: "checkTimestamp"
};
this.cronJosValues = {
checkTimestamp: "* * * * *"
};

/*********************************************************************
* ********************* Definition of Assigns **********************
* ******************************************************************/
Expand Down Expand Up @@ -198,64 +189,6 @@ class directorieshandlerClass {
objectNative: "objectNative",
objectIconPath: "objectIconPath"
};

// Create cronjob to check timestamps (for device offline notification)
this.cronJobs[this.cronJobIds.checkTimestamp] = schedule.scheduleJob(this.cronJosValues.checkTimestamp,this.checkTimestamps.bind(this));

}

/*********************************************************************
* ************************ Check Timestamp *****************************
* ******************************************************************/

async checkTimestamps(){
const activeFunction = "checkTimestamps";
try{
const adapterObjects = await this.adapter.getAdapterObjectsAsync();
// Generate Infos of all defices and decoded folders
for(const adapterObject of Object.values(adapterObjects)){
if(adapterObject._id.endsWith(`${this.reachableSubfolders.uplinkRaw}.json`)){
const uplinkState = await this.adapter.getStateAsync(adapterObject._id);
if(uplinkState){
const msInOneHour = 1000 * 60 * 60;
const maxDifferenceMin = 0 * msInOneHour;
const maxDifferenceMax = 1 * msInOneHour;
const timestampNow = Date.now();
const timestampData = uplinkState.ts;
const difference = timestampNow - timestampData;
if(difference >= maxDifferenceMin && difference <= maxDifferenceMax){
const changeInfo = await this.adapter.getChangeInfo(adapterObject._id);
if(changeInfo){
this.adapter.registerNotification("lorawan", "LoRaWAN device offline", `The LoRaWAN device ${changeInfo.usedDeviceId} in the application ${changeInfo.usedApplicationName} is offline`);
const deviceFolderId = adapterObject._id.substring(0,adapterObject._id.indexOf(".uplink"));
const deviceFolderObject = await this.adapter.getObjectAsync(deviceFolderId);
// Set foldericon to low / no connection
if(deviceFolderObject){
deviceFolderObject.common.icon = "icons/wifiSfX_0.png";
await this.adapter.extendObjectAsync(deviceFolderId,{
common: deviceFolderObject.common,
});
}

//const devicefolder = await this.getObjectAsync()
}
}
}
}
}
}
catch(error){
this.adapter.log.error(`error at ${activeFunction}: ` + error);
}
}

// Clear all schedules, if there are some
clearAllSchedules(){
for(const cronJob in this.cronJobs)
{
schedule.cancelJob(this.cronJobs[cronJob]);
delete this.cronJobs[cronJob];
}
}

/*********************************************************************
Expand Down
63 changes: 63 additions & 0 deletions lib/modules/messagehandler.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const directorieshandlerClass = require("./directorieshandler");
const schedule = require("node-schedule");

class messagehandlerClass {
constructor(adapter) {
Expand All @@ -19,8 +20,70 @@ class messagehandlerClass {
// Define present devices for general datainfo via jsonformat in infor folder
this.idDeviceinformations = "info.deviceinformations";
this.deviceinformations = {};

// Cronjobs for device offline checking (notification)
this.cronJobs = {};
this.cronJobIds = {
checkTimestamp: "checkTimestamp"
};
this.cronJosValues = {
checkTimestamp: "0 * * * *"
};
// Create cronjob to check timestamps (for device offline notification)
this.cronJobs[this.cronJobIds.checkTimestamp] = schedule.scheduleJob(this.cronJosValues.checkTimestamp,this.checkTimestamps.bind(this));
}

/*********************************************************************
* ************************ Check Timestamp *****************************
* ******************************************************************/

async checkTimestamps(){
const activeFunction = "checkTimestamps";
try{
const adapterObjects = await this.adapter.getAdapterObjectsAsync();
// Generate Infos of all defices and decoded folders
for(const adapterObject of Object.values(adapterObjects)){
if(adapterObject._id.endsWith(`${this.directoryhandler.reachableSubfolders.uplinkRaw}.json`)){
const uplinkState = await this.adapter.getStateAsync(adapterObject._id);
if(uplinkState){
const msInOneHour = 1000 * 60 * 60;
const maxDifferenceMin = 0 * msInOneHour;
const maxDifferenceMax = 1 * msInOneHour;
const timestampNow = Date.now();
const timestampData = uplinkState.ts;
const difference = timestampNow - timestampData;
if(difference >= maxDifferenceMin && difference <= maxDifferenceMax){
const changeInfo = await this.adapter.getChangeInfo(adapterObject._id);
if(changeInfo){
this.adapter.registerNotification("lorawan", "LoRaWAN device offline", `The LoRaWAN device ${changeInfo.usedDeviceId} in the application ${changeInfo.usedApplicationName} is offline`);
const deviceFolderId = adapterObject._id.substring(0,adapterObject._id.indexOf(".uplink"));
const deviceFolderObject = await this.adapter.getObjectAsync(deviceFolderId);
// Set foldericon to low / no connection
if(deviceFolderObject){
deviceFolderObject.common.icon = "icons/wifiSfX_0.png";
await this.adapter.extendObjectAsync(deviceFolderId,{
common: deviceFolderObject.common,
});
}
}
}
}
}
}
}
catch(error){
this.adapter.log.error(`error at ${activeFunction}: ` + error);
}
}

// Clear all schedules, if there are some
clearAllSchedules(){
for(const cronJob in this.cronJobs)
{
schedule.cancelJob(this.cronJobs[cronJob]);
delete this.cronJobs[cronJob];
}
}

/*********************************************************************
* *************************** General ******************************
Expand Down
2 changes: 1 addition & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class Lorawan extends utils.Adapter {
}

// Clear Schedules im directoriehandler
this.messagehandler?.directoryhandler.clearAllSchedules();
this.messagehandler?.clearAllSchedules();

// Destroy mqtt client
this.mqttClient?.destroy();
Expand Down

0 comments on commit 910c7ce

Please sign in to comment.