From c8687b6fbed61322c77f40827127b2bc25b1e890 Mon Sep 17 00:00:00 2001 From: jneilliii Date: Sat, 2 May 2020 13:46:07 -0400 Subject: [PATCH] 0.9.20 (#156) * Fixed @TPLINKON and @TPLINKOFF commands that were broken in last update --- octoprint_tplinksmartplug/__init__.py | 12 ++++++++---- setup.py | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/octoprint_tplinksmartplug/__init__.py b/octoprint_tplinksmartplug/__init__.py index f9b2854..be90289 100644 --- a/octoprint_tplinksmartplug/__init__.py +++ b/octoprint_tplinksmartplug/__init__.py @@ -905,8 +905,11 @@ def processGCODE(self, comm_instance, phase, cmd, cmd_type, gcode, *args, **kwar else: return - elif cmd.startswith("@TPLINKON"): - plugip = re.sub(r'^@TPLINKON\s?', '', cmd) + def processAtCommand(self, comm_instance, phase, command, parameters, tags=None, *args, **kwargs): + self._logger.info(command) + self._logger.info(parameters) + if command == "TPLINKON": + plugip = parameters self._tplinksmartplug_logger.debug("Received @TPLINKON command, attempting power on of %s." % plugip) plug = self.plug_search(self._settings.get(["arrSmartplugs"]),"ip",plugip) self._tplinksmartplug_logger.debug(plug) @@ -914,8 +917,8 @@ def processGCODE(self, comm_instance, phase, cmd, cmd_type, gcode, *args, **kwar t = threading.Timer(int(plug["gcodeOnDelay"]),self.gcode_turn_on,[plug]) t.start() return None - elif cmd.startswith("@TPLINKOFF"): - plugip = re.sub(r'^@TPLINKOFF\s?', '', cmd) + if command == "TPLINKOFF": + plugip = parameters self._tplinksmartplug_logger.debug("Received TPLINKOFF command, attempting power off of %s." % plugip) plug = self.plug_search(self._settings.get(["arrSmartplugs"]),"ip",plugip) self._tplinksmartplug_logger.debug(plug) @@ -974,6 +977,7 @@ def __plugin_load__(): global __plugin_hooks__ __plugin_hooks__ = { "octoprint.comm.protocol.gcode.sent": __plugin_implementation__.processGCODE, + "octoprint.comm.protocol.atcommand.sending": __plugin_implementation__.processAtCommand, "octoprint.comm.protocol.temperatures.received": __plugin_implementation__.monitor_temperatures, "octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information } diff --git a/setup.py b/setup.py index bc45acf..2e26ebe 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_name = "OctoPrint-TPLinkSmartplug" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "0.9.19" +plugin_version = "0.9.20" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module