tl;dr: The only thing I actually need to know is how to separate 3 values from a string (they are separated by a enter) and also convert them into number (since they are numbers in string form) from the output of the join node inside of the function node
Hi, I want to make a simple program that detects wherever a program has frozen by checking wherever the values of this program are the same in 3 different times, currently, 20 seconds later and 40 seconds later, basically if value is the same in these 3 timezones then the program has become frozen and will be closed and reopened on the raspberry pi by a console command
This is how it looks, everything I said works up until the function part: It's pretty simple, a repeating inyection (manually for now since it doesn't work), reading the data from the program from emoncms since the data from that program gets sent to emoncms, getting 3 outputs numbers from diferent times, using the delay node to sync them up...
But after that the problems begin, here is the output from the Join node which is correct but the problem is that when it got joined the data got converted from number to string
This is the omega noob part, because not only are they 3 values, they also are strings mixed in one msg.payload I can't for the life of me figure out how to separate them and also how to then convert them to number again, this is how this completely broken and unfinished JS thing is:
const triple = msg.payload
const words = triple.split(" ");
var valor1 = (words[0]);
var valor2 = (words[1]);
var valor3 = (words[2]);
var valor1n = Number("valor1")
var valor2n = Number("valor2")
var valor3n = Number("valor3")
msg.payload = ((valor1n + valor2n + valor3n)- valor3n * 3);
return msg;
After that probably omegasimple issue is done then I can finish the program which is as simple as ((value1 + value2 + value3) - (value3 * 3)) to check if the values are the same or not (if the result is 0 then all the values are the same and the program is detected as frozen so a command will sent to raspberry pi to close that frozen program.
Cheers