@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.
70 lines (57 loc) • 2.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 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);
};