Skip to content

Instantly share code, notes, and snippets.

@jneilliii
Last active October 28, 2023 14:51
Show Gist options
  • Save jneilliii/057cf4f153e82746e12e882f14ac326a to your computer and use it in GitHub Desktop.
Save jneilliii/057cf4f153e82746e12e882f14ac326a to your computer and use it in GitHub Desktop.
# coding=utf-8
import octoprint.plugin
class RewritePlugin(octoprint.plugin.OctoPrintPlugin):
def __init__(self):
self.ip_address = "192.168.0.2"
def rewrite(self, comm_instance, phase, cmd, cmd_type, gcode, *args, **kwargs):
if gcode and gcode not in ["M106", "M107"]:
return
if gcode and gcode == "M106":
return [cmd, "@TPLINKON {self.ip_address}"]
if gcode and gcode == "M107":
return [cmd, "@TPLINKOFF {self.ip_address}"]
__plugin_name__ = "Rewrite M106 M107"
__plugin_pythoncompat__ = ">=3,<4"
def __plugin_load__():
global __plugin_implementation__
__plugin_implementation__ = RewritePlugin()
global __plugin_hooks__
__plugin_hooks__ = {
"octoprint.comm.protocol.gcode.queuing": __plugin_implementation__.rewrite
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment