UNPKG

@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.

83 lines (77 loc) 2.71 kB
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); };