Hello. I'm developing a project on node-RED that uses the influxdb database. Well, I have 2 problems related to printing data in a table.
1 - I want the time label to be written as "Tempo" (my mother tongue). Is it possible to configure the database to return this label or would I have to scan the array and change it?
2 - The time zone for recording the data is different from the place where I live (3 hours more, I live in Brazil). Is it possible to change this, or would I have to do it manually again?
What are you using to display the table? Are you talking about a ui_table dashboard node or something else?
I'm using the ui_table node. As for the label, it's ok, I saw that I can change the columns in the table configuration itself. The only thing that bothers me is the time zone of the records. I saw that if I send the time data to a debug node, node red recognizes my time zone and prints correctly. Obviously, if I send it directly to the table this does not happen.
See: This is the debug node:
Wed Nov 09 2022 10:20:58 GMT-0300 (GMT-03:00)
This is what is printed in the table:
2022-11-09T13:20:58.000Z
I know they are different time formats, but my focus is on the hour, node red recognizes the -3 hour.
You can convert it to a string in your local timezone in a number of ways. probably node-red-contrib-simpletime will do what you want. Alternatively you can do it in a function node using javascript.
You can also use JSONata in a change node using tranform syntax and moments to format the time strings. You can set the location of format using tz(timezone). Enter the timezone you wish to display in the change node tz() section.
e.g.
[{"id":"68814e0abf5a4932","type":"inject","z":"452103ea51141731","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":3840,"wires":[["44af15a1100b75de"]]},{"id":"44af15a1100b75de","type":"template","z":"452103ea51141731","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"2022-11-09T13:20:58.000Z,1,2,3\n2022-11-09T13:20:58.000Z,4,5,6","output":"str","x":260,"y":3840,"wires":[["1893dff8519ec532"]]},{"id":"1893dff8519ec532","type":"csv","z":"452103ea51141731","name":"","sep":",","hdrin":"","hdrout":"none","multi":"mult","ret":"\\n","temp":"time,one,two,three","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":430,"y":3840,"wires":[["dbcd4837c2de3f06","e1080a2f57f66e65"]]},{"id":"dbcd4837c2de3f06","type":"change","z":"452103ea51141731","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$$.payload ~> |$|{\"time\": $moment($.time).tz(\"America/Halifax\").format(\"YYYY-MM-DD HH:mm\")}|","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":3900,"wires":[["ddea3a4a3b906727","2ae34a12eb467538"]]},{"id":"e1080a2f57f66e65","type":"debug","z":"452103ea51141731","name":"debug 109","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":590,"y":3780,"wires":[]},{"id":"ddea3a4a3b906727","type":"debug","z":"452103ea51141731","name":"debug 108","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":550,"y":3900,"wires":[]},{"id":"2ae34a12eb467538","type":"ui_table","z":"452103ea51141731","group":"2d4fe667.28f8ba","name":"","order":17,"width":0,"height":0,"columns":[],"outputs":0,"cts":false,"x":470,"y":3960,"wires":[]},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"demo","tab":"1caa8458.b17814","order":2,"disp":true,"width":"12","collapse":false},{"id":"1caa8458.b17814","type":"ui_tab","name":"Demo","icon":"dashboard","order":1,"disabled":false,"hidden":false}]
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.