var valeurOPCUA = msg.payload; // Stocke la valeur OPC UA dans une variable
flow.set('valeurOPCUA', valeurOPCUA); // Stocke la valeur dans une variable de flux (flow)
return msg;
Function Association :
var valeurOPCUA = flow.get('valeurOPCUA'); // Récupère la valeur OPC UA depuis la variable de flux
var dateFormatee = flow.get('dateFormatee'); // Récupère le timestamp depuis le message
var donnéesÀEnregistrer = {
valeurOPCUA: valeurOPCUA,
dateFormatee: dateFormatee
};
msg.payload = donnéesÀEnregistrer;
return msg;
But when i show my database,I don't understand why my values aren't stored in separate columns on the same rows.
This is because Node-RED is message based and asynchronous. So at the start of your flow, you have 2 wires coming out of the trigger node. This creates two separate messages that flow independently of each other. Where you are feeding the 2 wires into a single node, those inputs are not coordinated, each wire results in a separate execution of the function node for each message on each wire.
Ideally, try to keep your flows linear and add additional properties on the msg that flow through to the end.
If that is not possible, you need to use a context variable to temporarily store things so that you can merge the values.