Helpers are methods that plugin can exposed to other plugins in order to make common functionality available on the
system. They are registered with the OctoPrint plugin system through the use of the control property __plugin_helpers__.

An example for providing some helper functions to the system can be found in the
Discovery Plugin,
which provides it’s SSDP browsing and Zeroconf browsing and publishing functions as helper methods.

Listing 30 Excerpt from the Discovery Plugin showing the declaration of its exported helpers.¶

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

def__plugin_load__():ifnotpybonjour:# no pybonjour available, we can't use thatlogging.getLogger("octoprint.plugins."+__name__).info("pybonjour is not installed, Zeroconf Discovery won't be available")plugin=DiscoveryPlugin()global__plugin_implementation____plugin_implementation__=pluginglobal__plugin_helpers____plugin_helpers__=dict(ssdp_browse=plugin.ssdp_browse)ifpybonjour:__plugin_helpers__.update(dict(zeroconf_browse=plugin.zeroconf_browse,zeroconf_register=plugin.zeroconf_register,zeroconf_unregister=plugin.zeroconf_unregister))

An example of how to use helpers can be found in the Growl Plugin.
Using get_helpers() plugins can retrieve exported helper methods and call
them as (hopefully) documented.

Listing 31 Excerpt from the Growl Plugin showing utilization of the helpers published by the Discovery Plugin.¶