Is it possible to trigger a cfg.json save without using the UI? I’m attempting to have three dynamic variables persist between boots. I’ve used readFromConfig() and addToConfig() but my understanding is that this is not tantamount to a save.
It is, but unless you understand the implications it is better for you to implement persistent JSON store in your usermod.
Use serializeJson() and deserializeJson() from ArduinoJSON.
Thanks for that. Is using NVS (with wled) a viable option as well?
File system is using flash memory (i.e. NVM) if you are referring to that.
Use something like:
// sotre
File f = WLED_FS.open(filename, "w");
if (f) serializeJson(jsonDocument, f);
f.close();
// retrieve
File f = WLED_FS.open(filename, "r");
if (f) deserializeJson(jsonDocument, f);
f.close();
You will also need to construct JSON document and populate values in it.