From 9170f03a9a434d497026511d87a844fc4b8cd07b Mon Sep 17 00:00:00 2001 From: TheThief Date: Thu, 17 Oct 2024 19:57:00 +0100 Subject: [PATCH] Apply temperature offset (#2) From https://github.com/kantlivelong/OctoPrint-SmartPreheat/issues/17 --- octoprint_smartpreheat/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/octoprint_smartpreheat/__init__.py b/octoprint_smartpreheat/__init__.py index 2439db8..eedb22b 100644 --- a/octoprint_smartpreheat/__init__.py +++ b/octoprint_smartpreheat/__init__.py @@ -92,6 +92,8 @@ def get_temps_from_file(self, selected_file): if gcode in ('M104', 'M109', 'M140', 'M190'): self._logger.debug("Line %d: Detected SetTemp. Line=%s", lineNum, line) + offsets = self._printer._comm.getOffsets() + toolMatch = octoprint.util.comm.regexes_parameters["intT"].search(line) if toolMatch: toolNum = int(toolMatch.group("value")) @@ -104,10 +106,10 @@ def get_temps_from_file(self, selected_file): if gcode in ("M104", "M109"): self._logger.debug("Line %d: Tool %s = %s", lineNum, toolNum, temp) - temps["tools"][toolNum] = temp + temps["tools"][toolNum] = temp + offsets.get("tool%d" % toolNum, 0) elif gcode in ("M140", "M190"): self._logger.debug("Line %d: Bed = %s", lineNum, temp) - temps["bed"] = temp + temps["bed"] = temp + offsets.get("bed", 0) self._logger.debug("Temperatures: %r", temps) return temps