Last active
October 28, 2023 14:51
-
-
Save jneilliii/057cf4f153e82746e12e882f14ac326a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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