This E-Stop code I pasted into the printer.cfg file is getting errors when I hit SAVE & RESTART.

I edited and trimmed the code down to this: [gcode_button e-stop] pin: rpi:gpio26 press_gcode: {% do call_method("printer.emergency_stop") %} release_gcode: {% if event.elapsed_time > 1.0 %} {% do call_method("machine.reboot") %} {% endif %} Resulting error: Error loading template 'gcode_button e-stop:press_gcode': jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'do'.
19 Replies
ctbjdm_04135
ctbjdm_041352mo ago
Just a guess, but try getting rid of the spaces in “gcode_button e-stop”
millenford - VC4 300h
The docs show a space in there when you add an optional name (e-stop in my case), but I tried it anyway and got a new error. lol thanks though!
TheTik
TheTik2mo ago
Take a look at this, maybe you're not importing something you should? https://stackoverflow.com/a/67045035
Stack Overflow
jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'do'
I'm not very familiar with Jinja and I'm having some issues using "do" statement in my template. I was reading other posts and I was trying to fix it but still no luck. Here is how partial
millenford - VC4 300h
The first few lines are fairly straightforward, but it's not evident to me how to integrate the rest. I will try though. Thanks.
CrashTestCharlie / VC4 400h
Isn't this supposed to be in moonraker.cfg and not printer.cfg?
miklschmidt
miklschmidt2mo ago
[gcode_button] is a klipper section. do is not a thing in klipper's jinja environment though. You're totally correct however that the jinja syntax used here is moonraker and not klipper.
CrashTestCharlie / VC4 400h
Ok, the snip helge posted had "# moonraker.conf" at the top of it, so I'm all turned around
millenford - VC4 300h
Yes it does have moonraker.conf at the top, but when Helge gave me the code he said to put it in printer.cfg. So should I put the code in moonraker.conf?
CrashTestCharlie / VC4 400h
Someone else got this working., might be worth some time to search some
millenford - VC4 300h
When I searched I found some discussions about just interrupting the power, using M112, or using this code or something similar. I didn't find a final solution that somebody implemented and it just worked. Then Mikl said the E-Stop functionality is part of the Klipper configuration. Then Helge pasted in some code, and here I am.
CrashTestCharlie / VC4 400h
Check https://discord.com/channels/582187371529764864/1223286652949106748/12660306623188215291266030662318821529 That might not point to the message Here, I am using a latching e-stop button so I did only the reset function. Since I am going 3v3 to GPIO I had to use the ~ in front of the pin to enable the built in pull down resistor. Also it looks like pin format has to be gpiochip0/gpio22 in my case to work. Going to do some more testing but so far so good. Here is my current moonraker.conf file
# Emergency Stop
[button estop]
type: gpio
pin: ~gpiochip0/gpio22
on_press:
# Executes immediately after a press is detected
{% do call_method("printer.emergency_stop") %}
# Emergency Stop
[button estop]
type: gpio
pin: ~gpiochip0/gpio22
on_press:
# Executes immediately after a press is detected
{% do call_method("printer.emergency_stop") %}
millenford - VC4 300h
My moonraker.conf has a bunch of IP addresses in it. Should the E-Stop code go above or below the IP stuff or does it matter?
CrashTestCharlie / VC4 400h
I don't know, but I'd put it after
millenford - VC4 300h
This is my moonraker file. Load the RatOS moonraker defaults [include RatOS/moonraker.conf] If you use a non standard ip range in your local network, you can specify it under trusted_clients here. [authorization] cors_domains: http://app.fluidd.xyz https://app.fluidd.xyz https://my.mainsail.xyz http://my.mainsail.xyz http://*.local http://*.lan trusted_clients: 127.0.0.1 10.0.0.0/8 127.0.0.0/8 169.254.0.0/16 172.16.0.0/12 192.168.0.0/16 FE80::/10 ::1/128 FD00::/8 Okay I'll try it.
TheTik
TheTik2mo ago
Try putting your code within a code block. Start and stop it with triple backtick (same button as tilde ~)
Want results from more Discord servers?
Add your server