Trigger Command for Node-RED save to file time period

Hi, I’ve built a data logger that grabs certain points every minute from my Epic and writes the values to a csv file. I use the injector to run this. However, I’m looking for the following to make this enhanced:

  1. only pulls the data starting at 8am and stops pulling the data at 4pm.
  2. each day it creates a new file log called APM1_Temp_Log_[new date].csv

The new file will go to the same path /home/dev/secured/… but will be rename each day to the new date.

Right now I’m using the edit-write-edit-node to create the log to file.

Three part answer to your two part question…

  1. Don’t do parallel reads like you show in your screenshot.
    The parallel API calls can time out or have a lot of jitter from doing (in your case) 8 calls at the same time.
    Better is to convert the flow from parallel to serial (or as some of use like to call it, a snake).
    You can see graphical examples and hear from other user success stories here: Optimizing Node Red Flow
    Note the first and 4th posts. In their case, they had a bunch of injects all firing at 1 second, in your case, you simply use one inject with lots of wires, but the end result is the same, you are both firing off a lot of REST nodes all at the same time. (A second and more powerful example perhaps in the last few posts to this thread here: Node Red - Write file data into Pac write node)
    Better to simply serialize your flow. The end result is exactly the same, only less CPU, faster and more efficient.
  2. For your 8am to 4pm @torchard and I have found the https://flows.nodered.org/node/node-red-contrib-cron-plus node to do the job well. Just go to your pallet manager and search for cron-plus and you will be able to install it and test from there.
  3. For making a new log file every day, this forum post here will get you going: Sending an email attachment with Node-RED My second post in that thread uses the same Moment node that you are using.
2 Likes

Everything @Beno said is spot on, one last thing to add is that the inject node has some more interesting options that are often overlooked. You may want to check that out as well:

1 Like