Hello, I need to implement a system where this system has some default settings. For example, file save location and an ambient temperature field. This information is later stored in a file.
What I need is that every time the browser is shut down or power down, and the next time the user logs in, this default temperature and default directory information will be set automatically in their text fields.
I don't know if I was clear, but if anyone has any flow or any ideas on how I can do it.
Let me see if I've understood. You want to create a user interface that lets the user change some standard variables and have that saved then replayed next time the user reconnects to the UI?
If so, this is fairly easy with Node-RED. All you need to do is to make sure that whatever the user changes is sent back to the Node-RED server and saved there in a way that is replayed whenever a new connection is made to the URL for the ui.
Exactly how you will do that will depend on what you are using to build the UI so that is the next question. Given that you want comms back to Node-RED, you are likely to want to use Dashboard or one of the 3rd party ui's such as my own uibuilder.
If you do use uibuilder, there is an example on the WIKI that shows you how to build a simple cache which is what you want - just make sure that you are using persistent storage for the cache variable. With Dashboard, it has a built-in cache but it isn't persistent across Node-RED restarts. Also, with Dashboard, the cache is always common across all connected users/tabs. It would be possible to adapt the uibuilder cache example to use different caches for different users if you need to do that.
It wouldn't be exactly that. It might be, but if my system, the server shuts down for some reason. I need your last valid configuration read and loaded for the user.
You could save the values in the flow/global context upon change, and set the context as persistent when saving to file. See the relevant part of the docs for persistent storage.
Or if you are already using MQTT then write them to Retained Topics in MQTT.
That is what persistent storage is for. Ceate a secondary context store in settings.js:
Now you can create a variable in the "file" context store and it will survive Node-RED and server restarts.
As Colin points out, you used to have to use MQTT with the retained flag or a file or db to do this. Now, however, you don't.