@parallaxcontrol/node-red-control
Version:
A comprehensive package of Node-RED nodes designed to seamlessly integrate with the Parallax Control Engine, offering enhanced control capabilities for AV Automation.
93 lines (87 loc) • 3.15 kB
JavaScript
/*
* Copyright (c) 2025 Parallax AV Design Inc.
* All rights reserved.
*
* This software is licensed, not sold. You may not copy, modify, merge,
* publish, distribute, sublicense, or sell copies of this file or substantial
* portions of it except as expressly permitted by the LICENSE file included
* with this package. Use is restricted to building manifests for the
* Parallax Control Node-RED nodes. See LICENSE for details.
*/
module.exports = function(RED) {
function InputSelectNode(config) {
RED.nodes.createNode(this, config);
var node = this;
this.input = parseFloat(config.input);
node.on('input', function(msg) {
//input-select v2
//handles inject node
if(typeof msg.payload === "boolean")
{
if(msg.payload === true)
{
const outputHigh = {
Input: node.input,
Value: true
};
node.send({payload: outputHigh});
}
if(msg.payload === false)
{
const outputLow = {
Input: node.input,
Value: false
};
node.send({payload: outputLow});
}
}
//handles inject node
if(typeof msg.payload.Value === "boolean")
{
if(msg.payload.Value === true)
{
const outputHigh = {
Input: node.input,
Value: true
};
node.send({payload: outputHigh});
}
if(msg.payload.Value === false)
{
const outputLow = {
Input: node.input,
Value: false
};
node.send({payload: outputLow});
}
}
//handles incoming button presses
if(typeof msg.payload.Value === "string")
{
node.warn("in msg.payload.Value: ");
node.warn("msg.payload.Value: "+msg.payload.Value);
switch(msg.payload.Value){
case "true":
{
const outputHigh = {
Input: node.input,
Value: true
};
node.send({payload: outputHigh});
break;
}
case "false":
{
const outputLow = {
Input: node.input,
Value: false
};
node.send({payload: outputLow});
break;
}
}
}
});
}
RED.nodes.registerType("input-select", InputSelectNode);
};