[Solved]I need some help with my plugin

Just some background: I posted a while back about a WiFi Filament scale that I created. I wanted to write a plugin to show that info in OctoPrint. I'm currently working on that plugin, and since I'm fairly new to Python, I'm having all kinds of problems. Anyways, I need help with this problem in particular.

I based my plugin on the Filament Scale plugin. That one simply uses GPIO Pins on the Pi, whereas my plugin would need to get the information via either MQTT or through a web request. I have changed a TON of the code around. And now, with my plugin installed, the Save button on the settings dialog just has a spinner on it, and clicking on it does nothing. I don't see anything in the logs when that happens, or any time before that indicates any error.

Can someone please do me a favor and take a look at the code and tell me if you have any ideas as to what might be causing this issue?

Just looked at your code. I think you need to change all the references for settings.settings.plugins.filament_scale to reference your plugin's identifier filaweigher. At least that's where I would start looking. The settings aren't pulling into your viewmodel properly because of this I think. Look in your browser's developer console on page load is where you will see the errors.

Im pretty sure I did that. I thought I got all the places that reference that. Are you seeing any that I missed?

In the js file there was a bunch.Not sure if it will effect the functionality for you or not. But I just got your plugin to load. I'll submit a PR against your repo with the changes I did.

Ah. I forgot about that. I was going through the files one by one making my changes. I hadn’t gotten there yet. Thanks for the help once again.

Thank you very much for this help. I think this is all I needed to get it to a point where it can display the weight.

No problem, glad to assist.

It looks like I need a little more help now. I got my plugin working. But now I'm just adding some error checking. I have it checking to see if the setting is a valid IP address. If it is not, it logs it, and stops the timer in __init.py. Then I use the 'on_settings_save' function to restart the timer forcing it to check the new IP address that was saved. However, when I add that function in there, it gives me the following warnings, and it doesn't save it. Any ideas on how to correct that? The warning seems like it's telling me to use the 'on_settings_save' function, which I am. I have no idea what the 'super' function is:

2020-01-30 10:28:58,528 - octoprint.server.api.settings - WARNING - Could not save settings for plugin OctoPrint FilaWeigher (0.0.1) since it called super(...)
2020-01-30 10:28:58,528 - octoprint.server.api.settings - WARNING - in a way which has issues due to OctoPrint's dynamic reloading after plugin operations.
2020-01-30 10:28:58,529 - octoprint.server.api.settings - WARNING - Please contact the plugin's author and ask to update the plugin to use a direct call like
2020-01-30 10:28:58,529 - octoprint.server.api.settings - WARNING - octoprint.plugin.SettingsPlugin.on_settings_save(self, data) instead.

Try this...

	def on_settings_save(self, data):
		octoprint.plugin.SettingsPlugin.on_settings_save(self, data)
		try:
			self.t.start()
		except:
			self._logger.info("Couldn't start the timer. Might be running already")

That was it. Thanks again.

I want to test the plugin as it behaves from scratch. How can I uninstall it? I installed it using "octoprint dev plugin:install". It doesn't let me uninstall when I try to do that via the GUI or with pip uninstall. I think it's because the folder is outside the venv folder. Is there any way for me to remove this plugin or at least reset everything?

EDIT: I couldn't figure out how to uninstall still, but I don't need that any more. I was able to reset the plugin settings by deleting from the OctoPrint config.yaml.

Just for your knowledge, typically what I do to uninstall is by typing pip freeze to get the list of installed items. Find your item in the list as it may be named differently than you expect, then use that name in the command pip uninstall plugin_name. The problem is that simply uninstalling will not remove the configuration settings from config.yaml. The current RC for the next version of OctoPrint incorporates some clean-up functions if I remember correctly, so you could uninstall, then load OctoPrint, use that clean-up function to remove the settings from config.yaml and then install again.

I did this, exactly as in the docs but it seems that get_settings_defaults() is not called. I can't find any differences to the example code in the plugin tutorial and there are no visible error messages (except for the 4 warnings) in the log. Any ideas?

Edit: after some debugging and poking I found out that

  1. On my setup these 4 WARNING lines are there even if octoprint.plugin.SettingsPlugin.on_settings_save(self, data) is called in on_settings_save()
  2. I had a typo in a command, I wrote self._settings.get(['foo','bar']) instead of self._settings.get(['foo', 'bar']) and there is no error message or similar in the log. Everything after that was not called.