I have two custom nodes in my flow: an "OccupancyTrigger" node, and a configuration node named "schedule". The OccupancyTrigger node uses schedule to detemine when it should be enabled. I want the schedule node to communicate changes in its state to the OccupancyTrigger node's status.
occupancy_trigger.js
module.exports = function(RED) {
function OccupancyTrigger(config) {
RED.nodes.createNode(this, config);
var node = this;
node.schedule = RED.nodes.getNode(config.schedule);
node.schedule.setupStatusReporting(this.id);
schedule.js
node.setupStatusReporting = function(nodeId) {
node.idsOfNodesToUpdateStatus.push(nodeId);
if (node.isExpired) {
node.setNodeExpiredStatus(nodeId);
} else if (node.isActive) {
node.setNodeActiveStatus(nodeId);
} else {
node.setNodeInactiveStatus(nodeId);
}
}
node.setNodeActiveStatus = function(nodeId) {
var nodeToSet = RED.nodes.getNode(nodeId);
if (nodeToSet ) {
nodeToSet .status({fill: "green", shape: "dot", text: "active"});
} else {
node.warn("couldn't find the node!");
}
};
I have verified that the id of the OccupancyTrigger node is properly being passed into the schedule node, and that it matches the id displayed on my flow, but I always hit my "couldn't find the node!" logic branch. getNode fails me. Any ideas why?