UNPKG

@hiv3d/bambu-types

Version:

TypeScript types and utilities for Bambu Lab 3D printers including error codes, commands, and API types

1,589 lines (1,584 loc) 391 kB
import { z } from 'zod'; type StringNumber = `${number}`; type StringBoolean = `${boolean}`; type NumberRange<start extends number, end extends number, arr extends unknown[] = [], acc extends number = never> = arr["length"] extends end ? acc | start | end : NumberRange<start, end, [ ...arr, 1 ], arr[start] extends undefined ? acc : acc | arr["length"]>; type StringNumberRange<F extends number, T extends number> = `${NumberRange<F, T>}`; /** * Valid AMS control actions */ declare enum AMSControlAction { RESUME = "resume", RESET = "reset", PAUSE = "pause", DONE = "done" } type State = "pause" | "resume" | "stop"; type PrintMessageCommands = "push_status" | "ams_control" | State | "gcode_line" | "gcode_file" | "project_file"; type PrintMessageCommand = { command: PrintMessageCommands; param?: string; sequence_id: string; }; interface PrintMessage { print: PrintMessageCommand; } declare function isPrintMessage(data: any): data is PrintMessage; type PrinterStatus = "FINISH" | "FAILED" | "RUNNING" | "IDLE" | "PAUSE" | "PREPARE" | "SLICING"; /** * Every stage of a print. * Extracted from https://github.com/bambulab/BambuStudio/blob/master/src/slic3r/GUI/DeviceManager.cpp */ declare enum PrintStage { "PRINTING" = "Printing", "BED_LEVELING" = "Auto bed leveling", "HEATBED_PREHEATING" = "Heatbed preheating", "XY_MECH_MODE_SWEEP" = "Sweeping XY mech mode", "CHANGE_MATERIAL" = "Changing filament", "M400_PAUSE" = "M400 pause", "FILAMENT_RUNOUT_PAUSE" = "Paused due to filament runout", "HOTEND_HEATING" = "Heating hotend", "EXTRUDE_COMPENSATION_SCAN" = "Calibrating extrusion", "BED_SCAN" = "Scanning bed surface", "FIRST_LAYER_SCAN" = "Inspecting first layer", "BE_SURFACE_TYPT_IDENTIFICATION" = "Identifying build plate type", "SCANNER_EXTRINSIC_PARA_CALI" = "Calibrating Micro Lidar", "TOOLHEAD_HOMING" = "Homing toolhead", "NOZZLE_TIP_CLEANING" = "Cleaning nozzle tip", "EXTRUDER_TEMP_PROTECT_CALI" = "Checking extruder temperature", "USER_PAUSE" = "Printing was paused by the user", "TOOLHEAD_SHELL_OFF_PAUSE" = "Pause of front cover falling", "SCANNER_LASER_PARA_CALI" = "Calibrating the micro lida", "EXTRUDER_ABSOLUTE_FLOW_CALI" = "Calibrating extrusion flow", "HOTEND_TEMPERATURE_ERROR_PAUSE" = "Paused due to nozzle temperature malfunction", "HEATED_BED_TEMPERATURE_ERROR_PAUSE" = "Paused due to heat bed temperature malfunction", "FILAMENT_UNLOADING" = "Filament unloading", "SKIP_STEP_PAUSE" = "Skip step pause", "FILAMENT_LOADING" = "Filament loading", "MOTOR_NOISE_CALIBRATION" = "Motor noise calibration", "AMS_LOST_PAUSE" = "Paused due to AMS lost", "HEAT_BREAK_FAN_PAUSE" = "Paused due to low speed of the heat break fan", "CHAMBER_TEMPERATURE_CONTROL_ERROR_PAUSE" = "Paused due to chamber temperature control error", "CHAMBER_COOLING" = "Cooling chamber", "USER_INSERT_GCODE_PAUSE" = "Paused by the Gcode inserted by user", "MOTOR_NOISE_SHOWOFF" = "Motor noise showoff", "NOZZLE_FILAMENT_COVERED_DETECTED_PAUSE" = "Nozzle filament covered detected pause", "CUTTER_ERROR_PAUSE" = "Cutter error pause", "FIRST_LAYER_ERROR_PAUSE" = "First layer error pause", "NOZZLE_CLOG_PAUSE" = "Nozzle clog pause" } /** * Maps numeric stage_curr values to PrintStage enum values */ declare const stageCurrToStage: Record<number, PrintStage>; /** * Detailed information about a print stage */ interface PrintStageInfo { /** The current stage of printing */ stage: PrintStage; /** Progress percentage within the current stage (0-100) */ progress: number; /** Human-readable name of the stage */ name: string; /** Detailed description of what's happening in this stage */ description: string; /** Whether this stage can be controlled (paused/resumed/skipped) */ controllable: boolean; /** Whether this stage is critical for print success */ critical: boolean; /** Estimated time remaining in this stage (seconds) */ timeRemaining?: number; } declare const PrintStageDetails: Record<PrintStage, Partial<PrintStageInfo>>; /** * Speed levels of the printer. * * Extracted from https://github.com/bambulab/BambuStudio/blob/master/src/slic3r/GUI/DeviceManager.hpp#L73-L80 */ declare enum SpeedLevel { SILENT = "1", NORMAL = "2", SPORT = "3", LUDICROUS = "4" } declare enum FilamentType { PLA = "PLA", ABS = "ABS", TPU = "TPU", PC = "PC", ASA = "ASA", PA_CF = "PA-CF", PA6_CF = "PA6-CF", PET_CF = "PET-CF", PETG = "PETG", PETG_CF = "PETG-CF", PLA_AERO = "PLA-AERO", PLA_CF = "PLA-CF", PPA_CF = "PPA-CF", PPA_GF = "PPA-GF", PA = "PA", HIPS = "HIPS", PPS = "PPS", PPS_CF = "PPS-CF", PVA = "PVA", PLA_S = "PLA-S", PA_S = "PLA-S" } /** * An AMS tray (filament slot) instance. */ interface AMSTray$1 { /** * Unknown. Bambu Studio appears to do nothing with it. */ bed_temp: string; /** * Unknown. Bambu Studio appears to do nothing with it. */ bed_temp_type: string; /** * Unknown. Bambu Studio doesn't even check for it. * * Probably the temperature required for filament drying. */ drying_temp: string; /** * Probably the time required for filament drying. */ drying_time: string; /** * The ID of the tray. */ id: string; /** * The loaded filament's maximum nozzle temperature. */ nozzle_temp_max: StringNumber; /** * The loaded filament's minimum nozzle temperature. */ nozzle_temp_min: StringNumber; /** * The amount filament remaining in %, if enabled and an official Bambu filament is loaded. * * With non-official Bambu filament: * - 0: Tracking is disabled. * - -1: Tracking is enabled. */ remain: number; /** * The UID of the filament's NFC that was scanned. * * Uses: * - Check if filament's manufacturer is Bambu Lab: https://github.com/bambulab/BambuStudio/blob/master/src/slic3r/GUI/DeviceManager.cpp#L1090-L1101 * * TODO: Extract when received from printer / provide helper function to do so. */ tag_uid: string; /** * The color of the filament loaded in HEX color code. */ tray_color: string; /** * The diameter of the spool loaded. */ tray_diameter: 1.75; /** * Unknown. Bambu Studio appears to do nothing with it. */ tray_id_name: string; /** * The ID of the base config file for the filament. * * Uses: * - Associate the filament loaded with it's complete brand name. Use the `getFilamentConfig` function for getting the config. * * Config files can be found here: https://github.com/bambulab/BambuStudio/tree/master/resources/profiles/BBL/filament */ tray_info_idx: string; /** * No use cases are known. */ tray_sub_brands: ""; /** * The type of filament loaded into the tray (filament slot). */ tray_type: FilamentType; /** * Unknown. Bambu Studio appears to do nothing with it. */ tray_uuid: string; /** * Unknown. Bambu Studio appears to do nothing with it. */ tray_weight: string; /** * Information about the AI camera features (?) */ xcam_info: string; } /** * An AMS instance. */ interface AMS { humidity: string; id: string; temp: string; tray: [ AMSTray$1 | undefined, AMSTray$1 | undefined, AMSTray$1 | undefined, AMSTray$1 | undefined ]; } /** * Nozzle information from device.nozzle.info array * Source: BambuStudio DeviceCore/DevNozzleSystem.cpp ParseV2_0 */ interface DeviceNozzleInfo { /** Nozzle ID (0 for main/right, 1 for left on dual extruder) */ id: number; /** Time-related field (usage unknown) */ tm: number; /** Nozzle type identifier (e.g., "HX01", "HS01") */ type: string; /** Wear indicator */ wear: number; /** Nozzle diameter in mm (e.g., 0.4) */ diameter: number; } /** * Nozzle system information from device.nozzle * Source: BambuStudio DeviceCore/DevNozzleSystem.h */ interface DeviceNozzle { /** Array of installed nozzles (1-2 items for single/dual extruder) */ info: DeviceNozzleInfo[]; /** Bitmap indicating which nozzles exist */ exist: number; /** Nozzle state: 0=idle, 1=checking */ state: number; } /** * Extruder information from device.extruder.info array * Source: BambuStudio DeviceCore/DevExtruderSystem.cpp ParseV2_0 */ interface DeviceExtruderInfo { /** Extruder ID (0 for main/right, 1 for left on dual extruder) */ id: number; /** Current nozzle ID installed on this extruder */ hnow: number; /** Previous nozzle ID */ hpre: number; /** Target nozzle ID */ htar: number; /** * Info flags (packed bitfield): * - Bit 1: extruder has filament * - Bit 2: buffer has filament * - Bit 3: has nozzle installed */ info: number; /** * Current slot (packed bitfield): * - Bits 0-7: slot ID * - Bits 8-15: AMS ID * - 65535 (0xFFFF) means no slot/external spool */ snow: number; /** * Previous slot (packed bitfield): * - Bits 0-7: slot ID * - Bits 8-15: AMS ID * - 255 (0xFF) or 65535 (0xFFFF) means no slot/external spool */ spre: number; /** * Target slot (packed bitfield): * - Bits 0-7: slot ID * - Bits 8-15: AMS ID * - 255 (0xFF) or 65535 (0xFFFF) means no slot/external spool */ star: number; /** * Status flags (packed bitfield): * - Bits 0-15: AMS status * - Bits 16-31: RFID status */ stat: number; /** * Temperature (packed bitfield): * - Bits 0-15: current temperature in Celsius * - Bits 16-31: target temperature in Celsius */ temp: number; /** Array of filament backup slot indices */ filam_bak: number[]; } /** * Extruder system information from device.extruder * Source: BambuStudio DeviceCore/DevExtruderSystem.h */ interface DeviceExtruder { /** Array of extruder information (1-2 items for single/dual extruder) */ info: DeviceExtruderInfo[]; /** * Extruder system state (packed bitfield): * - Bits 0-3: total extruder count * - Bits 4-7: current extruder ID * - Bits 8-11: target extruder ID * - Bits 12-14: switch state (0=idle, 1=busy, 2=switching, 3=failed) * - Bits 15-18: loading extruder ID * - Bit 19: busy for loading */ state: number; } /** * External spool (tray). This has unused values due to being a copy of the AMS trays. * Source: BambuStudio DeviceManager.cpp:3647-3676 */ interface ExternalTray extends AMSTray$1 { /** * Unknown. Bambu Studio appears to do nothing with it. */ cols: StringNumber[]; /** * The ID of the tray. * - "254": VIRTUAL_TRAY_DEPUTY_ID (second extruder external spool) * - "255": VIRTUAL_TRAY_MAIN_ID (main extruder external spool) */ id: "254" | "255"; /** * The loaded filament's "k" value (manually set in Bambu Studio). */ k: number; /** * The loaded filament's "n" value (manually set in Bambu Studio). */ n: number; } /** * Status of the AMS' RFID reader. */ declare enum AmsRFIDStatus { IDLE = 0, READING = 1, GCODE_TRANS = 2, GCODE_RUNNING = 3, ASSISTANT = 4, SWITCH_FILAMENT = 5, HAS_FILAMENT = 6 } /** * Bambu Lab's proprietary Health Management System (HMS). * * More info: https://wiki.bambulab.com/en/x1/troubleshooting/intro-hms * * All error codes: https://wiki.bambulab.com/en/hms/home */ interface HMS { attr: number; code: number; } /** * Interior lighting related status instance. */ interface LightReport { node: "chamber_light" | "work_light"; mode: "on" | "off" | "flashing"; } /** * The possible progress states of a firmware upgrade. * * Extracted from https://github.com/bambulab/BambuStudio/blob/master/src/slic3r/GUI/DeviceManager.cpp#L3481-L3494 */ declare enum UpgradeStatusProgressState { DOWNLOADING = "DOWNLOADING", UPGRADE_REQUEST = "UPGRADE_REQUEST", PRE_FLASH_START = "PRE_FLASH_START", PRE_FLASH_SUCCESS = "PRE_FLASH_SUCCESS" } /** * The possible finish states of a firmware upgrade. * * Extracted from https://github.com/bambulab/BambuStudio/blob/master/src/slic3r/GUI/DeviceManager.cpp#L3481-L3494 */ declare enum UpgradeStatusFinishState { UPGRADE_SUCCESS = "UPGRADE_SUCCESS", DOWNLOAD_FAIL = "DOWNLOAD_FAIL", FLASH_FAIL = "FLASH_FAIL", PRE_FLASH_FAIL = "PRE_FLASH_FAIL", UPGRADE_FAIL = "UPGRADE_FAIL" } /** * Error codes thrown by the upgrade. */ declare enum UpgradeErrorCode { UpgradeNoError = 0, UpgradeDownloadFailed = 1, UpgradeVerifyFailed = 2, UpgradeFlashFailed = 3, UpgradePrinting = 4 } /** * The possible states the printer's screen will display. */ declare enum UpgradeDisplayState { UNAVAILABLE = 0, IDLE = 1, UPGRADING = 2, UPGRADE_FINISHED = 3 } /** * Contains basic data about a filament, which is then extended by the final product. */ interface BaseFilamentConfig { type: "filament"; name: string; inherits: string; from: string; instantiation: StringBoolean; fan_cooling_layer_time: [StringNumber]; filament_max_volumetric_speed: [StringNumber]; filament_density: [StringNumber]; filament_cost: [StringNumber]; cool_plate_temp: [StringNumber]; eng_plate_temp: [StringNumber]; hot_plate_temp: [StringNumber]; textured_plate_temp: [StringNumber]; cool_plate_temp_initial_layer: [StringNumber]; eng_plate_temp_initial_layer: [StringNumber]; hot_plate_temp_initial_layer: [StringNumber]; textured_plate_temp_initial_layer: [StringNumber]; nozzle_temperature_initial_layer: [StringNumber]; reduce_fan_stop_start_freq: [StringNumber]; fan_min_speed: [StringNumber]; overhang_fan_threshold: [StringNumber]; close_fan_the_first_x_layers: [StringNumber]; nozzle_temperature: [StringNumber]; temperature_vitrification: [StringNumber]; nozzle_temperature_range_low: [StringNumber]; nozzle_temperature_range_high: [StringNumber]; slow_down_min_speed: [StringNumber]; slow_down_layer_time: [StringNumber]; additional_cooling_fan_speed: [StringNumber]; filament_start_gcode: [string]; } /** * The config files ending with @base */ interface ExtendedFilamentConfig extends Partial<BaseFilamentConfig> { type: "filament"; name: string; inherits: string; from: string; filament_id: string; setting_id: string; } /** * The final filament config data. Contains the inherited and @base file data. */ interface FilamentConfig { type: "filament"; name: string; inherits: string; from: string; filament_id: string; instantiation: StringBoolean; filament_cost: [StringNumber]; filament_vendor: [string]; nozzle_temp_min: string; nozzle_temp_max: string; bed_temp: string; bed_temp_type: string; } interface FilamentConfigs { [key: string]: FilamentConfig; } declare const filamentConfigs: FilamentConfigs; /** * Reports all sensors and statuses of the printer. */ interface PushAllResponse extends PrintMessageCommand { /** * Status of all connected AMSes. */ ams: { ams: [] | [AMS] | [AMS, AMS] | [AMS, AMS, AMS] | [AMS, AMS, AMS, AMS]; /** * Unknown. * * Probably used for checking for new AMSes. */ ams_exist_bits: StringNumber; /** * Unknown. * * Could possibly be related to storing whether the filament's data has been read from the AMSes. */ insert_flag: boolean; /** * Exact definition is unknown, but it appears to be used for checking if all filaments have been read since startup or not. */ power_on_flag: boolean; /** * Unknown. * * Probably used for checking for new AMSes. */ tray_exist_bits: StringNumber; /** * Unknown. * * Probably used for checking for new AMSes. */ tray_is_bbl_bits: StringNumber; /** * Current tray selected by all AMSes. * - 254: external spool (vt_tray) * - otherwise: ((ams_id * 4) + tray_id) for current tray * * @example Ams 2 tray 2 would be: (1*4)+1 = 5. */ tray_now: StringNumber; /** * Unknown. * * Probably used for checking which filament slots (trays) have already been read. */ tray_read_done_bits: StringNumber; /** * Unknown. * * Probably used for signalling which filament slots (trays) are currently being read. */ tray_reading_bits: StringNumber; /** * Unknown. Bambu Studio appears to do nothing with it. */ tray_tar: StringNumber; /** * Unknown. * * Could possibly be related to the AMS UI on the X1 series and in Bambu Studio. */ version: number; }; /** * The RFID reader status of the connected AMSes. */ ams_rfid_status: AmsRFIDStatus; /** * The AMS status. * * How to extract it: https://github.com/bambulab/BambuStudio/blob/f96b6cd433cf925e9759260925cd2142abf298ef/src/slic3r/GUI/DeviceManager.cpp#L736-L759 * * TODO: Extract when received from printer / provide helper function to do so. */ ams_status: number; /** * The target temperature of the printing bed in Celsius. */ bed_target_temper: number; /** * The temperature of the printing bed in Celsius. */ bed_temper: number; /** * Speed of the auxiliary fan in %. */ big_fan1_speed: StringNumberRange<0, 100>; /** * Speed of the chamber fan in %. */ big_fan2_speed: StringNumberRange<0, 100>; /** * Interior chamber temperature. */ chamber_temper: number; /** * The interior chamber's target temperature. * * Exists on the X1 series but only used on the X1E. */ ctt: number; /** * `chamber_temper` doesn't make sense on P1 series (due to it not being enclosed * by default) hence the `frame_temper` property. * * Even though `chamber_temper` exists, there is no physical sensor for it, but it is still included for some reason. * * The value of `chamber_temper` on the P1 series is a placeholder. */ frame_temper: number; /** * The command the response corresponds to. */ command: "push_status"; /** * Speed of the part cooling fan in %. */ cooling_fan_speed: StringNumberRange<0, 100>; /** * Unknown. Bambu Studio doesn't even check for it. */ fail_reason: StringNumber; /** * Array of filament backup groups. Each number is a bitmap where each bit represents * an AMS slot that can be used as backup for that filament group. Compatible slots * (same filament type and color) are grouped together. * * For example, if slots 0 and 4 contain the same filament type and color, * they would be in the same group with bitmap value 17 (binary: 0001 0001). */ filam_bak: number[]; /** * Contains the current speed of all the fans * * How to extract it: https://github.com/bambulab/BambuStudio/blob/master/src/slic3r/GUI/DeviceManager.cpp#L3273-L3279 * * TODO: Extract when received from printer / provide helper function to do so. */ fan_gear: number; /** * Something related to the firmware upgrades. */ force_upgrade: boolean; /** * Name of the GCode file that is currently printing. * * In most cases it's in the format "/plate_#.gcode", unless printing a * gcode file directly (bbl.gcode, or calibration gcodes) instead of a 3mf. */ gcode_file: string; /** * % of GCode prepared (sliced?) */ gcode_file_prepare_percent: StringNumberRange<0, 100>; /** * Epoch time when the print started. */ gcode_start_time: StringNumber; /** * The current status of the printer. */ gcode_state: PrinterStatus; /** * Fan speed in % * * Heat break fan: The smaller fan on the hotend itself */ heatbreak_fan_speed: StringNumberRange<0, 100>; /** * Bambu Lab's proprietary Health Management System (HMS) * * More info: https://wiki.bambulab.com/en/x1/troubleshooting/intro-hms * * All error codes: https://wiki.bambulab.com/en/hms/home */ hms: HMS[]; /** * This single property houses a lot of data regarding the printer. * There's currently no documentation for it except Bambu Studio's source code: * * - Check if axes are homed: https://github.com/bambulab/BambuStudio/blob/master/src/slic3r/GUI/DeviceManager.cpp#L1255-L1269 * - Check if printer is using 220V: https://github.com/bambulab/BambuStudio/blob/master/src/slic3r/GUI/DeviceManager.cpp#L1346-L1351 * - Check if camera is currently recording: https://github.com/bambulab/BambuStudio/blob/master/src/slic3r/GUI/DeviceManager.cpp#L1353 * - Check if AI camera detected filament entanglement: https://github.com/bambulab/BambuStudio/blob/master/src/slic3r/GUI/DeviceManager.cpp#L1368 * - Check if motor noise cancellation has been calibrated: https://github.com/bambulab/BambuStudio/blob/master/src/slic3r/GUI/DeviceManager.cpp#L1376-L1378 * - Check if the current machine is a P1P and has the enclosure enabled: https://github.com/bambulab/BambuStudio/blob/master/src/slic3r/GUI/DeviceManager.cpp#L1380-L1387 * - Check current SD card state (has a lot more info than the sdcard property): https://github.com/bambulab/BambuStudio/blob/master/src/slic3r/GUI/DeviceManager.cpp#L1389 * - Check if printer is using wired network (ethernet; X1E exclusive): https://github.com/bambulab/BambuStudio/blob/master/src/slic3r/GUI/DeviceManager.cpp#L1391 */ home_flag: number; hw_switch_state: number; /** * The printer's onboard camera. */ ipcam: { /** * The IP and path to the LAN liveview, otherwise disabled. * @version X1 series exclusive */ liveview: string | "disable"; /** * Unknown. Bambu Studio doesn't even check for it. */ tukt_server: string; /** * 0: Doesn't have camera * 1: Has camera */ ipcam_dev: StringNumberRange<0, 1>; /** * Whether recording while printing is enabled. */ ipcam_record: "enable" | "disable"; /** * Unknown. Bambu Studio doesn't even check for it. */ mode_bits: 3; /** * The camera's resolution * * The value is known to be very weird on the A1 series. */ resolution: "720p" | "1080p" | string; /** * Whether creating a timelapse while printing is enabled. */ timelapse: "enable" | "disable"; }; /** * Current layer number while printing. */ layer_num: number; /** * Probably to differentiate between in-house prototypes and production machines. */ lifecycle: "product" | "engineer"; /** * Internal light states */ lights_report: LightReport[]; /** * Unknown. Bambu Studio doesn't even check for it. */ maintain: number; /** * % of print done */ mc_percent: NumberRange<0, 100>; /** * Unknown. Bambu Studio appears to do nothing with it. * * Perhaps the current GCode line while printing? */ mc_print_line_number: StringNumber; /** * Unknown. Bambu Studio appears to do nothing with it. */ mc_print_error_code: "0" | StringNumber; /** * Something to do with signalling if calibration is done according to source code * * https://github.com/bambulab/BambuStudio/blob/master/src/slic3r/GUI/DeviceManager.cpp#L1331-L1342 */ mc_print_stage: StringNumberRange<1, 3>; /** * Unknown. Bambu Studio appears to do nothing with it. */ mc_print_sub_stage: number; /** * Remaining time from print. */ mc_remaining_time: number; /** * Probably to differentiate between in-house prototypes and production machines */ mess_production_state: "active" | "inactive"; /** * - 0: Full (pushAll) message * - 1: Partial (pushStatus) "difference" message (only changed properties are sent) * * @deprecated Unavailable on the X1 series in LAN mode. * * You can instead use isPushAllCommand or isPushStatusCommand from /responses or create a new PushAllCommand and PushStatus command from /commands and use their ownsResponse method for consistency. */ msg: NumberRange<0, 1>; /** * The target temperature of the nozzle in Celsius. */ nozzle_target_temper: number; /** * The temperature of the nozzle in Celsius. */ nozzle_temper: number; /** * Signals the status of some components of the printer and/or accessories. */ online: { /** * Unknown. */ ahb: boolean; /** * The RFID reader. */ rfid: boolean; /** * Unknown. */ version: number; }; /** * Unknown. Some error code standard which isn't defined in Bambu Studio. * * These codes can be cleared using `system.clean_print_error` command. */ print_error: number; /** * Unknown. Bambu Studio doesn't even check for it. */ print_gcode_action: number; /** * Unknown. Bambu Studio doesn't even check for it. */ print_real_action: number; /** * Where the print originates from. */ print_type: "cloud" | "system" | "local" | "idle"; /** * Unknown. Something related to what's being printed. */ profile_id: StringNumber; /** * Unknown. Something related to what's being printed. */ project_id: StringNumber; /** * Unknown. Something related to a print queue. (?) */ queue_est: number; /** * Unknown. Something related to a print queue. (?) */ queue_number: number; /** * Unknown. Something related to a print queue. (?) */ queue_sts: number; /** * Unknown. Something related to a print queue. (?) */ queue_total: number; /** * Objects that have been skipped by the printer while printing, */ s_obj: unknown[]; /** * Whether the SD card is inserted. */ sdcard: boolean; /** * Related to general MQTT commands on all Bambu Lab printers. Incremented by one each response/request. */ sequence_id: StringNumber; /** * The current speed level. */ spd_lvl: SpeedLevel; /** * The current speed level in %. */ spd_mag: NumberRange<50, 166>; /** * An x (unknown) amount of previous stages. */ stg: PrintStage[]; /** * The current print stage. */ stg_cur: PrintStage; /** * Main purpose is unknown. * - 0: printing from SD card */ subtask_id: StringNumber; /** * The name of the calibration gcode (without file extension), or the project file name (.3mf - with file extension) */ subtask_name: string; /** * Unknown. Bambu Studio appears to do nothing with it. */ task_id: StringNumber; /** * Total layer number of the current job. */ total_layer_num: number; /** * Firmware upgrade status data of the printer. */ upgrade_state: { /** * Unknown. * * Some component's new version number. */ ahb_new_version_number: string; /** * The new version number of the AMS(es). */ ams_new_version_number: string; /** * Unknown. Bambu Studio appears to do nothing with it. */ consistency_request: boolean; /** * What the display should say in the process. */ dis_state: UpgradeDisplayState; /** * Error codes thrown by the upgrade. */ err_code: UpgradeErrorCode; /** * Unknown. Bambu Studio appears to do nothing with it. * * Probably has something to do with an update the user can't deny. (for ex.: security vulnerabilities) */ force_upgrade: boolean; /** * Unknown. Bambu Studio appears to do nothing with it. */ message: string; /** * Unknown. Bambu Studio appears to do nothing with it. */ module: string; /** * Unknown. Bambu Studio appears to do nothing with it. */ new_ver_list: string; /** * Unknown. Bambu Studio appears to do nothing with it. */ new_version_state: number; /** * Unknown. Bambu Studio appears to do nothing with it. */ ota_new_version_number: string; /** * The progress of the update in %. */ progress: StringNumberRange<0, 100>; /** * Incremented by one every time a new status is returned. */ sequence_id: number; /** * The progress / finish states of the upgrade. */ status: UpgradeStatusProgressState & UpgradeStatusFinishState; }; /** * Print file download status data. */ upload: { /** * Downloaded file size (?) */ file_size: number; /** * Total file size (?) */ finish_size: number; /** * Unknown. Bambu Studio doesn't even check for it. */ message: string; /** * Unknown. Bambu Studio doesn't even check for it. */ oss_url: string; /** * The progress of the file download in %. */ progress: StringNumberRange<0, 100>; /** * Incremented by one every time a new status is returned. */ sequence_id: StringNumber; /** * Download speed in unknown units. */ speed: number; /** * Unknown. Bambu Studio doesn't even check for it. */ status: "idle" | string; /** * Unknown. Bambu Studio doesn't even check for it. */ task_id: string; /** * Time remaining until download completes in unknown units. */ time_remaining: number; /** * Unknown. Bambu Studio doesn't even check for it. * * Probably some kind of error code. */ trouble_id: string; }; /** * External spool (tray). This has unused values due to being a copy of the AMS trays. * @deprecated Legacy field for backward compatibility. Use vir_slot array instead. */ vt_tray: ExternalTray; /** * Virtual tray slots for external spools (newer format supporting dual extruders). * Array can contain 1-2 external trays: * - Index 0: Main extruder external spool (id: "255") * - Index 1: Second extruder external spool (id: "254") * * Falls back to vt_tray field if not present (older firmware). * Source: BambuStudio DeviceManager.cpp:3647-3676 */ vir_slot?: [ExternalTray] | [ExternalTray, ExternalTray]; /** * The signal strength of the Wi-Fi signal which the printer is connected to in dBm. */ wifi_signal: `-${number}dBm`; /** * Device hardware information (newer firmware format) * Contains detailed nozzle and extruder information * Source: BambuStudio DeviceManager.cpp device parsing */ device?: { /** Nozzle system information (optional, present in newer firmware) */ nozzle?: DeviceNozzle; /** Extruder system information (optional, present in newer firmware) */ extruder?: DeviceExtruder; }; /** * AI-related features of the printer's camera. */ xcam: { /** * Whether skipping parts setting is enabled. */ allow_skip_parts: boolean; /** * Whether the printer should detect the correct orientation and type of the buildplate. */ buildplate_marker_detector: boolean; /** * Whether the first layer inspection is enabled for the printer. */ first_layer_inspector: boolean; /** * Whether the printer is allowed to stop the print in the event it detects an abnormality. */ print_halt: boolean; /** * The sensitivity for the spaghetti detector, first layer inspection, etc. */ halt_print_sensitivity: "low" | "medium" | "high"; /** * Whether print monitoring is enabled. */ printing_monitor: boolean; /** * Whether the spaghetti detector is enabled. */ spaghetti_detector: boolean; }; /** * AI-related features' status. */ xcam_status: StringNumber; } /** * Retrieves the FilamentConfig object associated with the specified ID. * @param id - The ID of the FilamentConfig to retrieve. * @returns The FilamentConfig object if found, otherwise undefined. */ declare function getFilamentConfig(id: string): FilamentConfig | null; /** * Converts a numeric stage_curr value to its corresponding PrintStage enum value * @param stageCurr - The numeric stage value (0-35) * @returns The corresponding PrintStage enum value, or undefined if not found */ declare function getStageFromCurr(stageCurr: number): PrintStage | undefined; /** * Converts an array of numeric stage values to an array of PrintStage enum values * @param stages - Array of numeric stage values (0-35) * @returns Array of corresponding PrintStage enum values, filtering out any undefined stages */ declare function getStagesFromArray(stages: number[]): PrintStage[]; /** * Represents a stage with its details and completion status */ interface EnrichedStageInfo extends Partial<PrintStageInfo> { stage: PrintStage; description: string; completed: boolean; current: boolean; } /** * Creates an enriched array of stage information with completion status * @param currentStage - The current stage number (stage_curr) * @param stageHistory - Array of previous stage numbers (stg) * @returns Array of stages with their details and completion status * * @example * const stages = getEnrichedStages(4, [2, 13, 24, 4]); * // Returns array of EnrichedStageInfo with: * // - HEATBED_PREHEATING (completed) * // - TOOLHEAD_HOMING (completed) * // - FILAMENT_LOADING (completed) * // - CHANGE_MATERIAL (current, not completed) */ declare function getEnrichedStages(currentStage: number, stageHistory: number[]): EnrichedStageInfo[]; declare function isPushAllCommand(data: PrintMessageCommand): data is PushAllResponse; /** * Pause category enum for user-friendly grouping of pause reasons. * Matches @hiv3d/types PauseCategory but duplicated here to avoid circular deps. */ declare enum PauseCategory { FILAMENT_RUNOUT = "filament_runout", USER_PAUSE = "user_pause", GCODE_PAUSE = "gcode_pause", ERROR = "error", DEFAULT = "default" } /** * Maps numeric stg_cur values to user-friendly pause categories. * Used for selecting the appropriate light flash pattern. * * Category mappings: * - FILAMENT_RUNOUT: stage 6 (FILAMENT_RUNOUT_PAUSE) * - USER_PAUSE: stage 16 (USER_PAUSE) * - GCODE_PAUSE: stages 5 (M400_PAUSE), 30 (USER_INSERT_GCODE_PAUSE) * - ERROR: stages 20-21 (temperature errors), 26-28 (AMS/fan/chamber errors), * 32-35 (cutter/filament/first-layer/clog errors) * - DEFAULT: all other stages * * @param stgCur - The numeric stage value from printer data * @returns The corresponding PauseCategory */ declare function stageToPauseCategory(stgCur: number): PauseCategory; type BambuClientPrinterStatus = "FINISH" | "FAILED" | "RUNNING" | "IDLE" | "PAUSE" | "PREPARE" | "SLICING" | "OFFLINE"; declare enum PrinterModelNamesShort { X1C = "X1C", X1 = "X1", X1E = "X1E", P1P = "P1P", P1S = "P1S", A1 = "A1", A1M = "A1M", H2D = "H2D", H2S = "H2S" } declare enum PrinterModelIDs { X1C = "BL-P001", X1 = "BL-P002", P1P = "C11", P1S = "C12", X1E = "C13", A1 = "N2S", A1M = "N1", H2D = "O1D", H2S = "O1S" } /** * Mapping of printer model IDs to their friendly model names * This includes: * - Official model IDs from machine profiles (BL-P001, C11, etc.) * - Full names (from project_settings.config) */ declare const PRINTER_MODEL_MAP: Record<PrinterModelIDs, string>; /** * Mapping of printer model IDs to their full names * This includes: * - Official model IDs from machine profiles (BL-P001, C11, etc.) * - Full names (from project_settings.config) */ declare const PRINTER_MODEL_LONG_NAME_MAP: Record<PrinterModelIDs, PrinterLongNames>; declare const CONNECT_RETURN_CODE_DESC: { 0: string; 1: string; 2: string; 3: string; 4: string; 5: string; }; type PrinterLongNames = "Bambu Lab X1C" | "Bambu Lab X1" | "Bambu Lab P1S" | "Bambu Lab P1P" | "Bambu Lab A1" | "Bambu Lab A1 Mini" | "Bambu Lab H2D" | "Bambu Lab H2S"; type AMS_PREFIX = "A" | "B" | "C" | "D"; declare const AMS_LETTER_MAP: Record<string, AMS_PREFIX>; declare const commandSchemas: { updateLight: z.ZodObject<{ light: z.ZodEnum<["chamber_light", "work_light"]>; mode: z.ZodEnum<["on", "off", "flashing"]>; loopOptions: z.ZodOptional<z.ZodObject<{ onTime: z.ZodOptional<z.ZodNumber>; offTime: z.ZodOptional<z.ZodNumber>; loops: z.ZodOptional<z.ZodNumber>; interval: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { onTime?: number | undefined; offTime?: number | undefined; loops?: number | undefined; interval?: number | undefined; }, { onTime?: number | undefined; offTime?: number | undefined; loops?: number | undefined; interval?: number | undefined; }>>; }, "strip", z.ZodTypeAny, { light: "chamber_light" | "work_light"; mode: "on" | "off" | "flashing"; loopOptions?: { onTime?: number | undefined; offTime?: number | undefined; loops?: number | undefined; interval?: number | undefined; } | undefined; }, { light: "chamber_light" | "work_light"; mode: "on" | "off" | "flashing"; loopOptions?: { onTime?: number | undefined; offTime?: number | undefined; loops?: number | undefined; interval?: number | undefined; } | undefined; }>; updateFan: z.ZodObject<{ fan: z.ZodEffects<z.ZodEnum<["1", "2", "3"]>, number, "1" | "2" | "3">; speed: z.ZodNumber; }, "strip", z.ZodTypeAny, { speed: number; fan: number; }, { speed: number; fan: "1" | "2" | "3"; }>; updateSpeed: z.ZodObject<{ speed: z.ZodEnum<["1", "2", "3", "4"]>; }, "strip", z.ZodTypeAny, { speed: "1" | "2" | "3" | "4"; }, { speed: "1" | "2" | "3" | "4"; }>; updateTemp: z.ZodObject<{ part: z.ZodEnum<["bed", "nozzle", "chamber"]>; temperature: z.ZodNumber; }, "strip", z.ZodTypeAny, { part: "bed" | "nozzle" | "chamber"; temperature: number; }, { part: "bed" | "nozzle" | "chamber"; temperature: number; }>; updateState: z.ZodObject<{ state: z.ZodEnum<["pause", "resume", "stop"]>; }, "strip", z.ZodTypeAny, { state: "resume" | "pause" | "stop"; }, { state: "resume" | "pause" | "stop"; }>; gcode: z.ZodObject<{ gcodes: z.ZodArray<z.ZodString, "many">; }, "strip", z.ZodTypeAny, { gcodes: string[]; }, { gcodes: string[]; }>; resume: z.ZodObject<{ cleanPrintError: z.ZodOptional<z.ZodBoolean>; printError: z.ZodOptional<z.ZodNumber>; subtaskId: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { subtaskId?: string | undefined; printError?: number | undefined; cleanPrintError?: boolean | undefined; }, { subtaskId?: string | undefined; printError?: number | undefined; cleanPrintError?: boolean | undefined; }>; ams_control: z.ZodObject<{ param: z.ZodAny; }, "strip", z.ZodTypeAny, { param?: any; }, { param?: any; }>; refreshPrinterState: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>; ams_filament_settings: z.ZodObject<{ ams_id: z.ZodNumber; tray_id: z.ZodNumber; filament_id: z.ZodString; setting_id: z.ZodString; color: z.ZodString; filament_type: z.ZodString; nozzle_temp_min: z.ZodNumber; nozzle_temp_max: z.ZodNumber; }, "strip", z.ZodTypeAny, { ams_id: number; tray_id: number; filament_id: string; setting_id: string; color: string; filament_type: string; nozzle_temp_min: number; nozzle_temp_max: number; }, { ams_id: number; tray_id: number; filament_id: string; setting_id: string; color: string; filament_type: string; nozzle_temp_min: number; nozzle_temp_max: number; }>; loadFilament: z.ZodObject<{ trayId: z.ZodNumber; oldTemp: z.ZodOptional<z.ZodNumber>; newTemp: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { trayId: number; oldTemp?: number | undefined; newTemp?: number | undefined; }, { trayId: number; oldTemp?: number | undefined; newTemp?: number | undefined; }>; unloadFilament: z.ZodObject<{ oldTemp: z.ZodOptional<z.ZodNumber>; newTemp: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { oldTemp?: number | undefined; newTemp?: number | undefined; }, { oldTemp?: number | undefined; newTemp?: number | undefined; }>; axisControl: z.ZodObject<{ axis: z.ZodEnum<["X", "Y", "Z", "E"]>; distance: z.ZodNumber; unit: z.ZodOptional<z.ZodNumber>; speed: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { axis: "X" | "Y" | "Z" | "E"; distance: number; unit?: number | undefined; speed?: number | undefined; }, { axis: "X" | "Y" | "Z" | "E"; distance: number; unit?: number | undefined; speed?: number | undefined; }>; autoLevel: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>; goHome: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>; cleanPrintError: z.ZodObject<{ subtaskId: z.ZodString; printError: z.ZodNumber; }, "strip", z.ZodTypeAny, { subtaskId: string; printError: number; }, { subtaskId: string; printError: number; }>; powerLossRecovery: z.ZodObject<{ action: z.ZodEnum<["resume", "stop"]>; subtaskId: z.ZodString; printError: z.ZodNumber; }, "strip", z.ZodTypeAny, { subtaskId: string; printError: number; action: "resume" | "stop"; }, { subtaskId: string; printError: number; action: "resume" | "stop"; }>; camera: z.ZodObject<{ operation: z.ZodEnum<["ipcam_record_set", "ipcam_timelapse", "ipcam_resolution_set"]>; value: z.ZodUnion<[z.ZodBoolean, z.ZodString]>; }, "strip", z.ZodTypeAny, { value: string | boolean; operation: "ipcam_record_set" | "ipcam_timelapse" | "ipcam_resolution_set"; }, { value: string | boolean; operation: "ipcam_record_set" | "ipcam_timelapse" | "ipcam_resolution_set"; }>; taskAbort: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>; taskCancel: z.ZodObject<{ jobId: z.ZodString; }, "strip", z.ZodTypeAny, { jobId: string; }, { jobId: string; }>; hmsResume: z.ZodObject<{ errorCode: z.ZodString; jobId: z.ZodString; }, "strip", z.ZodTypeAny, { errorCode: string; jobId: string; }, { errorCode: string; jobId: string; }>; hmsIgnore: z.ZodObject<{ errorCode: z.ZodString; jobId: z.ZodString; }, "strip", z.ZodTypeAny, { errorCode: string; jobId: string; }, { errorCode: string; jobId: string; }>; hmsStop: z.ZodObject<{ errorCode: z.ZodString; jobId: z.ZodString; }, "strip", z.ZodTypeAny, { errorCode: string; jobId: string; }, { errorCode: string; jobId: string; }>; stopBuzzer: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>; getAccessCode: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>; amsUserSettings: z.ZodObject<{ amsId: z.ZodNumber; startupReadOption: z.ZodBoolean; trayReadOption: z.ZodBoolean; calibrateRemainFlag: z.ZodBoolean; }, "strip", z.ZodTypeAny, { amsId: number; startupReadOption: boolean; trayReadOption: boolean; calibrateRemainFlag: boolean; }, { amsId: number; startupReadOption: boolean; trayReadOption: boolean; calibrateRemainFlag: boolean; }>; amsCalibrate: z.ZodObject<{ amsId: z.ZodNumber; }, "strip", z.ZodTypeAny, { amsId: number; }, { amsId: number; }>; amsRefreshRfid: z.ZodObject<{ trayId: z.ZodString; }, "strip", z.ZodTypeAny, { trayId: string; }, { trayId: string; }>; amsRefreshRfid2: z.ZodObject<{ amsId: z.ZodNumber; slotId: z.ZodNumber; }, "strip", z.ZodTypeAny, { amsId: number; slotId: number; }, { amsId: number; slotId: number; }>; amsSelectTray: z.ZodObject<{ trayId: z.ZodString; }, "strip", z.ZodTypeAny, { trayId: string; }, { trayId: string; }>; amsDryingStop: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>; setNozzleTempNew: z.ZodObject<{ extruderIndex: z.ZodNumber; targetTemp: z.ZodNumber; }, "strip", z.ZodTypeAny, { extruderIndex: number; targetTemp: number; }, { extruderIndex: number; targetTemp: number; }>; xyzAbsoluteMode: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>; printingOptions: z.ZodObject<{ autoRecovery: z.ZodBoolean; }, "strip", z.ZodTypeAny, { autoRecovery: boolean; }, { autoRecovery: boolean; }>; testLightSequence: z.ZodObject<{ sequence: z.ZodTuple<[z.ZodBoolean, z.ZodBoolean, z.ZodBoolean, z.ZodBoolean, z.ZodBoolean], null>; chamberLight: z.ZodBoolean; workLight: z.ZodBoolean; loops: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { sequence: [boolean, boolean, boolean, boolean, boolean]; chamberLight: boolean; workLight: boolean; loops?: number | undefined; }, { sequence: [boolean, boolean, boolean, boolean, boolean]; chamberLight: boolean; workLight: boolean; loops?: number | undefined; }>; }; type CommandSchemas = typeof commandSchemas; declare function validateCommandParams<T extends keyof CommandSchemas>(command: T, params: unknown): { success: true; data: z.infer<CommandSchemas[T]>; } | { success: false; error: z.ZodError; }; type CommandCategory = "info" | "pushing" | "system" | "print"; declare enum LightEffect$1 { ON = "on", OFF = "off", FLASHING = "flashing" } declare enum LightNode { CHAMBER = "chamber_light", WORK = "work_light" } interface LightOptions { onTime?: number; offTime?: number; loops?: number; interval?: number; } declare enum CameraOperation { RECORD = "ipcam_record_set", TIMELAPSE = "ipcam_timelapse", RESOLUTION = "ipcam_resolution_set" } declare enum FanType$1 { PART_COOLING = 1, AUXILIARY = 2, CHAMBER = 3 } type Axis = "X" | "Y" | "Z" | "E"; declare const VALID_COMMANDS: readonly ["updateLight", "updateFan", "updateSpeed", "updateTemp", "updateState", "gcode", "resume", "ams_control", "refreshPrinterState", "ams_filament_settings", "loadFilament", "unloadFilament", "axisControl", "autoLevel", "goHome", "cleanPrintError", "powerLossRecovery", "camera", "taskAbort", "taskCancel", "hmsResume", "hmsIgnore", "hmsStop", "stopBuzzer", "getAccessCode", "amsUserSettings", "amsCalibrate", "amsRefreshRfid", "amsRefreshRfid2", "amsSelectTray", "amsDryingStop", "setNozzleTempNew", "xyzAbsoluteMode", "printingOptions", "testLightSequence"]; type CommandType = (typeof VALID_COMMANDS)[number]; type CommandParams = { updateLight: { light: LightNode; mode: LightEffect$1; loopOptions?: LightOptions; }; updateFan: { fan: FanType$1; speed: NumberRange<0, 100>; }; updateSpeed: { speed: SpeedLevel; }; updateTemp: { part: "bed" | "nozzle" | "chamber"; temperature: NumberRange<0, 300>;