Just one message, I am reading the information from a sqlite database through a query which selects the last record of each so I can perform some operations (I need to check for example temperature > 30 so I can determine that is high temperature).
You can used the "copy path" button in the debug window to help you avoid making mistakes.
click copy path on the item of interest and paste it into the switch input boxes.
There’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item.
Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.
You are not really giving enough info, so difficult to say for sure the best method, but here is how you would set the conditionals in a function node.
This is the method I was looking for. I have tried it but couldnt figure out.
For now, doesnt matter the high/low values. Lets just assume > 50 (high) and <50 (low).
The msg.payload = "on" / "off"; is exactly what I want.
I have 7 conditions for on and 7 conditions for off
If you cannot / will not change your database schema then you will need to coerce your values into numbers before comparing them
e.g...
var temperature = Number(msg.payload[0].TEMPERATURA);
var humidity = Number(msg.payload[0].HUMIDADE);
var moisture = Number(msg.payload[0].HIDRATACAO);
if((temperature > 30 && (moisture < 50 || humidity < 50)) ||
(temperature < 30 && moisture < 50)){
msg.payload = "on";
}else{
msg.payload = "off";
}
HOWEVER, to avoid having to do this all the time / all over your flows, i strongly recommend updating your database schema to use INTS and FLOATS (instead of strings)