Variables for [save_z_home]

Basic Information:

Printer Model: Ender 5 Plus
MCU / Printerboard: BTT Mini e3 V3

Describe your issue:

Does anyone know if it is possible to take values from (exp. [stepper_x]…) and calculate a coordinate?
I tried the following:

[safe_z_home]

#{% set save_x = printer.configfile.settings[“stepper_x”].position_max %}
#{% set save_y = printer.configfile.settings[“stepper_y”].position_max %}

#{% set save_x = printer.configfile.config[“stepper_x”][“position_max”]|float / 2 %}
#{% set save_y = printer.configfile.config[“stepper_y”][“position_max”]|float / 2 %}

#{% set save_x = printer.configfile.settings[“stepper_x”][“position_max”]|float / 2 %}
#{% set save_y = printer.configfile.settings[“stepper_y”][“position_max”]|float / 2 %}

home_xy_position: 177.5,177.5 #{save_x},{save_y}
speed: 200
z_hop: 10
z_hop_speed: 100

(all commented out because actually i had to print something)

Thx in advance…

You need to use:

    {% set bed_x_max = printer.configfile.settings.stepper_x.position_max %}

[safe_z_home] is not the right place for such. Use [homing_override] for such.

Thanks for your Help.
But i think i dont really understand. Why cant (or shouldnt) i use it in this section?
I tried to use it in save_z_home and the setting of the variable now seems to work, but there seems to be an error when reading this value.
Error:
Unable to parse option ‘home_xy_position’ in section ‘safe_z_home’

I tried bed_x_max,bed_y_max and {bed_x_max},{bed_y_max}

Because [safe_z_home] is an internal definition that is not meant to extended via macros. For this flexibility [homing_override] offers the needed means.

means you CAN or SHOULD not?

I think i should tell you the Reason for this…
I often change the complete Toolhead. So everytime the Size and Positions do change.
I try to use only one variable at start of the printer.cfg for all the pendencies, so that everything will be calculated over this variable.
the savehome section was just the beginning.
Also i would use it in
[screws_tilt_adjust]
[bed_mesh]
[stepper_x] position_endstop: 338
[stepper_y] position_endstop: 330
and as i said
[safe_z_home]…

Cannot. Only settings that offer a gcode block can be amended with macros.

Ich sehe grade in deinem Profil das du aus D kommst…
Ich bin mal so frei die Sprache zu wechseln da mir das englisch recht schwer fällt.

Ok, also geht nicht weil geht nicht. Soweit ok…
Das mit dem Homing Override ist mir nicht ganz klar… was ist das und wie wende ich das an? Bzw könnte das u.U. eine Gesamtlösung werden?

Ok, ich habe mir das mit dem Override mal zu Gemüte geführt.
Das scheint nicht der Weg zu meinem Ziel zu sein.

Trotzdem erstmal vielen Dank für deine Hilfe.

Sorry, but this an English speaking forum and other readers shall have the chance to participate as well.

Effectively you can do a lot with macros and as far as my understanding of your concept goes, this should be possible but requires quite some macro understanding and work.

You might want to have a look at various existing macros and at the macro tutorial to get an idea how to work with variables etc.
See especially the Macros - Klipper category and the excellent macro tutorial Macro Creation Tutorial - #22 by Mard0
Also a lot of inspiration can be obtained from GitHub - zellneralex/klipper_config: This is the config of my Voron 2.4 350mm3 Serial:V2.660

homing_override is described here Configuration reference - Klipper documentation
In the gcode block you can customize homing with macros