Basic 1 ... how to check if a sensed value is greater than ...

by 01:20 0 commenti
This simple flow checks whether the Input1 value is greater then 10. If yes it prints out the value alto, otherwise the value basso. 


Notice that since msg.payload is a string it must be parsed into an Integer to check if the condition holds.


if (parseInt(msg.payload)>10){
    msg.payload="alto";
}
else{
    msg.payload="basso";
}
return msg;

[{"id":"4f4135f7.fc1a5c","type":"ui_tab","z":"912f565f.b221e8","name":"Basic","icon":"dashboard","order":"1"},{"id":"301cc185.91e06e","type":"ui_text_input","z":"912f565f.b221e8","tab":"4f4135f7.fc1a5c","mode":"text","delay":300,"name":"Input1","topic":"","group":"","order":1,"x":152,"y":290,"wires":[["f680c1ca.0088e"]]},{"id":"f680c1ca.0088e","type":"function","z":"912f565f.b221e8","name":"Check Input1 >","func":"if (parseInt(msg.payload)>10){\n    msg.payload=\"alto\";\n}\nelse{\n    msg.payload=\"basso\";\n}\nreturn msg;","outputs":1,"noerr":0,"x":358,"y":290,"wires":[["a888e7e3.b61418"]]},{"id":"a888e7e3.b61418","type":"ui_text","z":"912f565f.b221e8","tab":"4f4135f7.fc1a5c","name":"Out","group":"","order":1,"format":"{{msg.payload}}","x":566,"y":291,"wires":[]}]

andrea

Developer

Cras justo odio, dapibus ac facilisis in, egestas eget quam. Curabitur blandit tempus porttitor. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.

0 commenti:

Posta un commento

Nota. Solo i membri di questo blog possono postare un commento.