Hi. Im struggling since over 1 day with my if statements. i tried anything i know from java but it doesn´t works please help me. Here´s my function node:
var valueFromTrigger1 = parseInt(msg.payload.Trig0);
var valueFromTrigger2 = parseInt(msg.payload.Trig1);
var valueFromTrigger3 = parseInt(msg.payload.Trig2);
var valueFromTrigger4 = parseInt(msg.payload.Trig3);
var valueFromTrigger5 = parseInt(msg.payload.Trig4);
var valueFromDatabase1 = parseInt(msg.payload.Wert0);
var valueFromDatabase2 = parseInt(msg.payload.Wert1);
var valueFromDatabase3 = parseInt(msg.payload.Wert2);
var valueFromDatabase4 = parseInt(msg.payload.Wert3);
var valueFromDatabase5 = parseInt(msg.payload.Wert4);
var kindOfTrigger = msg.payload.T.toString();
var valueToSet = msg.payload.TV.toString().toString(16);
var valueToSetInDb = msg.payload.TV;
if(valueFromTrigger1 == valueFromDatabase1 && valueFromTrigger2 == valueFromDatabase2 && valueFromTrigger3 == valueFromDatabase3 && valueFromTrigger4 == valueFromDatabase4 && valueFromTrigger5 == valueFromDatabase5 && kindOfTrigger == "set all adresses"){
for(i=0;i<=111;i++){
var currentAdress= i.toString().toString(16);
var newMsg = msg;
newMsg.payload = new Buffer(["0x7c","0x06","0x05","0x01", currentAdress , valueToSet ]);
// newMsg.topic = "UPDATE BUS SET WERT= "+"\'"+valueToSetInDb+"\'"+" WHERE BUSNUMMER= "+"\'"+i+"\'"+"" ;
node.send(newMsg);
}
}else if(valueFromTrigger1 == valueFromDatabase1 && valueFromTrigger2 == valueFromDatabase2 && valueFromTrigger3 == valueFromDatabase3 && valueFromTrigger4 == valueFromDatabase4 && valueFromTrigger5 == valueFromDatabase5 && kindOfTrigger == "set every even adress"){
for(i=0;i<=111;i+=2){
var currentAdress1= i.toString().toString(16);
var newMsg1 = msg;
newMsg1.payload= new Buffer(["0x7c","0x06","0x05","0x01", currentAdress1 , valueToSet ]);
// newMsg1.topic = "UPDATE BUS SET WERT= "+"\'"+valueToSetInDb+"\'"+" WHERE BUSNUMMER= "+"\'"+i+"\'"+"" ;
node.send(newMsg1);
}
}else if(valueFromTrigger1 == valueFromDatabase1 && valueFromTrigger2 == valueFromDatabase2 && valueFromTrigger3 == valueFromDatabase3 && valueFromTrigger4 == valueFromDatabase4 && valueFromTrigger5 == valueFromDatabase5 && kindOfTrigger == "set every odd adress"){
for(i=1;i<=111;i+=2){
var currentAdress2= i.toString().toString(16);
var newMsg2 = msg;
newMsg2.payload= new Buffer(["0x7c","0x06","0x05","0x01", currentAdress2 , valueToSet ]);
// newMsg2.topic = "UPDATE BUS SET WERT= "+"\'"+valueToSetInDb+"\'"+" WHERE BUSNUMMER= "+"\'"+i+"\'"+"" ;
node.send(newMsg2);
}
}
only the if-statement is the relevant part