Reset to Default-Settings of a Plugin

Hi,
is there a way to reset the current Plugin-Settings to the default values?

In my case: I have a plugin that had several message-patterns, if the user customize it for its own use and later he want to switch to the default values, he can't.

Where are this plugin-settings stored?

Hope you can help,
Olli

Hi Olli,
no idea if this could work (don't know enough about plugins) but what's about that:
store the default settings in a .json file and if needed read the settings from there ... ?!?

Regards Bernd

I think persiting the values is not the challange, because the default values are already in the plugin.
From my point of view it would be realy cool if the Octoprint-SettingsPlugin has something to handle the reset - function.

For example:

  • The SettingsPlugin has a methode called is_reset_values_allowed. The default return value is false.
  • If the plugin needs a reset, then the plugin could overwrite this methods and return true.
  • Now Octoprint shows a "reset-button" (beside the save-button) of the plugin settings page and if clicked the (already existing) get_settings_defaults is called and these values are persists

That's it, should be easy to implement and every plugin-developer has e benefit of this feature.

BR
Olli

Nope. The buttons down there don't keep track of which page is open right now. Adding that logic plus getting the information through to the frontend whether to even show a reset button and such would be ugly. It wouldn't be impossible, but it would be a ton of work for a fairly niche feature request (you are actually the first plugin author ever to express an interest in nuking the configuration back to defaults).

Haven't tested this yet, but just a shot in the dark, try:

self._settings.set([], None)

That should nuke the existing plugin settings, making stuff automatically fall back to the defaults. I'm just not sure whether I check for empty paths currently and would deny such a call. If so, that could be changed.

Thx, for your feedback!
I know that "easy to implement" some kind of "provocation". Anyway, the most importend point for me, is this answer:

"...you are actually the first plugin author..."

So, if no one else need this feature, it is absolute not necessary to implement a general function for that.

I will take a look at your code suggestion or set each value separately by name.

Yeah, I have my reset button!!
reset_settings

In the new version 1.5.0 of my Plugin: https://github.com/OllisGit/OctoPrint-DisplayLayerProgress I added the reset-functionality.

Solution works with some JavaScript and a REST-Call......it's portable and easy to understand (I think)..I will put this features to all my other plugins in the near future.

BR
Olli

I like that idea. I typically as a developer regularly connect sftp to to my pi and edit the configy.yaml and re-upload/restart octoprint to achieve this. I'd be interested in this feature in plugin manager as well as an option to reinstall the plugin.