Hello
I am trying to enable persistent data storage for Node-Red on my Cerbo GX. I have enabled superuser, set the root password and can access via Putty, but cannot find my way to the directory with the settings.js file.
I am sitting at root@einstein:~
Can anyone tell me the specific commands to get to the right place?
I have tried the standard dir command but that is not recognised
Thanks
Simon
It’s Linux so the command is ls
Like this:
# cd /data/home/nodered/.node-red/
# ls -l
This might be interesting to:
https://communityarchive.victronenergy.com/questions/155949/node-red-config-files.html
Thanks! That gets me as far as the .node-red directory. Do you know where the settings.js file is located? That is, the one that needs to be changed to enable persistent variables and storage to the file system?
i see on the PuTTY screen:
root@einstein:~# cd /data/home/nodered/.node-red/
root@einstein:/data/home/nodered/.node-red# ls
flows.json lib package-lock.json
flows_cred.json node_modules package.json
root@einstein:/data/home/nodered/.node-red#
There is no settings.js there!
Thanks
I guess Node-Red works a little different here.
From what I learned from my link, on startup of Node-RED on Venus it reads three settings files:
- /usr/lib/node_modules/node-red/venus-settings.js
- data/home/nodered/.node-red/settings-venus.js
- /data/home/nodered/.node-red/settings-user.js
Thanks! It turns out that the files were hidden. using ls -a showed them up. I have now edited the .config.users.json file as below (code from here https://nodered.org/docs/user-guide/context), and also added .node-red/context/ directory so that there is somewhere to store the data.
Next step is to re-start Node-Red and see if it works…
Which I have just done, and Node-Red starts and runs fine, but the .config.users.json file has been over-written with my edits removed. After playing about it seems that this file is ‘live’ - i.e. it stores the current config settings, so if you select a filter on the debug screen, this appears as a setting in the file. See below screenshot of file after re-boot and applying debug filter:
So… where to now? How do we get the context storage permanently enabled? any @Victron experts out there can advise?
Do we create a settings.js file in the .node-red/ directory?
Also, any idea what the path for the external storage SD card might be on the Cerbo? Can we also specify this path in the .config file?
Thanks again!
Many files are generated at boot, so you can try editing the script that generates that file. Of course, when you update, it is overwritten again.
You could always run nodered externally, using the process victron provides, then you would be able to fully customise it.
Thanks @nickdb
So, I did try to add a settings.js file, but that is converted to settings.js.old on a re-boot and the context storage still doesn’t work (not surprisingly).
Running Node-Red externally means an extra device, which seems a waste as we have the Cerbo which is a nice piece of industrial kit.
There is a work-around for my problem if we can write all the variables to file (say hourly or daily) using the Node-Red file write node, however despite hunting, I still cannot find the path to access the SD card. Can you advise on that?
Also, is there a way to avoid the settings file being over-written so we can use the full Node-Red features?
Thanks again!
Mine is mounted on /run/media/mmcblk0p1
If you dig through git or the old community archive, I am sure you will find the script that is generating the file you need modified.
Ultimately this is the challenge of customising venus beyond the borders that have been set for it.
Hi Nick
Here are a couple of updates and a question:
Firstly, the settings.js file can be found at root@einstein:/usr/lib/node_modules/node-red/
I have un-commented the relevant lines but still do not get persistent variables (option doesn’t exist in the change node).
Secondly, I found the SD card via PuTTY mounted where you said, and after a little bit of messing about with the path got a file write command with no error. However, when I view the file, nothing has been written to it. So, I added a line of text using the vi editor in PuTTY and can read the file into node-red and the line of text is there. So, we have the right file and path and can access the file.
The issue is how to get the write to file to work correctly? I am just sending a string “Hello world” to the file, and have sent it many times with out any error showing, but it does not appear in the file.
My aim is to create a logfile entry string and send it to the file at a pre-defined time, which is easy enough if the file write function works!
Any ideas?
Thanks