How can I get the minus summary of two measurements

Hi,
I need some help how I can get a negativ summary of two measurements from a photovoltaic and the consumption.

I have two different measurements 1st is the power consumption e.g. 400 watts and a second e.g. 700 watts. Now I want to calculate the minus summary of these two e.g. 400-700=300 watts.

Sorry for my English hopefully it's understandable.

All nodes I searched are for addition for Positiv results.

Thx in advance

will this work?

you need node-red-contrib-calc contrib node

[{"id":"8618330606b79d89","type":"join","z":"c0b4d8b015901a0c","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":370,"y":200,"wires":[["674c590a9310e2e4"]]},{"id":"f86265e069a42c1c","type":"inject","z":"c0b4d8b015901a0c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"kwh","payload":"-700","payloadType":"num","x":200,"y":140,"wires":[["8618330606b79d89"]]},{"id":"460512ee9cb22580","type":"inject","z":"c0b4d8b015901a0c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"kwh","payload":"400","payloadType":"num","x":200,"y":220,"wires":[["8618330606b79d89"]]},{"id":"674c590a9310e2e4","type":"calculator","z":"c0b4d8b015901a0c","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"sum","constant":"","round":true,"decimals":0,"x":510,"y":200,"wires":[["3f9e54561e96a04e"]]},{"id":"3f9e54561e96a04e","type":"calculator","z":"c0b4d8b015901a0c","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"abs","constant":"","round":true,"decimals":0,"x":680,"y":200,"wires":[["e471835148da203d"]]},{"id":"e471835148da203d","type":"debug","z":"c0b4d8b015901a0c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":850,"y":200,"wires":[]}]

Sorry, Just realised your both inputs are POSITIVE, then please change the Operation in the first calc node to SUBTRACT, it should work.

image

Thank you very much. That´s what i need

1 Like

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