I apologize if this issue has been raised before, I searched the history and could not find any relevant discussion on the topic.
My proposal centers around modifying the dashboard input notes (numeric, switch, etc.) to make it easier to save and restore their state on restarts, or whenever the nodes are (re)created. I am aware of how to implement this with existing nodes (see Dashboard backup for example), but with many widgets the flows get, in my opinion, unnecessarily large and complicated.
Taking the switch node as an example, I propose to add a checkbox, say, below "Wrap value from max to min and min to max", which could say something like "Save and restore state from file context". This checkbox would be disabled if there is no file context (or it could be hidden altogether).
When the user changes the state manually, or via an input message, that state would be saved in the global file context, under the key "dashboard-state", which would be an object whose keys would be the dashboard widget node ids, and the values would be the corresponding state of the associated widgets.
When the nodes are created, if the "Save and restore state from file context" is checked, then the state would be retrieved from the global file context, defaulting to the current widget default if there is no saved state.
I have a proof-of-concept working for the ui_switch node, but I have not looked at the other nodes to see if this can be extended to all the other input widgets. I may also be missing important implications or ramifications of this proposal, so I am keen to get feedback from the community.
Thank you!
Pablo