node-red-contrib-knx-ultimate
Advanced tools
Comparing version
@@ -8,2 +8,8 @@ # node-red-contrib-knx-ultimate | ||
<p> | ||
<b>Version 1.1.27</b><br/> | ||
- New: added payloadmeasureunit to the node's msg output (for example "W" or "%"), based on Datapoint type.<br/> | ||
- New: added knx.dptdesc to the node's msg output (for example "Power" or "Humidity").<br/> | ||
- New: added Loglevel option in config-node, for debugging pourpose only. Thanks Heleon19.<br/> | ||
</p> | ||
<p> | ||
<b>Version 1.1.26</b><br/> | ||
@@ -10,0 +16,0 @@ - New: Professional Watchdog Node added. Please <a href="https://github.com/Supergiovane/node-red-contrib-knx-ultimate/wiki/7.-WatchDog-Configuration" target="_blank">consult the Wiki</a>.<br/> |
@@ -28,5 +28,14 @@ const knx = require('knx') | ||
} | ||
}; | ||
} | ||
// 06/02/2020 To be tested | ||
// convertSubtype = (baseType) => (kv) => { | ||
// let value = `${baseType.base}.${kv[0]}` | ||
// return { | ||
// value: value | ||
// , text: value + ` (${kv[1].name}${kv[1].unit !== undefined?" - " + kv[1].unit:""})` | ||
// } | ||
// } | ||
toConcattedSubtypes = (acc, baseType) => { | ||
@@ -42,3 +51,2 @@ let subtypes = | ||
module.exports = (RED) => { | ||
@@ -76,2 +84,3 @@ | ||
node.csv = readCSV(config.csv); // Array from ETS CSV Group Addresses | ||
node.loglevel = config.loglevel !== undefined ? config.loglevel : "info"; // 06/02/2020 by Heleon19 Loglevel default info | ||
@@ -102,4 +111,4 @@ // Endpoint for reading csv from the other nodes | ||
}); | ||
node.setAllClientsStatus = (_status, _color, _text) => { | ||
@@ -116,5 +125,5 @@ function nextStatus(oClient) { | ||
try { | ||
node.knxConnection.removeListener("event"); | ||
node.knxConnection.removeListener("event"); | ||
} catch (error) { | ||
} | ||
@@ -124,3 +133,3 @@ try { | ||
} catch (error) { | ||
} | ||
@@ -132,3 +141,3 @@ node.linkStatus = "disconnected"; // 29/08/2019 signal disconnection | ||
} | ||
node.knxConnection = null; | ||
@@ -146,3 +155,3 @@ } | ||
} else { | ||
// Topic must be in formar x/x/x | ||
@@ -168,3 +177,3 @@ if (_Node.topic.split("\/").length < 3) { | ||
node.removeClient = (_Node) => { | ||
@@ -184,7 +193,7 @@ // Remove the client node from the clients array | ||
} | ||
node.readInitialValues = () => { | ||
if (node.linkStatus !== "connected") return; // 29/08/2019 If not connected, exit | ||
if (node.knxConnection) { | ||
if (node.knxConnection) { | ||
var readHistory = []; | ||
@@ -209,8 +218,8 @@ let delay = 0; | ||
} | ||
}) | ||
} | ||
} | ||
node.readValue = topic => { | ||
@@ -224,6 +233,6 @@ if (node.linkStatus !== "connected") return; // 29/08/2019 If not connected, exit | ||
} | ||
} | ||
} | ||
// 01/02/2020 Dinamic change of the KNX Gateway IP, Port and Physical Address | ||
@@ -253,2 +262,3 @@ // This new thing has been requested by proServ RealKNX staff. | ||
suppress_ack_ldatareq: node.suppressACKRequest, | ||
loglevel: node.loglevel, | ||
// wait at least 60 millisec between each datagram | ||
@@ -283,3 +293,3 @@ //minimumDelay: 60, // 02/01/2020 Removed becuse it doesn't respect the message sequence, it sends messages random. | ||
} | ||
} | ||
@@ -304,3 +314,3 @@ } | ||
node.knxConnection = new knx.Connection(knxConnectionProperties); | ||
// Handle BUS events | ||
@@ -319,3 +329,3 @@ node.knxConnection.on("event", function (evt, src, dest, rawValue) { | ||
} catch (error) { } | ||
// 25/10/2019 TRY TO AUTO DECODE | ||
@@ -329,3 +339,3 @@ // -------------------------------- | ||
// -------------------------------- | ||
} else { | ||
@@ -358,3 +368,3 @@ let msg = buildInputMessage(src, dest, evt, rawValue, oGA.dpt, oGA.devicename) | ||
case "GroupValue_Response": { | ||
node.nodeClients | ||
@@ -369,3 +379,3 @@ .filter(input => input.notifyresponse == true) | ||
} catch (error) { } | ||
// 25/10/2019 TRY TO AUTO DECODE | ||
@@ -378,3 +388,3 @@ // -------------------------------- | ||
// -------------------------------- | ||
} else { | ||
@@ -408,7 +418,7 @@ let msg = buildInputMessage(src, dest, evt, rawValue, oGA.dpt, oGA.devicename) | ||
case "GroupValue_Read": { | ||
node.nodeClients | ||
.filter(input => input.notifyreadrequest == true) | ||
.forEach(input => { | ||
if (input.listenallga == true) { | ||
@@ -420,3 +430,3 @@ // Get the DPT | ||
} catch (error) { } | ||
// 25/10/2019 TRY TO AUTO DECODE | ||
@@ -430,3 +440,3 @@ // -------------------------------- | ||
// -------------------------------- | ||
} else { | ||
@@ -472,4 +482,4 @@ let msg = buildInputMessage(src, dest, evt, null, oGA.dpt, oGA.devicename); | ||
}; | ||
// 02/01/2020 All sent messages are queued, to allow at least 50 milliseconds between each telegram sent to the bus | ||
@@ -482,3 +492,3 @@ node.writeQueueAdd = _oKNXMessage => { | ||
function handleTelegramQueue() { | ||
if (node.knxConnection) { | ||
if (node.knxConnection) { | ||
if (node.telegramsQueue.length==0) { | ||
@@ -492,10 +502,10 @@ return; | ||
if (oKNXMessage.outputtype==="response") { | ||
node.knxConnection.respond(oKNXMessage.grpaddr, oKNXMessage.payload, oKNXMessage.dpt); | ||
node.knxConnection.respond(oKNXMessage.grpaddr, oKNXMessage.payload, oKNXMessage.dpt); | ||
} else | ||
{ | ||
node.knxConnection.write(oKNXMessage.grpaddr, oKNXMessage.payload, oKNXMessage.dpt); | ||
node.knxConnection.write(oKNXMessage.grpaddr, oKNXMessage.payload, oKNXMessage.dpt); | ||
} | ||
} | ||
} | ||
// 26/10/2019 Try to figure out the datapoint type from raw value | ||
@@ -508,3 +518,3 @@ function tryToFigureOutDataPointFromRawValue(_rawValue) { | ||
} else { | ||
return "5.001"; // Absolute Brightness ? | ||
return "5.001"; // Absolute Brightness ? | ||
} | ||
@@ -514,3 +524,3 @@ } else if (_rawValue.length == 4) { | ||
} else if (_rawValue.length == 2) { | ||
return "9.001"; | ||
return "9.001"; | ||
} else if (_rawValue.length == 14) { | ||
@@ -535,3 +545,3 @@ return "16.001"; // Text ? | ||
var jsValue = dptlib.fromBuffer(_rawValue, dpt) | ||
if (typeof jsValue !== "undefined") { | ||
if (typeof jsValue !== "undefined") { | ||
//RED.log.info("Trying for " + dest + ". FOUND " + element.value); | ||
@@ -542,4 +552,4 @@ return element.value; | ||
} catch (error) { | ||
} | ||
} | ||
} | ||
@@ -573,3 +583,2 @@ } | ||
} | ||
@@ -579,4 +588,3 @@ | ||
// Resolve DPT and convert value if available | ||
//if (dest=="0/0/50") RED.log.error("Buildinputmessage src=" + src + " dest" + dest + " value=" + value + " inputDpt=" + inputDpt + " _devicename="+_devicename); | ||
var dpt = dptlib.resolve(inputDpt) | ||
var dpt = dptlib.resolve(inputDpt); | ||
var jsValue = null | ||
@@ -586,2 +594,8 @@ if (dpt && value) { | ||
} | ||
var sPayloadmeasureunit = "unknown"; | ||
var sDptdesc = "unknown"; | ||
if (dpt.subtype !== undefined) { | ||
sPayloadmeasureunit = dpt.subtype.unit !== undefined ? dpt.subtype.unit : "unknown"; | ||
sDptdesc = dpt.subtype.desc !== undefined ? dpt.subtype.desc.charAt(0).toUpperCase() + dpt.subtype.desc.slice(1) : "unknown"; | ||
}; | ||
@@ -592,2 +606,4 @@ // Build final input message object | ||
, payload: jsValue | ||
, payloadmeasureunit: sPayloadmeasureunit | ||
, devicename: (typeof _devicename !== 'undefined') ? _devicename : "" | ||
, knx: | ||
@@ -597,3 +613,4 @@ { | ||
, dpt: inputDpt | ||
//, dptDetails: dpt | ||
//, details: dpt | ||
, dptdesc: sDptdesc | ||
, source: src | ||
@@ -603,7 +620,6 @@ , destination: dest | ||
} | ||
, devicename: (typeof _devicename !== 'undefined') ? _devicename : "" | ||
} | ||
} | ||
}; | ||
}; | ||
node.on("close", function () { | ||
@@ -614,7 +630,7 @@ clearInterval(node.timerSendTelegramFromQueue); // 02/01/2020 Stop queue timer | ||
}) | ||
function readCSV(_csvText) { | ||
var ajsonOutput = new Array(); // Array: qui va l'output totale con i nodi per node-red | ||
if (_csvText == "") { | ||
@@ -627,3 +643,3 @@ RED.log.info('knxUltimate: no csv ETS found'); | ||
let sTemp = correctCRLFInCSV(_csvText); | ||
// Read and decode the CSV in an Array containing: "group address", "DPT", "Device Name" | ||
@@ -636,3 +652,3 @@ let fileGA = sTemp.split("\n"); | ||
} | ||
var sFirstGroupName = ""; | ||
@@ -644,5 +660,5 @@ var sSecondGroupName = ""; | ||
element = element.replace(/\"/g, ""); // Rimuovo le virgolette | ||
if (element !== "") { | ||
// Main and secondary group names | ||
@@ -659,3 +675,3 @@ if ((element.split("\t")[1].match(/-/g) || []).length == 2) { | ||
if(sFirstGroupName!=="" && sSecondGroupName !==""){sFather="(" + sFirstGroupName + "->" +sSecondGroupName + ") " } | ||
if (element.split("\t")[1].search("-") == -1 && element.split("\t")[1].search("/") !== -1) { | ||
@@ -689,12 +705,12 @@ // Ho trovato una riga contenente un GA valido, cioè con 2 "/" | ||
} | ||
return ajsonOutput; | ||
} | ||
} | ||
// 23/08/2019 Delete unwanted CRLF in the GA description | ||
function correctCRLFInCSV(_csv) { | ||
var sOut = ""; // fixed output text to return | ||
@@ -708,6 +724,6 @@ var sChar = ""; | ||
if (!bStart) { | ||
bStart = true; | ||
bStart = true; | ||
}else | ||
{ | ||
bStart = false; | ||
bStart = false; | ||
} | ||
@@ -722,3 +738,3 @@ sOut += sChar; | ||
{ | ||
sOut += sChar; | ||
sOut += sChar; | ||
} else | ||
@@ -730,5 +746,5 @@ { | ||
{ | ||
sOut += sChar; | ||
sOut += sChar; | ||
} | ||
} | ||
@@ -744,7 +760,5 @@ } | ||
RED.nodes.registerType("knxUltimate-config", knxUltimateConfigNode); | ||
} | ||
{ | ||
"name": "node-red-contrib-knx-ultimate", | ||
"version": "1.1.26", | ||
"version": "1.1.27", | ||
"description": "Single Node KNX IN/OUT with optional ETS group address importer. Easy to use and highly configurable.", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1998293
0.01%995
0.4%50
-1.96%