the values will come in at different times, so your function 'Grabar a BD' will not have the data from both when it runs. If you need the data from both, you will have to feed the two change nodes into a join node and feed it's output into the function node.
Read up about the join node to see how it works and/or do some google searches to learn about it.
Okay I think I got the problem:
I try to send 2 obj type, but then,how can I get the number on this?
var lines = msg.payload.split("\n");
var outp = [];
outp[0] = {payload:lines[0]};
outp[1] = {payload:lines[1]};
var sql= "";
var d = new Date();
var epoch = d.getTime();
var device="ESP8266";
var outputs = [];
var eHall=outp[0].toInt();
var gas=outp[1].toInt();
/*sq1 = "INSERT INTO dhtreadings (eHall,gas,fecha,hora,device)" +
"VALUES ("+outp[1]+","+outp[0]+","+d+","+epoch+","+device+")";
outputs.push({topic:sq1});*/
var fecha=d.toString();
var hora=epoch.toString();
sq1 = "INSERT INTO lecturasensor (eHall,gas,fecha,hora,device)" +
"VALUES ("+eHall+","+gas+","+fecha+","+hora+","+device+")";
outputs.push({topic:sq1}); indent preformatted text by 4 spaces
I get this from union
What I intent to do, is get the first value and put it on eHall, and the second value on gas. Then send it to my sqlite db.
Can you show what is coming out of the debug node connected to the join. Also please read the post in the FAQ which explains how to add your flow to a post, then edit and fix your posted flow
Okay I solve it!!
I put the join like an array and then I can get both values!! YAY
Now I got two problems: I wanted to send the day and the hour on string Format, but when I do that, it's appears a msg that said: Unexpected String.
var value =[];
var value=msg.payload;
var eHall=parseInt(value[1]);
var gas=parseInt(value[0]);
var sql= "";
var d = new Date();
var epoch = d.getTime();
var dispositivo="ESP8266";
var outputs = [];
/*sq1 = "INSERT INTO lecturasensor (eHall,gas,fecha,device)" +
"VALUES ("+eHall+","+gas+","+tiempo+","+dispositivo")";
outputs.push({topic:sq1});*/
sq1 = "INSERT INTO dhtreadings (eHall,gas)" +
"VALUES ("+eHall+","+gas+")";
outputs.push({topic:sq1});
//Actualizar status con el tiempo
var now=new Date();
var yyyy = now.getFullYear();
var mm=now.getMonth()<9? "0" + (now.getMonth()+1): (now.getMonth()+1); //getMonth()
var dd=now.getDate()<10? "0" + now.getDate() : now.getDate();
var hh = now.getMinutes() < 10 ? "0" +now.getMinutes() : now.getMinutes();
var ss = now.getSeconds()< 10 ? "0" + now.getSeconds(): now.getSeconds();
node.status({fill:"blue",shape:"ring",text:"Última actualización: "+dd+"."+mm+"."+yyyy+""+hh+":"+ss});
return [outputs];