node-red-contrib-boolean-logic-ultimate
Advanced tools
Comparing version 1.1.5 to 1.1.6
@@ -7,2 +7,3 @@ module.exports = function (RED) { | ||
node.math = config.math === undefined ? "sum" : config.math; | ||
node.subtractstartfrom = config.subtractstartfrom === undefined ? "" : config.subtractstartfrom; | ||
node.topics = []; | ||
@@ -54,4 +55,7 @@ | ||
if (!isNaN(ret) && isFinite(ret)) { | ||
if (node.topics.find(a => a.id === msg.topic.toString()) === undefined) { | ||
let oFound = node.topics.find(a => a.id === msg.topic.toString()); | ||
if (oFound === undefined) { | ||
node.topics.push({ id: msg.topic.toString(), val: ret }); | ||
} else { | ||
oFound.val = ret; | ||
} | ||
@@ -82,8 +86,20 @@ | ||
} else if (node.math === "subtract") { | ||
let risultato = node.topics[0].val; | ||
let risultato = 0; | ||
if (node.subtractstartfrom !== "") { | ||
try { | ||
risultato = node.topics.find(m => m.id === node.subtractstartfrom).val; | ||
} catch (error) { | ||
setNodeStatus({ fill: "grey", shape: "ring", text: "Waiting for " + node.subtractstartfrom }); | ||
return; | ||
} | ||
} else { | ||
setNodeStatus({ fill: "red", shape: "ring", text: "Please specify the topic form subtract to." }); | ||
return; | ||
} | ||
quantita = 1; | ||
for (let index = 1; index < node.topics.length; index++) { | ||
risultato -= node.topics[index].val; | ||
++quantita; | ||
for (let index = 0; index < node.topics.length; index++) { | ||
if (node.topics[index].id !== node.subtractstartfrom) { | ||
risultato -= node.topics[index].val; | ||
++quantita; | ||
} | ||
} | ||
@@ -90,0 +106,0 @@ |
@@ -7,2 +7,6 @@ # node-red-contrib-boolean-logic-ultimate | ||
<p> | ||
<b>Version 1.1.6</b> April 2024<br/> | ||
- Math node: in SUBTRACT mode, now you must set a msg.topic to start subtracting from.</br> | ||
</p> | ||
<p> | ||
<b>Version 1.1.5</b> April 2024<br/> | ||
@@ -9,0 +13,0 @@ - Math node: fixed an issue with the "subtract" operator. See contestual help in the node-red help tab.</br> |
{ | ||
"name": "node-red-contrib-boolean-logic-ultimate", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "A set of Node-RED enhanced boolean logic and utility nodes, flow interruption, blinker, invert, filter, toggle etc.., with persistent values after reboot. Compatible also with Homeassistant values.", | ||
@@ -5,0 +5,0 @@ "author": "Supergiovane (https://github.com/Supergiovane)", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1264734
1445