diff --git a/docs/features/gcode_scripts.rst b/docs/features/gcode_scripts.rst
index 6b14a616..9c12a35c 100644
--- a/docs/features/gcode_scripts.rst
+++ b/docs/features/gcode_scripts.rst
@@ -87,6 +87,9 @@ There are a few additional template variables available for the following specif
* ``pause_position``: Position reported by the printer via ``M114`` immediately before the print was paused. See
``last_position`` above for the structure to expect here.
+
+ **Please note:** This will not be available if you disable
+ "Log position on pause" under Settings > Serial > Advanced options!
* ``pause_temperature``: Last known temperature values when the print was paused. See ``last_temperature`` above
for the structure to expect here.
@@ -94,6 +97,9 @@ There are a few additional template variables available for the following specif
* ``cancel_position``: Position reported by the printer via ``M114`` immediately before the print was cancelled.
See ``last_position`` above for the structure to expect here.
+
+ **Please note:** This will not be available if you disable
+ "Log position on cancel" under Settings > Serial > Advanced options!
* ``cancel_temperature``: Last known temperature values when the print was cancelled. See ``last_temperature`` above
for the structure to expect here.
diff --git a/src/octoprint/server/api/settings.py b/src/octoprint/server/api/settings.py
index 65eefc9d..0e39ecb6 100644
--- a/src/octoprint/server/api/settings.py
+++ b/src/octoprint/server/api/settings.py
@@ -154,6 +154,8 @@ def getSettings():
"ignoreErrorsFromFirmware": s.getBoolean(["serial", "ignoreErrorsFromFirmware"]),
"disconnectOnErrors": s.getBoolean(["serial", "disconnectOnErrors"]),
"triggerOkForM29": s.getBoolean(["serial", "triggerOkForM29"]),
+ "logPositionOnPause": s.getBoolean(["serial", "logPositionOnPause"]),
+ "logPositionOnCancel": s.getBoolean(["serial", "logPositionOnCancel"]),
"supportResendsWithoutOk": s.getBoolean(["serial", "supportResendsWithoutOk"]),
"maxTimeoutsIdle": s.getInt(["serial", "maxCommunicationTimeouts", "idle"]),
"maxTimeoutsPrinting": s.getInt(["serial", "maxCommunicationTimeouts", "printing"]),
@@ -365,6 +367,8 @@ def _saveSettings(data):
if "disconnectOnErrors" in data["serial"]: s.setBoolean(["serial", "disconnectOnErrors"], data["serial"]["disconnectOnErrors"])
if "triggerOkForM29" in data["serial"]: s.setBoolean(["serial", "triggerOkForM29"], data["serial"]["triggerOkForM29"])
if "supportResendsWithoutOk" in data["serial"]: s.setBoolean(["serial", "supportResendsWithoutOk"], data["serial"]["supportResendsWithoutOk"])
+ if "logPositionOnPause" in data["serial"]: s.setBoolean(["serial", "logPositionOnPause"], data["serial"]["logPositionOnPause"])
+ if "logPositionOnCancel" in data["serial"]: s.setBoolean(["serial", "logPositionOnCancel"], data["serial"]["logPositionOnCancel"])
if "maxTimeoutsIdle" in data["serial"]: s.setInt(["serial", "maxCommunicationTimeouts", "idle"], data["serial"]["maxTimeoutsIdle"])
if "maxTimeoutsPrinting" in data["serial"]: s.setInt(["serial", "maxCommunicationTimeouts", "printing"], data["serial"]["maxTimeoutsPrinting"])
if "maxTimeoutsLong" in data["serial"]: s.setInt(["serial", "maxCommunicationTimeouts", "long"], data["serial"]["maxTimeoutsLong"])
diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py
index 269fa3de..75908a66 100644
--- a/src/octoprint/settings.py
+++ b/src/octoprint/settings.py
@@ -112,6 +112,8 @@ default_settings = {
"ignoreErrorsFromFirmware": False,
"logResends": True,
"supportResendsWithoutOk": False,
+ "logPositionOnPause": True,
+ "logPositionOnCancel": True,
# command specific flags
"triggerOkForM29": True
diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js
index 15a34ac6..16b2ceb0 100644
--- a/src/octoprint/static/js/app/viewmodels/settings.js
+++ b/src/octoprint/static/js/app/viewmodels/settings.js
@@ -173,6 +173,8 @@ $(function() {
self.serial_disconnectOnErrors = ko.observable(undefined);
self.serial_triggerOkForM29 = ko.observable(undefined);
self.serial_supportResendsWithoutOk = ko.observable(undefined);
+ self.serial_logPositionOnPause = ko.observable(undefined);
+ self.serial_logPositionOnCancel = ko.observable(undefined);
self.serial_maxTimeoutsIdle = ko.observable(undefined);
self.serial_maxTimeoutsPrinting = ko.observable(undefined);
self.serial_maxTimeoutsLong = ko.observable(undefined);
diff --git a/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 b/src/octoprint/templates/dialogs/settings/serialconnection.jinja2
index 528889eb..6860d50b 100644
--- a/src/octoprint/templates/dialogs/settings/serialconnection.jinja2
+++ b/src/octoprint/templates/dialogs/settings/serialconnection.jinja2
@@ -151,6 +151,18 @@
{{ _('Simulate an additional ok for resend requests') }}
+