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.3

4

CHANGELOG.md
# node-red-contrib-knx-ultimate
<p>
<b>Version 1.0.3</b><br/>
- If ETS csv file is set, when typing a group address in the node, a list of KNX devices will be shown and when selected, it set the Datapoint and the Devicename automatically.<br/>
</p>
<p>
<b>Version 1.0.2</b><br/>

@@ -4,0 +8,0 @@ - Fixed minor glitches in node config ui<br/>

141

knxUltimate-config.js

@@ -39,68 +39,4 @@ const knx = require('knx')

readCSV = (_csv, RED, _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;
}
}
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;
}
}
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;
}
}
}
module.exports = (RED) => {
module.exports = (RED) => {
RED.httpAdmin.get("/knxUltimateDpts", RED.auth.needsPermission('knxUltimate-config.read'), function (req, res) {

@@ -117,3 +53,2 @@ const dpts =

function knxUltimateConfigNode(n) {

@@ -124,5 +59,10 @@ RED.nodes.createNode(this, n)

node.port = n.port
node.csv = readCSV(n.csv,RED,false) // Array from ETS CSV Group Addresses
node.csv = readCSV(n.csv,false) // Array from ETS CSV Group Addresses
//node.setClientStatus("disconnected","red","")
// Entry point for reading csv from the other nodes
RED.httpAdmin.get("/csv", RED.auth.needsPermission('knxUltimate-config.read'), function (req, res) {
res.json(node.csv)
});
var knxErrorTimeout

@@ -316,3 +256,70 @@ node.nodeClients = [] // Stores the registered clients

}
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;
}
}
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;
}
}
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;
}
}
}
RED.nodes.registerType("knxUltimate-config", knxUltimateConfigNode);
}
{
"name": "node-red-contrib-knx-ultimate",
"version": "1.0.2",
"version": "1.0.3",
"description": "Single Node KNX IN/OUT with optional ETS group address importer.",

@@ -5,0 +5,0 @@ "dependencies": {

# node-red-contrib-knx-ultimate
[![NPM version][npm-version-image]][npm-url]
[![NPM downloads per month][npm-downloads-month-image]][npm-url]
[![NPM downloads total][npm-downloads-total-image]][npm-url]
[![MIT License][license-image]][license-url]
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![Build Status](https://travis-ci.org/Rafelder/knx-datapoints.svg?branch=master)](https://travis-ci.org/Rafelder/knx-datapoints)
![Sample Node](img/sample.png)

@@ -107,2 +114,9 @@

[{"id":"b1d17725.e39228","type":"function","z":"71ead01a.630ba","name":"Read Request","func":"return ({\n readstatus: true,\n knx: {\n destination: \"0/0/1\"}\n });","outputs":1,"noerr":0,"x":260,"y":640,"wires":[["348e7499.c50544"]]},{"id":"94a1fc7b.9a9288","type":"inject","z":"71ead01a.630ba","name":"Trigger","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":640,"wires":[["b1d17725.e39228"]]},{"id":"348e7499.c50544","type":"knxUltimate","z":"71ead01a.630ba","server":"d08a9721.b34f1","topic":"","dpt":"1.001","initialread":false,"notifyreadrequest":false,"notifyresponse":false,"notifywrite":true,"listenallga":true,"name":"All","x":420,"y":640,"wires":[["9d34ac1a.429de"]]},{"id":"9d34ac1a.429de","type":"debug","z":"71ead01a.630ba","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":550,"y":640,"wires":[]},{"id":"d08a9721.b34f1","type":"knxUltimate-config","z":"","host":"224.0.23.12","port":"3671","csv":"\"Group name\"\t\"Address\"\t\"Central\"\t\"Unfiltered\"\t\"Description\"\t\"DatapointType\"\t\"Security\"\n\"Attuatori luci\"\t\"0/-/-\"\t\"\"\t\"\"\t\"Attuatori luci\"\t\"\"\t\"Auto\"\n\"Luci primo piano\"\t\"0/0/-\"\t\"\"\t\"\"\t\"Luci primo piano\"\t\"\"\t\"Auto\"\n\"Camera da letto luce\"\t\"0/0/1\"\t\"\"\t\"\"\t\"Camera da letto luce\"\t\"DPST-1-8\"\t\"Auto\"\n\"Loggia camera da letto\"\t\"0/0/2\"\t\"\"\t\"\"\t\"Loggia camera da letto\"\t\"DPST-1-1\"\t\"Auto\"\n\"Camera armadi luce\"\t\"0/0/3\"\t\"\"\t\"\"\t\"Camera armadi luce\"\t\"DPST-1-1\"\t\"Auto\"\n\"Bagno grande luce\"\t\"0/0/4\"\t\"\"\t\"\"\t\"Bagno grande luce\"\t\"DPST-1-1\"\t\"Auto\"\n\"Loggia bagno grande\"\t\"0/0/5\"\t\"\"\t\"\"\t\"Loggia bagno grande\"\t\"DPST-1-1\"\t\"Auto\"\n\"Bagno grande specchio (switch)\"\t\"0/0/6\"\t\"\"\t\"\"\t\"Bagno grande specchio switch\"\t\"DPST-1-1\"\t\"Auto\""}]
```
```
[license-image]: https://img.shields.io/badge/license-MIT-blue.svg
[license-url]: https://github.com/Rafelder/knx-datapoints/blob/master/LICENSE
[npm-url]: https://npmjs.org/package/knx-datapoints
[npm-version-image]: https://img.shields.io/npm/v/knx-datapoints.svg
[npm-downloads-month-image]: https://img.shields.io/npm/dm/knx-datapoints.svg
[npm-downloads-total-image]: https://img.shields.io/npm/dt/knx-datapoints.svg

Sorry, the diff of this file is not supported yet