Update/reload variables inside a macro

here it currently looks like the value of printer.heater_bed.temperature does not change inside one macro?

this is my macro:
M118 start bed-heat-time-test at {printer.heater_bed.temperature}C
TURN_OFF_HEATERS
M140 S55

M118 wait for 40C
TEMPERATURE_WAIT SENSOR=heater_bed MINIMUM=40 MAXIMUM=150
M118 bed reached {printer.heater_bed.temperature}C

M118 wait for 50
TEMPERATURE_WAIT SENSOR=heater_bed MINIMUM=50 MAXIMUM=150
M118 bed reached {printer.heater_bed.temperature}C

M118 end bed-heat-time-test at {printer.heater_bed.temperature}C
TURN_OFF_HEATERS

it worked correct, but the output was wrong - so the value is same all the time:
16:33:12 echo: start bed-heat-time-test at 38.9868671122C
16:33:12 echo: wait for 40C
16:33:30 echo: bed reached 38.9868671122C
16:33:30 echo: wait for 50
16:34:40 echo: bed reached 38.9868671122C
16:34:40 echo: end bed-heat-time-test at 38.9868671122C

how can I update / reload this values?

Macros are always evaluated in full before any of the commands are run. So, you’ll never see a variable update mid-macro - see: https://www.klipper3d.org/Command_Templates.html#the-printer-variable. The typical workaround for this is to use a second macro and call that from the original macro - that second macro is evaluated at the time it is first invoked.

-Kevin

okay, good to know now :slight_smile: