Hi guys,
two variables that I enter in a form on the dashboard, should retain their values even after restarting node-red. It's not working in my project, so I will show you what I have done and hope you can give me a solution. Node-Red is running on a raspberry.
I have change the settings.js context storage property to:
I have write a function to store the values in a global array using global.set:
// after click on submit button the function get executed
// msg.payload = contain values written by user in form
ip_api=[ ]; // global array to store ip address and api-key provided by user
{
ip_api[0]=msg.payload["easyE4 IP-Adresse"];//storing the ip address in global array.
ip_api[1]=msg.payload["easyE4 API-SchlĂĽssel"];//storing the API-Key in global array.
}
global.set("ip",ip_api[0]); // method to set global varible/array
global.set("api",ip_api[1]); // method to set global varible/array
msg.payload = ip_api;
return msg;
Everything is working fine in my project, but after restart of the raspberry I have to enter values again.
What have I done wrong?
I hope, I can get a little support from the community.
Ralf
The form fields will be empty after a restart, but the global variables should still exist, did you check the context data ? (you probably need to refresh it)
Hi guys,
I have found my mistake. I eddit the wrong settings.js.
I'm a linux beginner, and didn't nowing, that I have to look for a hide file.
So therefore I eddit the file found in the directory "/usr/lib/node_modules/node-red".
Now I have found the right file in "/home/pi/.node-red" and everythings working as expected.