Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # coding=utf-8
- from __future__ import absolute_import
- ### (Don't forget to remove me)
- # This is a basic skeleton for your plugin's __init__.py. You probably want to adjust the class name of your plugin
- # as well as the plugin mixins it's subclassing from. This is really just a basic skeleton to get you started,
- # defining your plugin as a template plugin, settings and asset plugin. Feel free to add or remove mixins
- # as necessary.
- #
- # Take a look at the documentation on what other plugin mixins are available.
- import octoprint.plugin
- import flask
- class IrenePlugin(octoprint.plugin.SettingsPlugin,
- octoprint.plugin.AssetPlugin,
- octoprint.plugin.TemplatePlugin,
- octoprint.plugin.SimpleApiPlugin
- ):
- ##~~ SettingsPlugin mixin
- def get_settings_defaults(self):
- return {
- # put your plugin's default settings here
- }
- def get_template_configs(self):
- return[
- dict(type="navbar", custom_bindings=False),
- dict(type="settings", custom_bindings=False),
- dict(type="sidebar", custom_bindings=True)
- ]
- ##~~ AssetPlugin mixin
- def get_assets(self):
- # Define your plugin's asset files to automatically include in the
- # core UI here.
- return {
- "js": ["js/irene.js"],
- "css": ["css/irene.css"],
- "less": ["less/irene.less"]
- }
- def get_api_commands(self):
- return dict(
- update_speed=["speed"]
- )
- def on_api_command(self, command, data):
- if command == "update_speed":
- speedStr = data.get('speed', None)
- if speedStr != None:
- self._logger.info("Something happened here kir2koon {speedStr}".format(**locals()))
- speed = float(speedStr)
- if speed is not None:
- # self.update_fan_speed(speed)
- print("yo")
- # def on_api_command(self, command, data):
- # import flask
- # if speed == "command1":
- # parameter = "unset"
- # if "parameter" in data:
- # parameter = "set"
- # self._logger.info("command1 called, parameter is {parameter}".format(**locals()))
- # elif command == "command2":
- # self._logger.info("command2 called, some_parameter is {some_parameter}".format(**data))
- # def on_api_get(self, request):
- # return flask.jsonify(foo="bar")
- ##~~ Softwareupdate hook
- def get_update_information(self):
- # Define the configuration for your plugin to use with the Software Update
- # Plugin here. See https://docs.octoprint.org/en/master/bundledplugins/softwareupdate.html
- # for details.
- return {
- "irene": {
- "displayName": "Irene Plugin",
- "displayVersion": self._plugin_version,
- # version check: github repository
- "type": "github_release",
- "user": "robofred",
- "repo": "OctoPrint-Irene",
- "current": self._plugin_version,
- # update method: pip
- "pip": "https://github.com/robofred/OctoPrint-Irene/archive/{target_version}.zip",
- }
- }
- # If you want your plugin to be registered within OctoPrint under a different name than what you defined in setup.py
- # ("OctoPrint-PluginSkeleton"), you may define that here. Same goes for the other metadata derived from setup.py that
- # can be overwritten via __plugin_xyz__ control properties. See the documentation for that.
- __plugin_name__ = "Irene Plugin"
- # Starting with OctoPrint 1.4.0 OctoPrint will also support to run under Python 3 in addition to the deprecated
- # Python 2. New plugins should make sure to run under both versions for now. Uncomment one of the following
- # compatibility flags according to what Python versions your plugin supports!
- #__plugin_pythoncompat__ = ">=2.7,<3" # only python 2
- #__plugin_pythoncompat__ = ">=3,<4" # only python 3
- #__plugin_pythoncompat__ = ">=2.7,<4" # python 2 and 3
- __plugin_pythoncompat__ = ">=2.7,<4"
- def __plugin_load__():
- global __plugin_implementation__
- __plugin_implementation__ = IrenePlugin()
- global __plugin_hooks__
- __plugin_hooks__ = {
- "octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement