in node-red i contextualize my sensors every X messages:
// Initialize a counter in the flow context if it doesn't exist
if (!flow.get("counter")) {
flow.set("counter", 0);
}
// Increment the counter
flow.set("counter", flow.get("counter") + 1);
// If the counter is a multiple of 100, add the context keys
if (flow.get("counter") % 100 === 0) {
msg.payload.SensorContext = {
SensorType:"VolumeMeasurementTool",
UpperTreshold:"100",
LowerTreshold:"0",
SensorID:"uniqueID",
SensorModel:"100XZERA",
SensorInstallDate:"20/5/25",
SensorLastCalibration:"20/5/25",
SensorNextDueCalibration:"20/5/26",
FirmwareVersion:"AZERSD",
SensorResolution: "0.1"
};
}
return msg;