What is the problem?
So I've had Octoprint running for a looooooong time without any issues. A few days ago, I moved my install from a Pi3 to a Pi4, using the backup and restore in Octoprint. Stupidly, I also moved my install from Python 2.7(?) to 3. (Should have done one at a time but I was on a roll).
Since then, whenever a print ends, it doesn't seem to want to run my "afterPrintDone" gcode script, which used to turn off the heat on the extruder, the print bed, raise the extruder, and move the print out of the way.
The script is in /home/pi/.octoprint/scripts/gcode/afterPrintDone
644, pi:pi
Contents:
M104 S0; Set Hot-end to 0C (off)
M140 S0; Set bed to 0C (off)
{% snippet 'end_of_print_routine' %}
The snippet in turns contains:
G91 ; relative
G1 Z20 F300 ; raise Z a bit
G90 ; absolute
G1 X0 Y200 F2000 ; plate forward head out of the way
M114 ; get last_position
{% if last_position.z < 100 %}
G1 Z100 F300 ; raise to 100 if not already there
{% endif %}
M84 ; disable motors
M106 S0 ;disable fan
What did you already try to solve it?
I initially thought it was a fluke, but since then, I've tried many prints and they all do the same... Just sit there when the last layer is printed, melting whatever area was printed last.
I have looked at the terminal output and matched it to the gcode printed, and it gets all the way to the last line of the gcode file as expected, but sadly, doesn't execute the few commands in my afterPrintDone file.
After looking at the logs further, it seems like this is the culprit... but it has worked for ages, so I'm not sure what the problem is...
2022-01-28 20:22:34,370 - octoprint.printer.standard.job - INFO - Print job done - origin: local, path: MK3S/x-carriage-with-back-and-cable-holder.gcode, owner: pcbroch
2022-01-28 20:22:34,405 - octoprint.settings - ERROR - Exception while trying to render script gcode:afterPrintDone
Traceback (most recent call last):
File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/settings.py", line 1989, in loadScript
script = template.render(**context)
File "/home/pi/oprint/lib/python3.7/site-packages/jinja2/environment.py", line 1090, in render
self.environment.handle_exception()
File "/home/pi/oprint/lib/python3.7/site-packages/jinja2/environment.py", line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File "/home/pi/oprint/lib/python3.7/site-packages/jinja2/_compat.py", line 28, in reraise
raise value.with_traceback(tb)
File "/home/pi/.octoprint/scripts/gcode/afterPrintDone", line 3, in top-level template code
{% snippet 'end_of_print_routine' %}
File "/home/pi/.octoprint/scripts/gcode/snippets/end_of_print_routine", line 7, in top-level template code
{% if last_position.z < 100 %}
TypeError: '<' not supported between instances of 'NoneType' and 'int'
Have you tried running in safe mode?
no
Did running in safe mode solve the problem?
n/a
Systeminfo Bundle
https://drive.google.com/file/d/1-GXPwUvQqqcazoTTPZyHKQqe4yY-58GF/view?usp=sharing
Additional information about your setup
OctoPrint version, OctoPi version, printer, firmware, browser, operating system, ... as much data as possible
Octoprint Version 1.7.3
Octopi Version 0.18.0, running on Raspberry Pi 4 Model B Rev 1.1
Printer is Prusa Mk2