Printer
Client Class for connecting to the Bambulabs 3D printer
- bambulabs_api.Printer.ams_hub(self) AMSHub
Get ams hub, all AMS’s hooked up to printer
- Returns:
ams information
- Return type:
AMSHub
- bambulabs_api.Printer.calibrate_printer(self, bed_level: bool = True, motor_noise_calibration: bool = True, vibration_compensation: bool = True) bool
Calibrate the printer.
- Parameters:
bed_level (bool, optional) – Whether to calibrate the bed level, by default True.
motor_noise_calibration (bool, optional) – Whether to calibrate the motor noise, by default True.
vibration_compensation (bool, optional) – Whether to calibrate the vibration compensation, by default True.
- Returns:
True if the printer is calibrated successfully.
- Return type:
bool
- bambulabs_api.Printer.camera_client_alive(self) bool
Check if the camera client is connected to the printer
- Returns:
Check if the camera loop is running.
- Return type:
bool
- bambulabs_api.Printer.camera_start(self)
Start the camera
- Returns:
If the camera successfully connected
- Return type:
bool
- bambulabs_api.Printer.camera_stop(self)
Stop the camera client
- bambulabs_api.Printer.connect(self)
Connect to the printer
- bambulabs_api.Printer.delete_file(self, file_path: str) str
Delete a file from the printer.
- Parameters:
file_path (str) – The path of the file to be deleted.
- Returns:
The path of the deleted file.
- Return type:
str
- bambulabs_api.Printer.disconnect(self)
Disconnect from the printer
- bambulabs_api.Printer.gcode(self, gcode: str | list[str]) bool
Send a gcode command to the printer.
- Parameters:
gcode (str | list[str]) – The gcode command or list of gcode commands to be sent.
- Returns:
True if the gcode command is sent successfully.
- Return type:
bool
- Raises:
ValueError – If the gcode command is invalid.
- bambulabs_api.Printer.gcode_file(self) str
Get current gcode file (current print details)
- Returns:
current gcode_file name
- Return type:
str
- bambulabs_api.Printer.get_bed_temperature(self) float | None
Get the bed temperature of the printer.
- Returns:
float – The bed temperature of the printer.
None if the printer is not printing.
- bambulabs_api.Printer.get_camera_frame(self) str
Get the camera frame of the printer.
- Returns:
Base64 encoded image of the camera frame.
- Return type:
str
- bambulabs_api.Printer.get_camera_image(self) Image
Get the camera frame of the printer.
- Returns:
Pillow Image of printer camera frame.
- Return type:
Image.Image
- bambulabs_api.Printer.get_current_state(self) PrintStatus
Get the current state of the printer.
- Returns:
The current state of the printer.
- Return type:
PrintStatus
- bambulabs_api.Printer.get_file_name(self) str
Get the name of the file being printed.
- Returns:
The name of the file being printed.
- Return type:
str
- bambulabs_api.Printer.get_light_state(self) str
Get the state of the printer light.
- Returns:
The state of the printer light.
- Return type:
str
- bambulabs_api.Printer.get_nozzle_temperature(self) float | None
Get the nozzle temperature of the printer.
- Returns:
float – The nozzle temperature of the printer.
None if the printer is not printing.
- bambulabs_api.Printer.get_percentage(self) int | str | None
Get the percentage of the print job completed.
- Returns:
int – Percentage of the print job completed.
str – “Unknown” if the percentage is unknown.
None if the printer is not printing.
- bambulabs_api.Printer.get_print_speed(self) int
Get the print speed of the printer.
- Returns:
The print speed of the printer.
- Return type:
int
- bambulabs_api.Printer.get_skipped_objects(self) list[int]
Get the current state of the printer.
- Returns:
The current state of the printer.
- Return type:
PrintStatus
- bambulabs_api.Printer.get_state(self) str
Get the state of the printer.
- Returns:
The state of the printer.
- Return type:
str
- bambulabs_api.Printer.get_time(self) int | str | None
Get the remaining time of the print job in seconds.
- Returns:
int – Remaining time of the print job in seconds.
str – “Unknown” if the remaining time is unknown.
None if the printer is not printing.
- bambulabs_api.Printer.home_printer(self) bool
Home the printer.
- Returns:
True if the printer is homed successfully.
- Return type:
bool
- bambulabs_api.Printer.load_filament_spool(self) bool
Load the filament spool to the printer.
- Returns:
True if the filament spool is loaded successfully.
- Return type:
bool
- bambulabs_api.Printer.move_z_axis(self, height: int) bool
Move the Z-axis of the printer.
- Parameters:
height (float) – The height for the bed.
- Returns:
True if the Z-axis is moved successfully.
- Return type:
bool
- bambulabs_api.Printer.mqtt_client_connected(self)
Get the mqtt client is connected to the printer.
- Returns:
Check if the mqtt client is connected.
- Return type:
bool
- bambulabs_api.Printer.mqtt_dump(self) dict[Any, Any]
Get the mqtt dump of the messages recorded from the printer
- Returns:
the json that is recorded from the printer.
- Return type:
dict[Any, Any]
- bambulabs_api.Printer.mqtt_start(self)
Start the camera
- Returns:
If the camera successfully connected
- Return type:
bool
- bambulabs_api.Printer.mqtt_stop(self)
Stop the mqtt client
- bambulabs_api.Printer.nozzle_diameter(self) float
Get the nozzle diameter currently registered to printer
- Returns:
nozzle diameter
- Return type:
float
- bambulabs_api.Printer.nozzle_type(self) NozzleType
Get the nozzle type currently registered to printer
- Returns:
nozzle diameter
- Return type:
NozzleType
- bambulabs_api.Printer.pause_print(self) bool
Pause the printer from printing.
- Returns:
True if the printer is paused successfully.
- Return type:
bool
- bambulabs_api.Printer.print_error_code(self) int
Get current gcode file (current print details)
- Returns:
error code (0 if normal)
- Return type:
int
- bambulabs_api.Printer.resume_print(self) bool
Resume the printer from printing.
- Returns:
True if the printer is resumed successfully.
- Return type:
bool
- bambulabs_api.Printer.retry_filament_action(self) bool
Retry the filament action.
- Returns:
True if the filament action is retried successfully.
- Return type:
bool
- bambulabs_api.Printer.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.Printer.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.Printer.set_bed_temperature(self, temperature: int) bool
Set the bed temperature of the printer.
- Parameters:
temperature (int) – The temperature to be set.
- Returns:
True if the temperature is set successfully.
- Return type:
bool
- bambulabs_api.Printer.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.Printer.set_filament_printer(self, color: str, filament: str | AMSFilamentSettings, ams_id: int = 255, tray_id: int = 254) bool
Set the filament of the printer.
- Parameters:
color (str) – The color of the filament.
filament (str | AMSFilamentSettings) – The filament to be set.
ams_id (int) – The index of the AMS, by default the external spool 255.
tray_id (int) – The index of the spool/tray in the ams, by default the external spool 254.
- Returns:
True if the filament is set successfully.
- Return type:
bool
- bambulabs_api.Printer.set_nozzle_temperature(self, temperature: int) bool
Set the nozzle temperature of the printer.
- Parameters:
temperature (int) – The temperature to be set.
- Returns:
True if the temperature is set successfully.
- Return type:
bool
- bambulabs_api.Printer.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.Printer.set_print_speed(self, speed_lvl: int) bool
Set the print speed of the printer.
- Parameters:
speed_lvl (int) – The speed level to be set. 0: Slowest 1: Slow 2: Fast 3: Fastest
- Returns:
True if the speed level is set successfully.
- Return type:
bool
- bambulabs_api.Printer.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.Printer.start_print(self, filename: str, plate_number: int, use_ams: bool = True, ams_mapping: list[int] = [0], skip_objects: list[int] | None = None) bool
Start printing a file.
- Parameters:
filename (str) – The name of the file to be printed.
plate_number (int) – The plate number of the file to be printed.
use_ams (bool, optional) – Whether to use the AMS system, by default True.
ams_mapping (list[int], optional) – The mapping of the filament trays to the plate numbers, by default [0].
None (skip_objects (list[int] |) – skip. Defaults to None.
optional) (List of gcode objects to) – skip. Defaults to None.
- Returns:
True if the file is printed successfully.
- Return type:
bool
- bambulabs_api.Printer.stop_print(self) bool
Stop the printer from printing.
- Returns:
True if the printer is stopped successfully.
- Return type:
bool
- bambulabs_api.Printer.subtask_name(self) str
Get current subtask name (current print details)
- Returns:
current subtask name
- Return type:
str
- bambulabs_api.Printer.turn_light_off(self) bool
Turn off the printer light.
- Returns:
True if the light is turned off successfully.
- Return type:
bool
- bambulabs_api.Printer.turn_light_on(self) bool
Turn on the printer light.
- Returns:
True if the light is turned on successfully.
- Return type:
bool
- bambulabs_api.Printer.unload_filament_spool(self) bool
Unload the filament spool from the printer.
- Returns:
True if the filament spool is unloaded successfully.
- Return type:
bool
- bambulabs_api.Printer.upload_file(self, file: BinaryIO, filename: str = 'ftp_upload.gcode') str
Upload a file to the printer.
- Parameters:
file (BinaryIO) – The file to be uploaded.
filename (str, optional) – The name of the file, by default “ftp_upload.gcode”.
- Returns:
The path of the uploaded file.
- Return type:
str
- bambulabs_api.Printer.vt_tray(self) FilamentTray
Get the filament information from the tray information.
- Returns:
filament information
- Return type:
Filament