diff --git a/klippy/extras/heaters.py b/klippy/extras/heaters.py index f8ed904ccb63..07d2b3c584f5 100644 --- a/klippy/extras/heaters.py +++ b/klippy/extras/heaters.py @@ -62,7 +62,9 @@ def __init__(self, config, sensor): self.mcu_pwm.setup_max_duration(MAX_HEAT_TIME) # Load additional modules self.printer.load_object(config, "verify_heater %s" % (short_name,)) - self.printer.load_object(config, "pid_calibrate") + # Register PID_CALIBRATE before gcode macros rename commands at connect + pid_calibrate = self.printer.load_object(config, "pid_calibrate") + pid_calibrate.register_heater(short_name) gcode = self.printer.lookup_object("gcode") gcode.register_mux_command("SET_HEATER_TEMPERATURE", "HEATER", short_name, self.cmd_SET_HEATER_TEMPERATURE, diff --git a/klippy/extras/pid_calibrate.py b/klippy/extras/pid_calibrate.py index 96495956171a..576c5d991005 100644 --- a/klippy/extras/pid_calibrate.py +++ b/klippy/extras/pid_calibrate.py @@ -9,17 +9,11 @@ class PIDCalibrate: def __init__(self, config): self.printer = config.get_printer() - self.printer.register_event_handler("klippy:connect", - self._handle_connect) - def _handle_connect(self): + def register_heater(self, heater_name): gcode = self.printer.lookup_object('gcode') - pheaters = self.printer.lookup_object('heaters') - all_heaters = pheaters.get_all_heaters() - for name in all_heaters: - short_name = name.split()[-1] - gcode.register_mux_command('PID_CALIBRATE', 'HEATER', short_name, - self.cmd_PID_CALIBRATE, - desc=self.cmd_PID_CALIBRATE_help) + gcode.register_mux_command('PID_CALIBRATE', 'HEATER', heater_name, + self.cmd_PID_CALIBRATE, + desc=self.cmd_PID_CALIBRATE_help) cmd_PID_CALIBRATE_help = "Run PID calibration test" def cmd_PID_CALIBRATE(self, gcmd): heater_name = gcmd.get('HEATER')