Hi everyone
This is my first venture into node-red and wondered if someone could maybe help with an issue I don't seem to resolve after hours of trying.
Thank you in advance
I have a function that simply receives a input of a string of either a "0" or "1" (newinput)
my else if statement then follows the critera and if true is supposed to change a variable tempinput but even though I know the event is being triggered the variable does not change
Many thanks
Andrew
// set tempinput - to be used as a internal changing variable
var tempinput
//set the value of tempinput to 1 to start with to stop undefined
if (tempinput === undefined){
tempinput = "1";}
// declare a variable to me used for sending debug messages
var text
// Assign the incoming character to variable new input
// This value is either a 1 or 0 String formatting
var newinput = msg.payload
// if newinput + tempinput === "01"
if (newinput === "0" && tempinput === "1") {
//Set debug output text
text = "New Trigger " + newinput + "" + tempinput;
// update the variable of tempinput to "0"
tempinput = "0";
// if newinput + tempinput === "10"
} else if (newinput === "1" && tempinput === "0") {
// update the variable of tempinput to "1"
tempinput = "1";
//Set debug output text
text = "Reset" + newinput + "" + tempinput;
} else {
//Set debug output text
text = "Not Important - " + newinput + "" + tempinput;
}
//set out message
var newMsg = {payload: text + " " + tempinput};
//send out message
return newMsg;