diff --git a/klippy/gcode.py b/klippy/gcode.py index 184f3a81..b7d737c6 100644 --- a/klippy/gcode.py +++ b/klippy/gcode.py @@ -389,18 +389,24 @@ class GCodeParser: eventtime = self.reactor.pause(eventtime + 1.) def set_temp(self, params, is_bed=False, wait=False): temp = self.get_float('S', params, 0.) + heater = None if is_bed: - heater_name = 'heater_bed' - else: - index = self.get_int('T', params, 0, minval=0) - heater_name = 'extruder%d' % (index,) + heater = self.printer.lookup_object('heater_bed', None) + elif 'T' in params: + index = self.get_int('T', params, minval=0) + extruder = self.printer.lookup_object('extruder%d' % (index,), None) + if extruder is not None: + heater = extruder.get_heater() + elif self.extruder is not None: + heater = self.extruder.get_heater() + if heater is None: + if temp > 0.: + self.respond_error("Heater not configured") + return print_time = self.toolhead.get_last_move_time() try: - heater = self.heaters.lookup_heater(heater_name) heater.set_temp(print_time, temp) except heater.error as e: - if not temp: - return raise error(str(e)) if wait and temp: self.bg_temp(heater)