@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.
60 lines (47 loc) • 1.71 kB
JavaScript
module.exports = function(RED) {
function MessageArrayNode(config) {
RED.nodes.createNode(this, config);
var node = this;
node.on('input', function(msg) {
//message-array
// Assuming msg.payload contains the JSON object
var jsonObject = msg.payload;
// Function to convert JSON object values to an array
function jsonValuesToArray(json) {
return Object.values(json);
}
// Convert and set to payload
msg.payload = jsonValuesToArray(jsonObject);
// Return the message
return msg;
});
}
RED.nodes.registerType("message-array", MessageArrayNode);
};
module.exports = function(RED) {
function MessageArrayNode(config) {
RED.nodes.createNode(this, config);
var node = this;
this.arrayType = config.arrayType;
this.joinID = config.joinID;
node.on('input', function(msg) {
//message-array
// Assuming msg.payload contains the JSON object
var jsonObject = msg.payload;
// Function to convert JSON object values to an array
function jsonValuesToArray(json) {
return Object.values(json);
}
// Convert and set to payload
jsonPayload = jsonValuesToArray(jsonObject);
var message = {
Type : node.arrayType,
JoinID: node.joinID,
Value : jsonPayload
}
// Return the message
node.send({payload: message});
});
}
RED.nodes.registerType("message-array", MessageArrayNode);
};