Send to rado platform; show_dbdata, db loads after start

This commit is contained in:
rasta5man 2024-12-02 16:57:26 +01:00
parent ed0fe5b15d
commit f63ac50497
22 changed files with 6380 additions and 2279 deletions

View file

@ -3,12 +3,9 @@ exports.title = 'Info sender';
exports.version = '1.0.0';
exports.group = 'Worksys';
exports.color = '#2134B0';
exports.input = 1;
exports.input = 2;
exports.output = 1
exports.click = false;
exports.author = 'oms-is';
exports.icon = 'bolt';
exports.options = { edge: "undefined" };
const { networkInterfaces } = require('os');
@ -22,13 +19,12 @@ exports.html = `<div class="padding">
exports.readme = `# send all data to projects.worksys.io, required to monitor status of controller(unipi)`;
const fs = require('fs');
var path = require('path');
exports.install = function(instance) {
exports.install = async function(instance) {
let id;
let allValues = {};
let sendAllValuesInterval;
let configured = false;
let now = new Date();
console.log(exports.title, "INSTALLED", now.toLocaleString("sk-SK"));
@ -47,23 +43,19 @@ exports.install = async function(instance) {
}
}
}
function sendValues()
{
const id = FLOW.OMS_projects_id;
if(!configured) return;
if(Object.keys(allValues).length > 0)
{
if(id !== undefined)
if(id)
{
delete allValues.__force__;
let dataToSend = {...allValues};
dataToSend.id = id;
dataToSend.ipAddresses = ipAddresses;
//dataToSend.notify_date = new Date().toISOString().slice(0, 19).replace('T', ' ');
//console.log(exports.title, "------------>sendValues", dataToSend);
instance.send(0, dataToSend);
@ -71,7 +63,7 @@ exports.install = async function(instance) {
}
else
{
console.log(exports.title, "unable to send data, id is undefined");
console.log(exports.title, "unable to send data, no id");
}
}
@ -81,10 +73,14 @@ exports.install = async function(instance) {
clearInterval(sendAllValuesInterval);
})
instance.on("data", (flowdata) => {
instance.on("0", _ => {
id = FLOW.GLOBALS.settings.project_id;
configured = true;
})
instance.on("1", flowdata => {
allValues = { ...allValues, ...flowdata.data};
//console.log("DATA RECEIVED", flowdata.data);
//__force__