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
0
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.1.14 to 1.1.15

73

boolean-logic-ultimate/RailwaySwitchUltimate.js

@@ -11,7 +11,4 @@ module.exports = function (RED) {

""
) || "trigger"; // Topic controlling the iRailway
node.iRailway = Number(node.config.initializewith); // Railway selector
node.autoToggle =
config.autoToggle === undefined ? 0 : parseInt(config.autoToggle); // Auto toggle the selected "initializewith" after a while (useful for homekit bridged, that sends junk after start)
node.timerAutoToggle = null;
) || "trigger"; // Topic controlling the sRailway
node.sRailway = String(node.config.initializewith); // Railway selector

@@ -34,27 +31,10 @@ function setNodeStatus({ fill, shape, text }) {

node.alignStatus = () => {
let sAutoToggle =
node.autoToggle > 0 ? " (Autotoggle in " + node.autoToggle + "s)" : "";
if (node.iRailway === 0) {
setNodeStatus({
fill: "green",
shape: "dot",
text: "-> UPPER PIN" + sAutoToggle,
});
} else {
setNodeStatus({
fill: "blue",
shape: "dot",
text: "-> LOWER PIN" + sAutoToggle,
});
}
setNodeStatus({
fill: "green",
shape: "dot",
text: "-> PIN " + node.sRailway,
});
};
if (node.autoToggle > 0) {
node.timerAutoToggle = setTimeout(() => {
node.autoToggle = 0;
node.iRailway === 0 ? (node.iRailway = 1) : (node.iRailway = 0);
node.alignStatus();
}, node.autoToggle * 1000);
}
node.alignStatus();

@@ -88,23 +68,16 @@

}
msg.payload = utils.ToBoolean(
sPayload = String(sPayload); // Must be always a string
msg.payload = utils.ToAny(
sPayload,
RED.nodes.getNode(config.translatorConfig) // Retrieve the config node. It can be null, but it's handled in utils.js;
);
);
if (msg.payload === undefined) return null;
if (node.timerAutoToggle !== null)
// 28/01/2022 Stop autotoggle
clearInterval(node.timerAutoToggle);
if (msg.payload === false) node.iRailway = 0;
if (msg.payload === true) node.iRailway = 1;
if (node.iRailway === 0) {
setNodeStatus({
fill: "green",
shape: "dot",
text: "-> UPPER PIN",
});
} else {
setNodeStatus({ fill: "blue", shape: "dot", text: "-> LOWER PIN" });
}
// Backward compatibility
// Pass msg.payload = false switches the msg input to the UPPER output
// Pass msg.payload = true switches the msg input to the LOWER output
if (msg.payload === false) msg.payload = '0';
if (msg.payload === true) msg.payload = '1';
node.sRailway = msg.payload;
node.alignStatus();
return; // DONT'S SEND THIS MESSAGE

@@ -114,7 +87,7 @@ }

node.currentMsg = RED.util.cloneMessage(msg);
if (node.iRailway === 0) {
node.send([msg, null]);
} else {
node.send([null, msg]);
}
if (node.sRailway === "0") node.send([msg, null, null, null, null]);
if (node.sRailway === "1") node.send([null, msg, null, null, null]);
if (node.sRailway === "2") node.send([null, null, msg, null, null]);
if (node.sRailway === "3") node.send([null, null, null, msg, null]);
if (node.sRailway === "4") node.send([null, null, null, null, msg]);
});

@@ -121,0 +94,0 @@ }

@@ -17,3 +17,3 @@ module.exports.ToBoolean = function ToBoolean(value, _configTranslationNode) {

let inputPayloadToBeTranslated = translationTable[index].split(":")[0];
let outputBoolean = Boolean(translationTable[index].split(":")[1]);
//let outputBoolean = Boolean(translationTable[index].split(":")[1]);
if (

@@ -42,2 +42,29 @@ value.toLowerCase() === inputPayloadToBeTranslated.toLowerCase() &&

module.exports.ToAny = function ToAny(value, _configTranslationNode) {
try {
let translationTable = [];
if (_configTranslationNode === null) {
// Don't do translation, because the default translation input may contin unwanted translations
return value;
} else {
translationTable = _configTranslationNode.commandText.split("\n");
}
for (let index = 0; index < translationTable.length; index++) {
let inputPayloadToBeTranslated = translationTable[index].split(":")[0];
//let outputBoolean = Boolean(translationTable[index].split(":")[1]);
if (
String(value).toLowerCase() === inputPayloadToBeTranslated.toLowerCase() &&
inputPayloadToBeTranslated.toLowerCase() !== ""
) {
return translationTable[index].split(":")[1];
}
}
return value;
} catch (error) {
console.log("Boolean-Logic-Ultimate:utils:toAny: " + error.message);
}
};
module.exports.fetchFromObject = function fetchFromObject(

@@ -44,0 +71,0 @@ _msg,

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

<p>
<b>Version 1.1.15</b> August 2024<br/>
- Railway Switcher: now you can choose between 5 different output instead of 2.</br>
</p>
<p>
<b>Version 1.1.14</b> Mai 2024<br/>

@@ -9,0 +13,0 @@ - FIX: inject node: fixed an error in JSON.parse.</br>

{
"name": "node-red-contrib-boolean-logic-ultimate",
"version": "1.1.14",
"version": "1.1.15",
"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)",

@@ -431,3 +431,3 @@

The railway switcher, switches the input msg flow to one ot the two outputs (upper or lower).
The railway switcher, redirect the incoming messages to one ot the avaiable output pins, just like a railway jinction switch.

@@ -438,18 +438,48 @@ <img src='https://raw.githubusercontent.com/Supergiovane/node-red-contrib-boolean-logic-ultimate/master/img/railroadSwitchScambio.png' width='80%'>

|Property|Description|
|--|--|
| Switcher topic | Whenever the node receives a payload from this **topic**, it switches the input messages to an output. |
| Switcher topic | Whenever the node receives a payload from this **topic**, it redirects the input messages to a choosen output PIN. |
| With Input | It's the msg property to be evaluated. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
| Then | This property, allow you to auto toggle the selected start state after some time. |
| Translator | Translates the incoming <code>payload</code> value. This allows the compatibility with, for example, **HomeAssistant** nodes. |
<br/>
### Inputs
</br>
</br>
The *Switcher topic* controls where the railway switch must be switched, between the output PINs.
Once an output PIN has been choosen, all messages passing through the node will be deviated to te choosen output PIN.
**INPUT MSG WITH "TRIGGER" TOPIC**
: topic (string|number) : this is the topic of the switcher message.
: payload (number|boolean) : this is the ouput PIN selector, base 0 (0 is the first output PIN).
Pass <code>msg.payload = false</code> switches the msg input to the UPPER output</br>
Pass <code>msg.payload = true</code> switches the msg input to the LOWER output</br>
### JSON switcher message
Take the example where you choosen such properties:
**Switcher topic**: "switcher"
**With Input**: "payload"
this JSON input message redirects all input messages to the first PIN
```json
{
topic:"switcher",
payload:0
}
```
this JSON input message redirects all input messages to the second PIN
```json
{
topic:"switcher",
payload:1
}
```
this JSON input message redirects all input messages to the third PIN, and so on...
```json
{
topic:"switcher",
payload:2
}
```
</br>

@@ -463,3 +493,3 @@

```javascript
[{"id":"a6993d5187f05c0a","type":"RailwaySwitchUltimate","z":"e5b506b72b42922e","name":"Railway Switch","triggertopic":"trigger","initializewith":"0","autoToggle":"0","x":490,"y":180,"wires":[["51e7df8da0bd8d67"],["7f33b14e12c91744"]]},{"id":"2e3014226290f678","type":"InjectUltimate","z":"e5b506b72b42922e","name":"Sample message","topic":"Train","curVal":true,"x":180,"y":140,"wires":[["a6993d5187f05c0a"],[],[]]},{"id":"f6f80cd77a65073e","type":"InjectUltimate","z":"e5b506b72b42922e","name":"Railway switcher","topic":"trigger","curVal":true,"x":180,"y":220,"wires":[[],[],["a6993d5187f05c0a"]]},{"id":"51e7df8da0bd8d67","type":"debug","z":"e5b506b72b42922e","name":"Upper railway","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"topic","statusType":"msg","x":720,"y":140,"wires":[]},{"id":"7f33b14e12c91744","type":"debug","z":"e5b506b72b42922e","name":"Lower railway","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"topic","statusType":"msg","x":720,"y":220,"wires":[]},{"id":"8716120e94a7b6ee","type":"comment","z":"e5b506b72b42922e","name":"Switch between railways","info":"","x":190,"y":80,"wires":[]}]
[{"id":"8243309f7c926112","type":"RailwaySwitchUltimate","z":"aa3efc585a6c7b9b","name":"Railway Switch","triggertopic":"switcher","initializewith":"3","payloadPropName":"payload","translatorConfig":"","x":350,"y":260,"wires":[["7f5a2c19a9ef64c8"],["5a35a650b225d910"],[],[],[]]},{"id":"d7bbc077bc20f4ea","type":"InjectUltimate","z":"aa3efc585a6c7b9b","name":"Junction switcher to Rail 0","topic":"","curVal":true,"outputJSON":"{ \n\t\"payload\":0,\n\t\"topic\":\"switcher\"\n}","x":350,"y":80,"wires":[[],[],[],["8243309f7c926112"]]},{"id":"5656d0c2ba66ed5e","type":"InjectUltimate","z":"aa3efc585a6c7b9b","name":"Junction switcher to Rail 1","topic":"","curVal":true,"outputJSON":"{ \n\t\"payload\":\"1\",\n\t\"topic\":\"switcher\"\n}","x":350,"y":160,"wires":[[],[],[],["8243309f7c926112"]]},{"id":"2253336fa8374c78","type":"InjectUltimate","z":"aa3efc585a6c7b9b","name":"Train","topic":"","curVal":true,"outputJSON":"{ \n\t\"payload\":\"hello\",\n\t\"topic\":\"I'm a train!\"\n}","x":110,"y":280,"wires":[["8243309f7c926112"],[],[],[]]},{"id":"7f5a2c19a9ef64c8","type":"debug","z":"aa3efc585a6c7b9b","name":"Rail 0","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":590,"y":260,"wires":[]},{"id":"5a35a650b225d910","type":"debug","z":"aa3efc585a6c7b9b","name":"Rail 1","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":590,"y":300,"wires":[]}]
```

@@ -466,0 +496,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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