Confused about deploying a plugin


#1

I've created a plugin, followed the tutorial and manually deployed it to Raspberry Pi. It works great - after some messing around. But I have a few questions.

Folder structure-wise my plugin is nearly identical to the helloworld sample.

So to deploy the plugin, I copied octoprint_lifxswitch folder to the /home/pi/.octoprint/plugins directory on the PI. That didn't work: it would show the plugin in the Settings screen, but wouldn't do anything once I clicked on it. By looking at the logs, I realized that it was looking for octoprint.plugins.octoprint_lifxswitch plugin, rather than just octoprint.plugins.lifxswitch. Therefore, OctoPrint is getting the name of the plugin based on the name of the directory. I changed the folder from octoprint_lifxswitch to lifxswitch, restarted the PI and everything worked fine.

My questions are as follows:

  1. I have plugin_identifier = "lifxswitch" at the bottom of init.py file. Shouldn't that tell OctoPrint to look for octoprint.plugins.lifxswitch?

  2. The same init.py file has the following line: plugin_name = "Lifx Switch". However, OctoPrint settings screen still shows the plugin as lifxswitch in the sidebar. Why is that and what do I have to do to show the proper plugin name?

  3. Finally, did I go about deploying it correctly?

Thank you.

P.S. I should mention that I am completely new to Python so it is probable that I have made some rookie mistakes.


#2
  1. I think if you install the plugin via the repository url it will get around naming issue you are seeing.
  2. Swap out the end of your code with something like below and install via repository url.
	##~~ Softwareupdate hook
	def get_update_information(self):
		return dict(
			rtmpstreamer=dict(
				displayName="Lifx Switch",
				displayVersion=self._plugin_version,

				# version check: github repository
				type="github_release",
				user="rgelb",
				repo="OctoPrint-LifxSwitch-Plugin",
				current=self._plugin_version,

				# update method: pip
				pip="https://github.com/rgelb/OctoPrint-LifxSwitch-Plugin/archive/{target_version}.zip"
			)
		)

__plugin_name__ = "Lifx Switch"

def __plugin_load__():
	global __plugin_implementation__
	__plugin_implementation__ = LifxSwitchPlugin()

	global __plugin_hooks__
	__plugin_hooks__ = {
		"octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information
	}
  1. The above should fix the deployment side of things as well.

PS: I'm no python expert either, hopefully this helps.


#3

Seriously, though, make sure you search your project for "TODO" and replace those boilerplate text blurbs with something descriptive.


#4

Thanks. That did the trick. The indenting took me a while to get right (just cause I am not used to Python), but other than that it worked perfectly.

One point of clarification: to get get_update_information to fire, you have to specify octoprint.plugin.OctoPrintPlugin mixin in the class constructor.


#5

All replaced. Thanks.