Hi Node community!
I need some help in trying to do a subtraction operation between two messages that are msg.payload: Topic like: {“T1”:25,“T2”:22}. I want all time make substraction (T1-T2) even T2 is receiving before T1.
Here the flow I am using but I don't know how can I define the msg payload by topic.
Thank you for your help
[{"id":"582edf40.44d24","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"cdb5c940.30f2f8","type":"function","z":"582edf40.44d24","name":"T1","func":"msg.topic=\"T1\";\nmsg.payload=msg.payload;\nreturn msg;","outputs":1,"noerr":0,"x":590,"y":220,"wires":[["6616ab7b.aa7584"]]},{"id":"d672ce87.fcb22","type":"inject","z":"582edf40.44d24","name":"","topic":"","payload":"25","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":"","x":390,"y":220,"wires":[["cdb5c940.30f2f8"]]},{"id":"dec4e2d.489c32","type":"function","z":"582edf40.44d24","name":"T2","func":"msg.topic=\"T2\";\nmsg.payload=msg.payload;\nreturn msg;","outputs":1,"noerr":0,"x":610,"y":300,"wires":[["6616ab7b.aa7584"]]},{"id":"6616ab7b.aa7584","type":"function","z":"582edf40.44d24","name":"Subtraction","func":"msg.payload = (T1 - T2);\n\nreturn msg;","outputs":1,"noerr":0,"x":870,"y":260,"wires":[["aadca427.0494d8"]]},{"id":"df9deb68.eed9c8","type":"inject","z":"582edf40.44d24","name":"","topic":"","payload":"22","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":"","x":390,"y":300,"wires":[["dec4e2d.489c32"]]},{"id":"aadca427.0494d8","type":"debug","z":"582edf40.44d24","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1070,"y":260,"wires":[]}]