Hello guys. I need your help to solve this problem. I'm running node red from my PC and I'm using node red to calculate and count the payment on my brother store. I'm really happy that node red is on my life it helps me too much. I have to calculate >> count the total payment for each staff (how much does he collect on his work hours) and view the total amount for each of the staffs at the end of week. for example (staff1) collect today on five hours work 300$ then on his next five hours work he collect 200$ so the total will be 300$+200$=500$. and same goes to the other staffs. the things that I need is to store the total of each of them on different time. to view them at the end of the week. the problem that when I use function.
it works fine to store the data for each staff but when I Shut down my PC the node red stop as usual, so all the data that stored on the function well be delete. So is there way to store the last data collected until the next day ,,,, until the end of the week. I tried to store the data on excel but the problem that excel will not store the total collected for each staff1 alone on a time it will ask to store also the total collected for the other staffs on the same time. it goes also to the SQLite.
Thanks all your help will be appreciated and respected.
@UnborN Thanks for your time to reply. incase I watched some tutorials on that and all goes as it must be, but when I try it on my node red the change node doesn't have a property to chose a way to save whether to only memory or file.
Did you make the changes to the settings.js file that will enable saving to the file system as is explained in the documentation and stop/start Node-RED?
If you have and it is not working, please start node-red And copy and paste the startup log to a reply.
@zenofmud Thanks for your reply. I already read your explanation on that on your node red post to change a function on the {.node-red/settings.js} file. I need to make sure is this function that I must to enable it on the file. then change it to the function that you shared.
yes .. contextStorage is the part of the settings.js file that you have to un-comment and change.
and as you mentioned above .. if you want the option in your Change node to choose whether you want something to be stored on disk or memory .. then the code you posted will do just that.
In the case of using Context in a Function node ..
you have to pass in an additional parameter to the get and set methods to specify which context store you want to read or write.
If you read carefully the previous link till the end, it points you to another section of the NR documentation for functions.
@UnborN@zenofmud I was a little bit confused. I deleted the change node and all goes fine. I have one more question is there a way that I can export all the flow of node red from node red folder while my site is not working it keeps loading. Maybe because the space is not enough on the ubuntu 18.04. So maybe I'll need to reinstall my ubuntu 18.04. Thanks.
When you start node-red it shows the name of the flow file that is loaded.
for Example on my PC it's flows_NODE.json
1 Aug 21:03:09 - [info] Node-RED version: v2.0.5
1 Aug 21:03:09 - [info] Node.js version: v14.16.0
1 Aug 21:03:09 - [info] Windows_NT 10.0.19043 x64 LE
1 Aug 21:03:11 - [info] Loading palette nodes
1 Aug 21:03:16 - [info] Dashboard version 2.30.0 started at /ui
1 Aug 21:03:17 - [info] Settings file : \Users\User\.node-red\settings.js
1 Aug 21:03:17 - [info] Context store : 'default' [module=localfilesystem]
1 Aug 21:03:17 - [info] Context store : 'memoryOnly' [module=memory]
1 Aug 21:03:17 - [info] User directory : \Users\User\.node-red
1 Aug 21:03:17 - [warn] Projects disabled : editorTheme.projects.enabled=false
1 Aug 21:03:17 - [warn] Flows file name not set. Generating name using hostname.
1 Aug 21:03:17 - [info] Flows file : \Users\User\.node-red\flows_NODE.json
1 Aug 21:03:17 - [info] Server now running at http://127.0.0.1:1880/
check the line Flows file : <your path>\<your file>.json and backup the json file.
but thats backing up only the flow file. For good measure better backup the whole .node-red folder because there are other important files in there also. Like the context folder (now that you are using the file system to save the context on disk)
@UnborN for the ubuntu maybe the file direction is deferent than PC even when you stop node red then you start it again it doesn't show any direction even to node red. I tried to find it from the node-red.service status I found this but is doesn't fit.
if you running node-red as a service you can start, stop and check the log with the commands described here
node-red-start - this starts the Node-RED service and displays its log output. Pressing Ctrl-C or closing the window does not stop the service; it keeps running in the background
node-red-stop - this stops the Node-RED service
node-red-restart - this stops and restarts the Node-RED service
node-red-log - this displays the log output of the service
open a terminal, stop node-red, start it again an see the log so you can investigate why your node-red
is not loading. what did you change ? is it really because of no space on disk ? did you confirm that ?
You only pass two parameters when ‘set’ - then you pass the name of the context variable and the second parameter is the data (actual value, a variable, object, etc).
The ‘get’ only needs the name of the context variable.
If you have two different types of storage for the context, then you may need to specify the name of in addition.
@UnborN Yah it is because there is no space on disk. I tried to find solution on site it says that maybe node red needs upgrades so I followed this commend.
on this way the default storing data will be (storeName) is there a deferent between you function that you shared above and the next function on your post (storeInFile). as shown bellow.
@UnborN I thought that maybe the problem on the version.
Is there a command to run node red service again because I already tried node-red start and enable but it didn’t work.