Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-red-contrib-boolean-logic-ultimate

Package Overview
Dependencies
Maintainers
1
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-red-contrib-boolean-logic-ultimate - npm Package Compare versions

Comparing version 1.0.34 to 1.0.35

42

boolean-logic-ultimate/FilterUltimate.js

@@ -15,36 +15,34 @@ module.exports = function (RED) {

this.on('input', function (msg) {
var sTopic = node.config.name;
if (msg.hasOwnProperty("topic")) {
sTopic = (msg.topic === "" ? sTopic : msg.topic);
if (!msg.hasOwnProperty("topic")) {
msg.topic = node.config.name || "";
}
if (!msg.hasOwnProperty("payload")) {
setNodeStatus({ fill: "red", shape: "dot", text: "No payload property from " + sTopic });
if (!msg.hasOwnProperty("payload" || msg.payload === undefined)) {
setNodeStatus({ fill: "red", shape: "dot", text: "No payload property from " + msg.topic });
return;
}
if (msg.payload !== true && msg.payload !== false) {
setNodeStatus({ fill: "red", shape: "dot", text: "Received non boolean value from " + sTopic });
var bRes = null;
try {
bRes = ToBoolean(msg.payload);
} catch (error) {
}
if (bRes === undefined || bRes === null) {
setNodeStatus({ fill: "red", shape: "dot", text: "Received non convertible boolean value " + msg.payload + " from " + msg.topic });
return;
}
var bRes = ToBoolean(msg.payload);
if (typeof bRes === "undefined") return;
// 24/01/2020 Clone input message and replace only payload
var msgOut = RED.util.cloneMessage(msg);
msgOut.payload = bRes;
// 24/01/2020 Clone input message and replace only relevant topics
var msgTrue = RED.util.cloneMessage(msg);
msgTrue.topic = sTopic;
msgTrue.payload = true;
var msgFalse = RED.util.cloneMessage(msg);
msgFalse.topic = sTopic;
msgFalse.payload = false;
if (bRes === true) {
setNodeStatus({ fill: "green", shape: "dot", text: "(Send) true" });
node.send([msgTrue, null]);
} else {
node.send([msgOut, null]);
} else if (bRes === false) {
setNodeStatus({ fill: "green", shape: "dot", text: "(Send) false" });
node.send([null, msgFalse]);
node.send([null, msgOut]);
}
return;
});

@@ -51,0 +49,0 @@

@@ -1,35 +0,48 @@

module.exports = function(RED) {
function InvertUltimate(config) {
RED.nodes.createNode(this,config);
module.exports = function (RED) {
function InvertUltimate(config) {
RED.nodes.createNode(this, config);
this.config = config;
var node = this;
function setNodeStatus({fill, shape, text})
{
function setNodeStatus({ fill, shape, text }) {
var dDate = new Date();
node.status({fill: fill,shape: shape,text: text + " (" + dDate.getDate() + ", " + dDate.toLocaleTimeString() + ")"})
node.status({ fill: fill, shape: shape, text: text + " (" + dDate.getDate() + ", " + dDate.toLocaleTimeString() + ")" })
}
setNodeStatus( {fill: "grey" ,shape: "dot" ,text: "Waiting"});
this.on('input', function(msg) {
var topic = msg.topic || "";
var payload = msg.payload;
if (topic !== undefined && payload !== undefined) {
setNodeStatus({ fill: "green", shape: "dot", text: "(Send) " + !ToBoolean(payload) });
// 24/01/2020 Clone input message and replace only relevant topics
var msgOUt = RED.util.cloneMessage(msg);
msgOUt.topic = topic;
msgOUt.payload = !ToBoolean(payload);
node.send(msgOUt);
return;
setNodeStatus({ fill: "grey", shape: "dot", text: "Waiting" });
this.on('input', function (msg) {
if (msg.hasOwnProperty("payload") && msg.payload !== undefined && msg.payload !== null) {
// 11/11/2021 Clone input message and replace only relevant topics
var bRes = null;
try {
bRes = ToBoolean(msg.payload);
} catch (error) {
}
if (bRes === undefined || bRes === null) {
setNodeStatus({ fill: "red", shape: "dot", text: "Received non convertible boolean value " + msg.payload + " from " + msg.topic });
return;
}
var msgOUt = RED.util.cloneMessage(msg);
try {
msgOUt.payload = !bRes;
setNodeStatus({ fill: "green", shape: "dot", text: "(Send) " + msgOUt.payload });
node.send(msgOUt);
} catch (error) {
setNodeStatus({ fill: "red", shape: "dot", text: "Unable to invert the input payload " + bRes });
}
} else {
setNodeStatus({ fill: "red", shape: "dot", text: "No payload from " + msg.topic });
}
});
});
function ToBoolean( value ) {
function ToBoolean(value) {
var res = false;

@@ -40,7 +53,7 @@ var decimal = /^\s*[+-]{0,1}\s*([\d]+(\.[\d]*)*)\s*$/

res = value;
}
else if( typeof value === 'number' || typeof value === 'string' ) {
}
else if (typeof value === 'number' || typeof value === 'string') {
// Is it formated as a decimal number?
if( decimal.test( value ) ) {
var v = parseFloat( value );
if (decimal.test(value)) {
var v = parseFloat(value);
res = v != 0;

@@ -52,13 +65,13 @@ }

}
return res;
};
}
RED.nodes.registerType("InvertUltimate",InvertUltimate);
}
RED.nodes.registerType("InvertUltimate", InvertUltimate);
}

@@ -5,2 +5,6 @@ # node-red-contrib-boolean-logic-ultimate

<p>
<b>Version 1.0.35</b> November 2021<br/>
- Filterultimate and Invertultimate: added others checks to avoid processing invalid/non boolean convertible payloads and notify it in the node status.</br>
</p>
<p>
<b>Version 1.0.34</b> August 2021<br/>

@@ -7,0 +11,0 @@ - NEW: Impulse node: you run issue a sequence of commands to, for example, open a garage door with a timed impulse, or switch speed of a fan requiring pulsed commands. Check the gitHub home for sample and explanation.</br>

{
"name": "node-red-contrib-boolean-logic-ultimate",
"version": "1.0.34",
"version": "1.0.35",
"description": "A set of Node-RED enhanced boolean logic node, flow interruption node, blinker node, invert node, filter node, with persisten values after reboot and more.",

@@ -5,0 +5,0 @@ "author": "Supergiovane (https://github.com/Supergiovane)",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc