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.

53 lines (49 loc) 2.16 kB
/* * 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 SetResetLatchNode(config) { RED.nodes.createNode(this, config); var node = this; node.on('input', function(msg) { //set-reset-latch v2 switch(msg.payload.Input) { case 1: { this.context().set("state", true); node.status({ fill: "green", shape: "dot", text: "SET" }); var message0 = { Value : this.context().get("state")}; var message1 = { Value : !(this.context().get("state"))}; node.send([[{payload : message0}],[{payload : message1}]]); break; } case 2: { this.context().set("state",false); node.status({ fill: "red", shape: "dot", text: "RESET" }); var message0 = { Value : this.context().get("state")}; var message1 = { Value : !(this.context().get("state"))}; node.send([[{payload : message0}],[{payload : message1}]]); break; } default: { // Handle invalid input node.warn("Warning in Node: " + node.id + ", check node status for more information."); node.status({ fill: "red", shape: "ring", text:"Invalid input: Expected 1-based index (1 for Set, 2 for Reset)"}); node.send([[null],[null]]); break; } } }); } RED.nodes.registerType("set-reset-latch", SetResetLatchNode); }