I did find this file in /config/node-red
I did add the above.
Did store an Global var with node-RED.
Shutdown HA (after more then a minute, it is refershing the file every 30 minutes)
After restart the var was gone.
What did I do wrong?
If I look beside global.vuilnisbak the remove “X” is a little bit moved to the left expecting to see something beside the X??
What to do?
Whenever I try to set the contextstorage node red won’t boot. It throws an error:
[09:32:52] INFO: Starting Node-RED...
> start
> node $NODE_OPTIONS node_modules/node-red/red.js "--settings" "/etc/node-red/config.js"
Error loading settings file: /etc/node-red/config.js
/config/node-red/settings.js:46
default: "file",
^^^^^^^
SyntaxError: Unexpected token 'default'
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1031:15)
at Module._compile (node:internal/modules/cjs/loader:1065:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/etc/node-red/config.js:1:16)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
What I did to try to configure the storage:
Opened the file \192.168.1.5\config\node-red\settings.js
I’ve tried to add somewhere early on in the file either of these two snippets of code:
Where is the file containing the context data stored? According to the Node Red documents it would be in ~/.node-red/context/, but in the Home Assistant Node Red Addon, there is no .node-red folder.
I am facing the same issue. I need to restore my global variables after a restart, but I cannot locate the settings.js file in my HO filesystem. I am using a function where I store values like this: global.set('name', value)
How can I find the settings file for Node-Red or store global variables to a file?
The HA folders have recently moved things around to new locations. Add-on configurations are now held in /addon_configs, and within this Node-RED now has its own folder ‘a0d7b954_nodered’, and within that you will find the Node-RED settings.js file
I have Samba share set up on my HA, which is very convenient for setting up network locations on my PC, so I can get to the various key folders directly.
The ‘context store’ bit is towards the bottom on the settings file. I just set up an extra ‘persist’ context using the ‘localfilesystem’ which works nicely for me. Note that the file system context store apparently only flushes to disk every 30 minutes, so an unexpected shutdown may still result in data loss.
With more than one context store available, the storeName should be used to define which one in the function call (I think this is optional and defaults to the first/default store if not set).
// Set value - sync
flow.set("count", 123, storeName);
Another tip - when using the change node to read back out of context (eg into msg.payload) use the ‘deep copy’ option. This forces the node to make a new copy of the data, which is important when working with objects as they are normally copied by reference, not by value. Copying by reference means that, any change to the object now in msg.payload, will also change the object in context.
Please make sure you take a copy of the original settings file first!