Hi. It's soon to be everyone's favorite Node-RED noob here. I'm saving a log file to a directory on my Raspberry Pi. As a default in the inject node, I have it saving once every minute. I want the user to be able to change that time for saving a log file to any time interval they would like. For example, if you look at the screenshot, if they change it to every 3 minutes, I'd like that to become the new interval for saving the log to the server. I'm looking for as simple a solution as possible. Thanks in advance!
Hi Robbie, time will tell if your'e the favorite noob
You may be out of luck expecting a simple solution, but this is the solution which came to mind.
[{"id":"e26fd59db2401204","type":"cronplus","z":"8ec88bd9c36c3f6b","name":"","outputField":"payload","timeZone":"","persistDynamic":true,"commandResponseMsgOutput":"output1","outputs":1,"options":[],"x":550,"y":605,"wires":[["6f29c58207865ade"]]},{"id":"6f29c58207865ade","type":"debug","z":"8ec88bd9c36c3f6b","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":695,"y":605,"wires":[]},{"id":"931ea753f4b75ba0","type":"function","z":"8ec88bd9c36c3f6b","name":"Time calcs","func":"let delay = msg.payload\n\nreturn {payload:\n[\n {\n \"command\": \"remove-all-dynamic\"\n },\n {\n \"command\": \"add\",\n \"name\": \"save log\",\n \"expression\": \"0 */\" + delay + \" * * * *\",\n \"payload\": \"Now\",\n \"type\": \"str\"\n}]\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":605,"wires":[["e26fd59db2401204"]]},{"id":"4c5edda6488feeb8","type":"inject","z":"8ec88bd9c36c3f6b","name":"Every 1 minute","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":175,"y":605,"wires":[["931ea753f4b75ba0"]]},{"id":"411fe6a57457fda7","type":"inject","z":"8ec88bd9c36c3f6b","name":"Every 3 minutes","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"3","payloadType":"num","x":175,"y":645,"wires":[["931ea753f4b75ba0"]]},{"id":"b252bf9df69ba894","type":"inject","z":"8ec88bd9c36c3f6b","name":"Every 10 minutes","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"10","payloadType":"num","x":175,"y":685,"wires":[["931ea753f4b75ba0"]]}]
You will need to install node-red-contrib-cron-plus first before importing the flow, but it's an example using 'dynamic schedules' that you could adapt to change the interval described above.
Hey Paul - Thanks for the suggestion and taking the time out to reply! I already have the cron installed, and I like it if I was going to be the person using it, but it's a little too robust for what we want to make available to the end user. I'm kinda looking for a solution just using a single numeric or text input through the dashboard ui.
Isn't that what my flow does?
The user would select a value, or input a value from the dashboard UI, which would feed into the function node (the inject nodes in the example are just to demo the process).
So if the user, for example selects '7' from a drop-down UI node, the '7' would feed into the function node, and the Cron+ node will then emit a msg every 7 minutes.
If you mean something completely different, then you may need to describe what you want in more detail.
Also - unless you have an SSD you might want to be careful about excessive writing to an SD card (every minute as in your initial request)
Craig
I don't think writing to the card every minute is a problem, unless it is megabytes of data every minute. That is assuming that good quality cards are being used, with a good headroom of space on the card so that wear levelling can do its job.
It does exactly that! Sorry. My mistake. I have it working now. Am I your favorite noob yet
Thanks for the advice! We decided to go with a 1 TB thumb drive.
Thanks for the input! We've bought "knock-off" cards before, so yes, that's a legitimate consideration.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.