Need help in date picker node

I want to use date picker node for showing data of a sensor from one particular date to another in a table or csv file.Need some guidance on using date picker node in this case


[{"id":"378c3b75.9fbae4","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"57ba1739.bc7e48","type":"base64","z":"378c3b75.9fbae4","name":"","action":"","property":"payload","x":360,"y":60,"wires":[["6462918c.a1cb2"]]},{"id":"77aee3b9.da3aac","type":"inject","z":"378c3b75.9fbae4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"AWcwAQJoaQ==","payloadType":"str","x":199,"y":119,"wires":[["57ba1739.bc7e48"]]},{"id":"6462918c.a1cb2","type":"function","z":"378c3b75.9fbae4","name":"","func":"var bytes = msg.payload;\nif (bytes[0]==01) {\n    var temperature = (bytes[3] << 8) + bytes[2];\n    var humidity= bytes[6];\n    return { \n        payload: {\n            temperature: temperature/10, \n            humidity: humidity/2\n        }\n    }\n}\nelse {\n    var power=bytes[2];\n    return {\n        payload: { power: power }\n    }\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":439,"y":119,"wires":[["d2f7ec64.f6ff5","825b781c.be5ef8","6b92a58.e8ed55c"]]},{"id":"2434032c.0fcafc","type":"debug","z":"378c3b75.9fbae4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":100,"wires":[]},{"id":"d2f7ec64.f6ff5","type":"function","z":"378c3b75.9fbae4","name":"","func":"msg.payload=msg.payload.humidity;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":580,"y":20,"wires":[["2434032c.0fcafc","bc291c0d.9e81c"]]},{"id":"825b781c.be5ef8","type":"function","z":"378c3b75.9fbae4","name":"","func":"msg.payload=msg.payload.temperature;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":560,"y":180,"wires":[["2434032c.0fcafc","26337091.53e99"]]},{"id":"bc291c0d.9e81c","type":"ui_gauge","z":"378c3b75.9fbae4","name":"Humidity","group":"a6fc5114.af331","order":1,"width":0,"height":0,"gtype":"wave","title":"Humidity","label":"units","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"60","seg2":"90","x":760,"y":40,"wires":[]},{"id":"26337091.53e99","type":"ui_gauge","z":"378c3b75.9fbae4","name":"Temperature","group":"a6fc5114.af331","order":0,"width":0,"height":0,"gtype":"gage","title":"Temperature","label":"celcius","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"30","seg2":"60","x":770,"y":200,"wires":[]},{"id":"3e9b3976.4d0bd6","type":"csv","z":"378c3b75.9fbae4","name":"","sep":",","hdrin":false,"hdrout":"once","multi":"one","ret":"\\r\\n","temp":"temperature,humidity","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":530,"y":320,"wires":[["13d5d6c2.70aa09"]]},{"id":"13d5d6c2.70aa09","type":"file","z":"378c3b75.9fbae4","name":"","filename":"D:/Node Red flows/data.csv","appendNewline":false,"createDir":false,"overwriteFile":"false","encoding":"none","x":680,"y":380,"wires":[[]]},{"id":"6b92a58.e8ed55c","type":"function","z":"378c3b75.9fbae4","name":"","func":"msg.payload = {value:msg.payload, timestamp:new Date().toString()};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":590,"y":260,"wires":[["3e9b3976.4d0bd6","2afd62ad.7c2c6e"]]},{"id":"2afd62ad.7c2c6e","type":"debug","z":"378c3b75.9fbae4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":790,"y":280,"wires":[]},{"id":"a6fc5114.af331","type":"ui_group","name":"Analog","tab":"bbb23f8b.85e49","order":1,"disp":true,"width":"6","collapse":false},{"id":"bbb23f8b.85e49","type":"ui_tab","name":"Demo","icon":"dashboard","disabled":false,"hidden":false}]

What guidance do you need?

@collins i want to use this node for seeing data from given range of dates in this case.for example between 01/02/2020 to 03/02/2020 any two given dates to showcase it in table or in some csv file format etc.

I assume you will want to use two date nodes for selecting the start and end times. What problem are you seeing doing that?

Now I have taken 2 nodes what next and do I have attach it in my current flow?

I deduce from your answer that you are a beginner using node red. I suggest you start by watching right through the Node Red Essentials videos that are linked from the node red docs. An hour or two spent doing that will save you, and us, much time in the long run.

1 Like

@collin I have already seen them but nothing specific is given related to date picker node.could you please help me configure the properties of date picker node so i am able to see in node red ui part working.

What have you done to try the date picker? Have you looked at the configuration dialog and read the help text to understand what it does? Have you fed the output into a debug node to see what it produces?

Yes collin we can see the output in degug sidebar from the above flow which I added.should I add date picker node after the function node to see the output?

This Stack overflow answer should help you , but i would recommend you to start with something simpler and to actually learn how node-red operates.
Then on a pice of paper write how your flow should operate , and how your functions should be written.

In fact, since you want two dates (start and finish) at the same time, you might be better using a ui-form node with two data picker fields in it. Then you will automatically get a Submit button to press when you have entered both dates.


Yes Collin I have taken UI form nodes and now where i have to place them in the flow what next?Also want to show the data in a range of dates from one particurlar date to another in table or csv fromat

Ok, so you have got the dates, now you have to work out what you want to do with the dates. and work out how to do it. Presumably you need to use the dates to select data from wherever you have saved the historical data, but you haven't told us how you have saved it.

@colin I have stored data in a csv file and Also i had a question how can i set alarms in node red?Now Do we have to connect ui form node and node red file node.?

That is nothing to do with the subject of this thread. If you ask multiple questions in one thread it will just get confusing. Better to ask again in another thread, and this time explain what you mean by 'set alarms'.

There don't seem to be any timestamps in the file which will make it a bit difficult to extract the data. How much data are you expecting to put there (how many samples per day and how many days)?

@collin Suppose I want 2 data per day on a particurlar date.I tried adding timestamp but it creates another object for it along with temp and humidity.could u add timestamp to my flow so that it also sends timestamp data to csv file along with temp and humidity.

[{"id":"378c3b75.9fbae4","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"57ba1739.bc7e48","type":"base64","z":"378c3b75.9fbae4","name":"","action":"","property":"payload","x":360,"y":60,"wires":[["6462918c.a1cb2"]]},{"id":"77aee3b9.da3aac","type":"inject","z":"378c3b75.9fbae4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"AWcwAQJoaQ==","payloadType":"str","x":199,"y":119,"wires":[["57ba1739.bc7e48"]]},{"id":"6462918c.a1cb2","type":"function","z":"378c3b75.9fbae4","name":"","func":"var bytes = msg.payload;\nif (bytes[0]==01) {\n    var temperature = (bytes[3] << 8) + bytes[2];\n    var humidity= bytes[6];\n    return { \n        payload: {\n            temperature: temperature/10, \n            humidity: humidity/2\n        }\n    }\n}\nelse {\n    var power=bytes[2];\n    return {\n        payload: { power: power }\n    }\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":439,"y":119,"wires":[["d2f7ec64.f6ff5","825b781c.be5ef8","6b92a58.e8ed55c"]]},{"id":"2434032c.0fcafc","type":"debug","z":"378c3b75.9fbae4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":730,"y":100,"wires":[]},{"id":"d2f7ec64.f6ff5","type":"function","z":"378c3b75.9fbae4","name":"","func":"msg.payload=msg.payload.humidity;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":580,"y":20,"wires":[["2434032c.0fcafc","bc291c0d.9e81c"]]},{"id":"825b781c.be5ef8","type":"function","z":"378c3b75.9fbae4","name":"","func":"msg.payload=msg.payload.temperature;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":560,"y":180,"wires":[["2434032c.0fcafc","26337091.53e99"]]},{"id":"bc291c0d.9e81c","type":"ui_gauge","z":"378c3b75.9fbae4","name":"Humidity","group":"a6fc5114.af331","order":1,"width":0,"height":0,"gtype":"wave","title":"Humidity","label":"units","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"60","seg2":"90","x":760,"y":40,"wires":[]},{"id":"26337091.53e99","type":"ui_gauge","z":"378c3b75.9fbae4","name":"Temperature","group":"a6fc5114.af331","order":0,"width":0,"height":0,"gtype":"gage","title":"Temperature","label":"celcius","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"30","seg2":"60","x":770,"y":200,"wires":[]},{"id":"3e9b3976.4d0bd6","type":"csv","z":"378c3b75.9fbae4","name":"","sep":",","hdrin":false,"hdrout":"once","multi":"one","ret":"\\r\\n","temp":"temperature,humidity,timestamp","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":530,"y":320,"wires":[["13d5d6c2.70aa09"]]},{"id":"13d5d6c2.70aa09","type":"file","z":"378c3b75.9fbae4","name":"","filename":"D:/Node Red flows/data.csv","appendNewline":false,"createDir":false,"overwriteFile":"false","encoding":"none","x":680,"y":380,"wires":[[]]},{"id":"2afd62ad.7c2c6e","type":"debug","z":"378c3b75.9fbae4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":790,"y":280,"wires":[]},{"id":"197b0167.3fad4f","type":"ui_form","z":"378c3b75.9fbae4","name":"","label":"","group":"a6fc5114.af331","order":4,"width":0,"height":0,"options":[{"label":"date","value":"Date1","type":"date","required":true,"rows":null},{"label":"date","value":"Date2","type":"text","required":false,"rows":null}],"formValue":{"Date1":"","Date2":""},"payload":"","submit":"submit","cancel":"cancel","topic":"","x":250,"y":300,"wires":[[]]},{"id":"6b92a58.e8ed55c","type":"function","z":"378c3b75.9fbae4","name":"","func":"msg.payload +=new Date().toString();\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":590,"y":260,"wires":[["2afd62ad.7c2c6e","3e9b3976.4d0bd6"]]},{"id":"a6fc5114.af331","type":"ui_group","name":"Analog","tab":"bbb23f8b.85e49","order":1,"disp":true,"width":"6","collapse":false},{"id":"bbb23f8b.85e49","type":"ui_tab","name":"Demo","icon":"dashboard","disabled":false,"hidden":false}]
var bytes = msg.payload;
if (bytes[0]==01) {
    var temperature = (bytes[3] << 8) + bytes[2];
    var humidity= bytes[6];
    return { 
        payload: {
            temperature: temperature/10, 
            humidity: humidity/2,
            timestamp: new Date()
        }
    }
}
else {
    var power=bytes[2];
    return {
        payload: { power: power, timestamp: new Date() }
    }
}
1 Like

Thanks Colin I have got the date also what next?
How will I link the data.csv file to ui form node to see the temperature and humidity values?

There are many ways, if you read the csv file into an array then you can use Array.filter() to select just the ones in the date range.

is there a node for reading csv file to array?how am i able to do so?