Using Node-RED, how do I add missing time/temp data to an InfluxDB database?

I have
Mosquitto MQTT collecting sensor data
all running in Docker containers on a Synology NAS and maintained via a PC.

Recently the Node-RED container stopped working which was fixed with Forum help.

Now, what is the easiest way of adding some missing data to the InfluxDB database, eg time/temperature?

I created a simple Excel spreadsheet with the intention of using the "spreadsheet-in" node to start the process.

This failed when I couldn't even figure out what the absolute path of the .xlsx file was on the NAS or PC when being located by Node-RED in the Docker container!

Was I barking up the right tree, or what is the "right tree"?

Assuming that you know how to formulate the correct timestamp for adding InfluxDB historic records, your issue seems to be more about understanding server filing system access than InfluxDB?

To start understanding the file locations, we first need to know how you are running Node-RED on the Synology NAS.

  1. Node-RED, InfluxDB etc are all running in containers in Docker on the NAS (also a Home Assistant container). I have a number of sensors around the house collecting data and feeding it into InfluxDB via MQTT and Node-Red. I maintain them and view the resulting information in Grafana via a PC.

  2. I started by using a spreadsheet to get the missing data into Node-RED/InfluxDB, because I thought that it would be the easiest way (for me to undersatnd), if there is a more simple, or easier way, then please say.

  3. After I created the spreadsheet on the PC it dawned on me that Node-Red would need to know the path to the file on the PC. Conversley, if the file were on the NAS, where should it be? I tried a number of locations and paths but the "read-file" node reported ""Error: ENOENT: no such file or directory".

If you are running node red in a container then you must put the file in a folder accessible to the container. Which folders are accessible depends on how the container is setup.

And the file/folder structure is relative to the container and not to the NAS. The typical Docker Node-RED install should have a /data folder attached which is your userDir (where the flows and other node-red files exist). So make sure you put your spreadsheet into that folder. Where the data folder physically sits on your NAS depends on how you configured the node-red docker container. You should check its settings to see where you mapped the data folder to.

This is a typical Docker issue, not a node-red issue. Containers are enclosed systems and you need to understand about how they are configured in order to be able to use them sensibly.

When I set up the container, the tutorial had me use the command

"sudo docker run -itd --name="nodered" --restart=always --net=host -p 1880:1880 -e TZ=Europe/London -v /volume2/docker/nodered:/data nodered/node-red"

which I guess set up the mapping to the the "data" folder "nodered".

This is the physical "data" folder in the "Docker" where I put the "Add_Data" spreadsheet.

(I hope that this makes sense)

So, what should I use as "Path"in the "Read File" node?

So I think that the NAS location for your data is /volume2/docker/nodered/ and the location for Node-RED is /data/

From inside node-red, run an exec node with the command ls /data/ and you will see what is there.

Well, thank you for being so patient with me Julian, that did the trick!

The foibles of containers and paths is going in my little black book!

Using a path name of /data/Add_Data.xlsxallowed the spreadsheet to be visible to the next node, so now I can crack on and format the data ready for sending back to InfuxDB.

Thanks again guys.

You might find it easier to access the data if you save it as csv from excel, unless you have already worked out how to access xlsx files.

Thanks Colin, I just happen to be watching a Steve Cope video and it does seem easier to control the data using a csv file - so with your nudge, I'll sack off the .xlsx format and go csv. :grinning:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.