Node-RED – Voorbeeld – Save variable to disk

On this page we give an example and some back=information how to store a node-red variable to disc, so that after a shutdown it can retrieve the data back again.

Some guides here:

Example 1 – In a function

To enable disc writing, edit the node-red settings.js file (mostly found in home/pi/.node-red)

Add these lines (they can also be found in the text)

Then when you want to store a value from a function you can use for example:

The value will be written every 30 seconds.

Where is it stored?

Official docs:

There is a JSON file created with the value in de .node-red/context folder, for example:


Where the foldername is the Flow ID (ae043a50.ff6048)

And the filename is the Node Id (44f81811.9a5e08)

Contents of the JSON file (with the example above)

To retrieve the value, use in a fucntion: