i am new to Node Red and hope that my question is not too obvious. However, i did not find any thread, related to my current challange.
So what i am currently doing is a twitter parser to CSV. Parsing from twitter to a csv file works like a charm, but the tweets are parsed without timestamps. Could you kindly help me to insert an additional timestamp in an extra column in the created csv file?
Attached you can see the current build of my flow:
You posted this in core development which if you read the description is for developers helping to write to core part of Node-RED. I’ve therefore moved it to the more appropriate #general
You should be able to get the current time stamp using the contrib-moment node, or by using javascript in a function node that you can then add to the message object for passing to a csv file. Have a go and if you get stuck come back and show us where you’ve got to
Here is a function node that will show you how to build up the string required to be put into the file
var topic = msg.topic;
if (msg.payload === "1") {
var p = "On";
}
else if (msg.payload === "0") {
var p = "Off";
}
else var p = "Unknown";
var d = flow.get("MyDateTime") || "0";
//var myCount = flow.get("count", storeName);
//create message to write to the log file
var payload1 = (d + " Tank Pump is " + p + " Topic is: " + msg.topic);
//Store message so it can be output on output 1
var msg1 = { payload:payload1 };
//Create 2nd message for screen writing on scrolling table
var payload2 = (d + " Tank Pump is " + p);
//Store message so it can be output on output 2
var msg2 = { payload:payload2 };
if (p == "On") {
var msg3 = { payload:'<i class="fa fa-refresh fa-spin fa-3x fa-fw"></i>' };
}
if (p == "Off") {
var msg3 = { payload:'<i class="fa fa-stop-circle-o fa-3x fa-fw"></i>' };
}
//End Function and return two messages on two outputs
return [msg1, msg2, msg3,];
I use the Contrib moment function to build a Global variable that is stored in another function and then referenced in here