Printer MQTT Client

Printer class for handling MQTT communication with the printer

bambulabs_api.PrinterMQTTClient.auto_home(self) bool

Auto home the printer

Returns:

success of the auto home command

Return type:

bool

bambulabs_api.PrinterMQTTClient.calibration(self, bed_levelling: bool = True, motor_noise_cancellation: bool = True, vibration_compensation: bool = True) bool

Start the full calibration process

Returns:

success of starting the full calibration process

Return type:

bool

bambulabs_api.PrinterMQTTClient.connect(self) None

Connects to the MQTT server asynchronously

bambulabs_api.PrinterMQTTClient.current_layer_num(self) int

Get the number of layers of the current/last print

Returns:

number of layers

Return type:

int

bambulabs_api.PrinterMQTTClient.dump(self) dict[Any, Any]

Dump the current state of the printer message

Returns:

The latest data recorded

Return type:

dict[Any, Any]

bambulabs_api.PrinterMQTTClient.gcode_file(self) str

Get current gcode file (current print details)

Returns:

current gcode_file name

Return type:

str

bambulabs_api.PrinterMQTTClient.gcode_file_prepare_percentage(self) int

Get the gcode file preparation percentage

Returns:

percentage

Return type:

int

bambulabs_api.PrinterMQTTClient.get_bed_temperature(self) float

Get the bed temperature

Returns:

bed temperature

Return type:

float

bambulabs_api.PrinterMQTTClient.get_bed_temperature_target(self) float

Get the bed temperature target

Returns:

bed temperature target

Return type:

float

bambulabs_api.PrinterMQTTClient.get_current_state(self) PrintStatus

Get the current printer state from stg_cur

Returns:

current_state

Return type:

PrintStatus

bambulabs_api.PrinterMQTTClient.get_file_name(self) str

Get the file name of the current/last print

Returns:

file name

Return type:

str

bambulabs_api.PrinterMQTTClient.get_last_print_percentage(self) int | str | None

Get the last print percentage

Returns:

The last print percentage

Return type:

int | str | None

bambulabs_api.PrinterMQTTClient.get_light_state(self) str

Get the printer light state

Returns:

led_mode

Return type:

str

bambulabs_api.PrinterMQTTClient.get_nozzle_temperature(self) float

Get the nozzle temperature

Returns:

nozzle temperature

Return type:

float

bambulabs_api.PrinterMQTTClient.get_nozzle_temperature_target(self) float

Get the nozzle temperature target

Returns:

nozzle temperature target

Return type:

float

bambulabs_api.PrinterMQTTClient.get_print_speed(self) int

Get the print speed

Returns:

print speed

Return type:

int

bambulabs_api.PrinterMQTTClient.get_printer_state(self) GcodeState

Get the printer state

Returns:

printer state

Return type:

PrintStatus

bambulabs_api.PrinterMQTTClient.get_remaining_time(self) int | str | None

Get the remaining time for the print

Returns:

The remaining time for the print

Return type:

int | str | None

bambulabs_api.PrinterMQTTClient.get_sequence_id(self)

Get the current sequence ID

Returns:

Get the current sequence ID

Return type:

int

bambulabs_api.PrinterMQTTClient.get_skipped_objects(self) list[int]

Get skipped Objects.

Args:

Returns:

if publish command is successful

Return type:

bool

bambulabs_api.PrinterMQTTClient.is_connected(self)

Check if the mqtt client is connected

Returns:

If the mqtt client is connected

Return type:

bool

bambulabs_api.PrinterMQTTClient.load_filament_spool(self) bool

Load the filament into the printer

Returns:

success of loading the filament

Return type:

bool

bambulabs_api.PrinterMQTTClient.loop_forever(self)

Loop client forever (synchonous, blocking call)

Returns:

error code of loop start

Return type:

MQTTErrorCode

bambulabs_api.PrinterMQTTClient.nozzle_diameter(self) float

Get the nozzle diameter currently registered to printer

Returns:

nozzle diameter

Return type:

float

bambulabs_api.PrinterMQTTClient.nozzle_type(self) NozzleType

Get the nozzle type currently registered to printer

Returns:

nozzle diameter

Return type:

NozzleType

bambulabs_api.PrinterMQTTClient.pause_print(self) bool

Pause the print

Returns:

print_status

Return type:

str

bambulabs_api.PrinterMQTTClient.print_error_code(self) int

Get current gcode file (current print details)

Returns:

error code (0 if normal)

Return type:

int

bambulabs_api.PrinterMQTTClient.process_ams(self)

Get the filament information from the AMS system

bambulabs_api.PrinterMQTTClient.pushall(self) bool

Force the printer to send a full update of the current state Warning: Pushall should be used sparingly - large numbers of updates can result in the printer lagging.

Returns:

success state of the pushall command

Return type:

bool

bambulabs_api.PrinterMQTTClient.resume_filament_action(self) bool

Resume the current filament action

Returns:

success of resuming the filament action

Return type:

bool

bambulabs_api.PrinterMQTTClient.resume_print(self) bool

Resume the print

Returns:

print_status

Return type:

str

bambulabs_api.PrinterMQTTClient.send_gcode(self, gcode_command: str | list[str]) bool

Send a G-code line command to the printer

Parameters:

gcode_command (str | list[str]) – G-code command(s) to send to the printer

bambulabs_api.PrinterMQTTClient.set_auto_step_recovery(self, auto_step_recovery: bool = True) bool

Set whether or not to set auto step recovery

Parameters:

auto_step_recovery (bool) – flag to set auto step recovery. Default True.

Returns:

success of the auto step recovery command command

Return type:

bool

bambulabs_api.PrinterMQTTClient.set_aux_fan_speed(self, speed: int | float) bool

Set the fan speed of the aux part fan

Parameters:

speed (int | float) – The speed to set the part fan

Returns:

success of setting the fan speed

Return type:

bool

bambulabs_api.PrinterMQTTClient.set_bed_height(self, height: int) bool

Set the absolute height of the bed (Z-axis). 0 is the bed at the nozzle tip and 256 is the bed at the bottom of the printer.

Parameters:

height (int) – height to set the bed to

Returns:

success of the bed height setting

Return type:

bool

bambulabs_api.PrinterMQTTClient.set_bed_temperature(self, temperature: int) bool

Set the bed temperature

Parameters:

temperature (int) – The temperature to set the bed to

Returns:

success of setting the bed temperature

Return type:

bool

bambulabs_api.PrinterMQTTClient.set_chamber_fan_speed(self, speed: int | float) bool

Set the fan speed of the chamber fan

Parameters:

speed (int | float) – The speed to set the part fan

Returns:

success of setting the fan speed

Return type:

bool

bambulabs_api.PrinterMQTTClient.set_nozzle_temperature(self, temperature: int) bool

Set the nozzle temperature

Parameters:

temperature (int) – temperature to set the nozzle to

Returns:

success of setting the nozzle temperature

Return type:

bool

bambulabs_api.PrinterMQTTClient.set_part_fan_speed(self, speed: int | float) bool

Set the fan speed of the part fan

Parameters:

speed (int | float) – The speed to set the part fan

Returns:

success of setting the fan speed

Return type:

bool

bambulabs_api.PrinterMQTTClient.set_print_speed_lvl(self, speed_lvl: int = 1) bool

Set the print speed

Parameters:

speed_lvl (int, optional) – Set the speed level of printer. Defaults to 1.

Returns:

success of setting the print speed

Return type:

bool

bambulabs_api.PrinterMQTTClient.set_printer_filament(self, filament_material: Filament, colour: str, ams_id: int = 255, tray_id: int = 254) bool

Set the printer filament manually fed into the printer

Parameters:
  • filament_material (Filament) – filament material to set.

  • colour (str) – colour of the filament.

  • ams_id (int) – ams id. Default to external filament spool: 255.

  • tray_id (int) – tray id. Default to external filament spool: 254.

Returns:

success of setting the printer filament

Return type:

bool

bambulabs_api.PrinterMQTTClient.skip_objects(self, obj_list: list[int]) bool

Skip Objects during printing.

Parameters:

obj_list (list[int]) – object list to skip objects.

Returns:

if publish command is successful

Return type:

bool

bambulabs_api.PrinterMQTTClient.start(self)

Starts the MQTT client

Returns:

error code of loop start

Return type:

MQTTErrorCode

bambulabs_api.PrinterMQTTClient.start_print_3mf(self, filename: str, plate_number: int, use_ams: bool = True, ams_mapping: list[int] = [0], skip_objects: list[int] | None = None) bool

Start the print

Parameters:
  • filename (str) – The name of the file to print

  • plate_number (int) – The plate number to print to

  • use_ams (bool, optional) – Use the AMS system. Defaults to True.

  • ams_mapping (list[int], optional) – The AMS mapping. Defaults to [0].

  • skip_objects (list[int] | None, optional) – List of gcode objects to skip. Defaults to [].

Returns:

print_status

Return type:

str

bambulabs_api.PrinterMQTTClient.stop(self)

Stops the MQTT client

bambulabs_api.PrinterMQTTClient.stop_print(self) bool

Stop the print

Returns:

print_status

Return type:

str

bambulabs_api.PrinterMQTTClient.subtask_name(self) str

Get current subtask name (current print details)

Returns:

current subtask name

Return type:

str

bambulabs_api.PrinterMQTTClient.total_layer_num(self) int

Get the total number of layers of the current/last print

Returns:

number of layers

Return type:

int

bambulabs_api.PrinterMQTTClient.turn_light_off(self) bool

Turn off the printer light

bambulabs_api.PrinterMQTTClient.turn_light_on(self) bool

Turn on the printer light

bambulabs_api.PrinterMQTTClient.unload_filament_spool(self) bool

Unload the filament from the printer

Returns:

success of unloading the filament

Return type:

bool

bambulabs_api.PrinterMQTTClient.vt_tray(self) FilamentTray

Get Filament Tray of the external spool.

Returns:

External Spool Filament Tray

Return type:

FilamentTray