New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-red-contrib-knx-ultimate

Package Overview
Dependencies
Maintainers
1
Versions
461
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-red-contrib-knx-ultimate - npm Package Compare versions

Comparing version

to
1.0.5

4

CHANGELOG.md
# node-red-contrib-knx-ultimate
<p>
<b>Version 1.0.5</b><br/>
- Fixed a typo error causing a mess<br/>
</p>
<p>
<b>Version 1.0.4</b><br/>

@@ -4,0 +8,0 @@ - Fixed possible issue with the csv ETS endpoint<br/>

150

knxUltimate-config.js

@@ -39,2 +39,7 @@ const knx = require('knx')

module.exports = (RED) => {

@@ -53,18 +58,17 @@

function knxUltimateConfigNode(n) {
RED.nodes.createNode(this, n)
function knxUltimateConfigNode(config) {
RED.nodes.createNode(this, config)
var node = this
node.host = n.host
node.port = n.port
node.csv = readCSV(n.csv,false) // Array from ETS CSV Group Addresses
//node.setClientStatus("disconnected","red","")
node.host = config.host
node.port = config.port
node.csv = toJsonCSV(config.csvincollato); // Array from ETS CSV Group Addresses
// Entry point for reading csv from the other nodes
RED.httpAdmin.get("/knxUltimatecsv", RED.auth.needsPermission('knxUltimate-config.read'), function (req, res) {
res.json(node.csv)
});
res.json(node.csv)
});
var knxErrorTimeout
node.nodeClients = [] // Stores the registered clients
node.addClient = (_Node) => {

@@ -82,2 +86,3 @@ // Add _Node to the clients array

node.removeClient = (_Node) => {

@@ -118,2 +123,3 @@ // Remove the client node from the clients array

node.readValue = topic => {

@@ -133,3 +139,2 @@ if (node.knxConnection) {

node.connect = () => {

@@ -228,2 +233,4 @@ node.setClientStatus("disconnected","red","")

function buildInputMessage(src, dest, evt, value, inputDpt, _devicename) {

@@ -254,75 +261,72 @@ // Resolve DPT and convert value if available

node.on("close", function () {
node.setClientStatus("disconnected","red","")
node.knxConnection = null
})
}
function toJsonCSV(_csvText) {
var ajsonOutput = new Array(); // Array: qui va l'output totale con i nodi per node-red
readCSV = (_csv, _checkOnly) => {
var retLog = "" // if _checkOnly, returns this, otherwise, the json array of the group addresses in the csv
if (_csv=="") {
RED.log.info('knxUltimate: no csv ETS found')
return null;
} else {
RED.log.info('knxUltimate: csv ETS found !')
// Read and decode the CSV in an Array containing: "group address", "DPT", "Device Name"
let fileGA = _csv.split("\n");
// Controllo se le righe dei gruppi contengono il separatore di tabulazione
if (fileGA[0].search("\t")==-1) {
RED.log.error('knxUltimate: ERROR: the csv ETS file must have the tabulation as separator')
if (_checkOnly) {
return "knxUltimate: ERROR: the csv ETS file must have the tabulation as separator"
} else {
return null;
if (_csvText == "") {
RED.log.info('knxUltimate: no csv ETS found');
return ajsonOutput;
} else {
RED.log.info('knxUltimate: csv ETS found !');
// Read and decode the CSV in an Array containing: "group address", "DPT", "Device Name"
let fileGA = _csvText.split("\n");
// Controllo se le righe dei gruppi contengono il separatore di tabulazione
if (fileGA[0].search("\t") == -1) {
RED.log.error('knxUltimate: ERROR: the csv ETS file must have the tabulation as separator')
return ajsonOutput;
}
}
var ajsonOutput = new Array(); // Array: qui va l'output totale con i nodi per node-red
for (let index = 0; index < fileGA.length; index++) {
const element = fileGA[index].replace(/\"/g,""); // Rimuovo le virgolette
if (element !== "") {
if (element.split("\t")[1].search("-")==-1 && element.split("\t")[1].search("/")!==-1) {
// Ho trovato una riga contenente un GA valido, cioè con 2 "/"
if (element.split("\t")[5] == "") {
RED.log.error("knxUltimate: ERROR: Datapoint not set in ETS CSV. Please set the datapoint with ETS and export the group addresses again. ->" + element.split("\t")[0] + " " + element.split("\t")[1])
if (_checkOnly) {
return "knxUltimate: ERROR: Datapoint not set in ETS CSV. Please set the datapoint with ETS and export the group addresses again. ->" + element.split("\t")[0] + " " + element.split("\t")[1]
} else {
return null;
for (let index = 0; index < fileGA.length; index++) {
const element = fileGA[index].replace(/\"/g, ""); // Rimuovo le virgolette
if (element !== "") {
if (element.split("\t")[1].search("-") == -1 && element.split("\t")[1].search("/") !== -1) {
// Ho trovato una riga contenente un GA valido, cioè con 2 "/"
if (element.split("\t")[5] == "") {
RED.log.error("knxUltimate: ERROR: Datapoint not set in ETS CSV. Please set the datapoint with ETS and export the group addresses again. ->" + element.split("\t")[0] + " " + element.split("\t")[1])
return ajsonOutput;
}
var DPTa = element.split("\t")[5].split("-")[1];
var DPTb = "";
try {
DPTb = element.split("\t")[5].split("-")[2];
} catch (error) {
DPTb = "001"; // default
}
if (!DPTb) {
RED.log.warn("knxUltimate: WARNING: Datapoint not fully set (there is only the first part on the left of the '.'). I applied a default .001, but please set the datapoint with ETS and export the group addresses again. ->" + element.split("\t")[0] + " " + element.split("\t")[1] + " Datapoint: " + element.split("\t")[5]);
retLog += "knxUltimate: WARNING: Datapoint not fully set (there is only the first part on the left of the '.'). I applied a default .001, but please set the datapoint with ETS and export the group addresses again. ->" + element.split("\t")[0] + " " + element.split("\t")[1] + " Datapoint: " + element.split("\t")[5] + "<br />"
DPTb = "001"; // default
}
// Trailing zeroes
if (DPTb.length == 1) {
DPTb = "00" + DPTb;
} else if (DPTb.length == 2) {
DPTb = "0" + DPTb;
} if (DPTb.length == 3) {
DPTb = "" + DPTb; // stupid, but for readability
}
ajsonOutput.push({ ga: element.split("\t")[1], dpt: DPTa + "." + DPTb, devicename: element.split("\t")[0] });
}
var DPTa = element.split("\t")[5].split("-")[1];
var DPTb = "";
try {
DPTb = element.split("\t")[5].split("-")[2];
} catch (error) {
DPTb = "001"; // default
}
if (!DPTb) {
RED.log.warn("knxUltimate: WARNING: Datapoint not fully set (there is only the first part on the left of the '.'). I applied a default .001, but please set the datapoint with ETS and export the group addresses again. ->" + element.split("\t")[0] + " " + element.split("\t")[1] + " Datapoint: " + element.split("\t")[5]);
retLog+="knxUltimate: WARNING: Datapoint not fully set (there is only the first part on the left of the '.'). I applied a default .001, but please set the datapoint with ETS and export the group addresses again. ->" + element.split("\t")[0] + " " + element.split("\t")[1] + " Datapoint: " + element.split("\t")[5] + "<br />"
DPTb = "001"; // default
}
// Trailing zeroes
if (DPTb.length == 1) {
DPTb = "00" + DPTb;
}else if (DPTb.length==2) {
DPTb = "0" + DPTb;
}if (DPTb.length==3) {
DPTb = "" + DPTb; // stupid, but for readability
}
ajsonOutput.push({ga:element.split("\t")[1],dpt:DPTa+"."+DPTb,devicename:element.split("\t")[0]});
}
}
}
if (_checkOnly) {
return retLog;
} else {
}
return ajsonOutput;
}
}
node.on("close", function () {
node.setClientStatus("disconnected","red","")
node.knxConnection = null
})
}
RED.nodes.registerType("knxUltimate-config", knxUltimateConfigNode);
}

@@ -14,4 +14,2 @@ module.exports = function (RED) {

node.outputtype = config.outputtype || "write" // When the node is used as output

@@ -18,0 +16,0 @@ node.on("input", function (msg) {

{
"name": "node-red-contrib-knx-ultimate",
"version": "1.0.4",
"version": "1.0.5",
"description": "Single Node KNX IN/OUT with optional ETS group address importer.",
"dependencies": {
"knx": "2.3.3"
"knx": "=>2.3.5"
},

@@ -8,0 +8,0 @@ "node-red": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet