Using external data source to change payload

Hi, hopefully this is an easy one, I have only just start using node red.

I am working on a lone working alarm type system. when someone presses a button an RF receiver sends a code to node red and then node red does multiple search and replaces on the RF code to change the code to the button wearer’s name.

This is fine, but we are about to add a lot more button and this does not seem the best way to manage this. Ideally we should be maintaining a database or even a CSV which has button codes and user names then the follow uses that to perform any payload changes.

So my flow at the moment:

and i am using a change node

So as this is a real time solution, i do not want to do anything to slow it down, as it currently runs instantly

Is there a way i can populate the change module form an external source? If not is there a node i can use to receive the payload and compare it to a database or CSV file. and change the payload as required?

Any help would be great, thanks

You’re probably going to want to use the file in node. Either trigger the flow at NR startup with an inject node and read/parse the file into memory or put the flow directly in your current flow.

Thanks, I have done this, I can read the file in ok and it is showing as a object within the debug. How to save this to memory so i can use it by another node for example the function node.

Hi, I have managed to save the data into the flow context.

image

an am now just trying to use it a function. so i have this:

image

and inside the function is:

let s = flow.get("code_names");

return s;

but the debug is showing

19/10/2022, 16:13:14node: debug 1
msg.payload : undefined
undefined

How do i us the object in the function module?

Thanks

I have realised by using the node.warn() command I have successfully retrieved the object with the function and can process it.