Substract in an order

Hello, I'm now trying to substract 2 numbers but they need to be in a specific order, it always has to be PV_DAK - PV_SMA...

Any idea how to do this, when I copy the path to the numbers with said topics it just says "payload".

Thanks

You would need to join the two incoming messages.
e.g.

[{"id":"b13ba1cb.18b6d8","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"PV_DAK","payload":"9999","payloadType":"num","x":400,"y":640,"wires":[["291f29ce.68968e"]]},{"id":"291f29ce.68968e","type":"join","z":"bf9e1e33.030598","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":580,"y":680,"wires":[["c386f74c.b4802"]]},{"id":"75a43cf6.270d74","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"PV_SMA","payload":"999","payloadType":"num","x":410,"y":720,"wires":[["291f29ce.68968e"]]},{"id":"c386f74c.b4802","type":"function","z":"bf9e1e33.030598","name":"","func":"msg.payload = msg.payload.PV_DAK - msg.payload.PV_SMA\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":780,"y":680,"wires":[["da619082.64d898"]]},{"id":"da619082.64d898","type":"debug","z":"bf9e1e33.030598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":960,"y":680,"wires":[]}]

Ok that works thank you, is there a way to give the output the topic PV_ESS? Now the topic is just a random one from the inputs.
Thanks

yes add
msg.topic = "PV_ESS";

Ah yes thanks.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.