diff --git a/octoprint_RepetierInformer/__init__.py b/octoprint_RepetierInformer/__init__.py index 4dce00a..ed5df0c 100644 --- a/octoprint_RepetierInformer/__init__.py +++ b/octoprint_RepetierInformer/__init__.py @@ -280,8 +280,29 @@ def on_event(self, event, payload): self.sendInformer("Timelapse failed","Timelapse rendering has failed","Timelapse rendering has failed",inform_err) return - - + def hook_gcode_pause(self, comm_instance, phase, cmd, cmd_type, gcode, *args, **kwargs): + # Return if not enabled + if not self._settings.get(['enabled']): + self._logger.info("Not enabled, will not send.") + return + + # Handle pause/resume gcodes + if gcode and gcode == "M24": + if self._settings.get(['notify','printresume']): + self.sendInformer("Printing resumed","Printng has been resumed","Printing has been resumed via M24",inform_ok) + return + if gcode and gcode == "M25": + if self._settings.get(['notify','printpause']): + self.sendInformer("Printing paused","Printng has been paused","Printing has been paused via M25",inform_pause) + return + if gcode and gcode == "M226": + if self._settings.get(['notify','printpause']): + self.sendInformer("Printing paused","Printng has been paused","Printing has been paused via M226",inform_pause) + return + if gcode and gcode == "M600": + if self._settings.get(['notify','printpause']): + self.sendInformer("Printing paused","Printng has been paused","Printing has been paused via M600",inform_pause) + return # If you want your plugin to be registered within OctoPrint under a different name than what you defined in setup.py @@ -295,6 +316,8 @@ def __plugin_load__(): global __plugin_hooks__ __plugin_hooks__ = { - "octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information + "octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information, + "octoprint.comm.protocol.gcode.sent": __plugin_implementation__.hook_gcode_pause + } diff --git a/setup.py b/setup.py index f4fcded..4878673 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_name = "Repetier-Informer for OctoPrint" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "0.1.3" +plugin_version = "0.1.4" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module