Deduct old payload from new payload

Hi,

I am currently getting a payload that is perfectly fine to further use, but I would also like to deduct the previous payload

Ideally something like

payload=new.payload-old.payload

Is this easily done in a function somehow?

Best regards

Take a look at https://nodered.org/docs/writing-functions#storing-data

Thank you for the link, unfortunately I wasn’t able to derive anything that worked…

Is it some sort of buffer or similar I need to do?

Best regards

No node red doesn’t have a “buffer” of previous messages. So if you want to remember the previous message you will have to choose to store it, which is why I linked to the page that shows you how.

Just to give a bit more of a pointer, the docs @ukmoose has linked to shows you how to store data in flow context. This can be used to store a message’s payload and retrieve it the next time a Function is called - allowing you to perform the operation you want.