Skip to content

Dev-devadath/babu-cli

Repository files navigation

babu-cli

CLI for controlling BambuLab printers directly over MQTT/FTPS/camera.

Install

Using Go install

go install github.com/Dev-devadath/babu-cli/cmd/babu-cli@latest

If @latest resolves to an older commit, use:

GOPROXY=direct go install github.com/Dev-devadath/babu-cli/cmd/babu-cli@master

or pin a commit:

GOPROXY=direct go install github.com/Dev-devadath/babu-cli/cmd/babu-cli@<commit>

macOS setup

# 1) Install Go (if needed)
brew install go

# 2) Install babu-cli
go install github.com/Dev-devadath/babu-cli/cmd/babu-cli@latest

# 3) Add Go bin to PATH
echo 'export PATH="$PATH:$(go env GOPATH)/bin"' >> ~/.zshrc
source ~/.zshrc
hash -r

# 4) Verify
which babu-cli
babu-cli --help

If you use GOBIN, add that path instead of $(go env GOPATH)/bin.

Download pre-built binaries

Download the latest release from GitHub Releases and extract the binary for your platform.

Build from source

go build -o babu-cli ./cmd/babu-cli

Update

When a new feature is pushed, update babu-cli using the same method you used to install it.

Update with Go install (recommended)

macOS:

go install github.com/Dev-devadath/babu-cli/cmd/babu-cli@latest
hash -r
babu-cli --help

Windows (PowerShell):

go install github.com/Dev-devadath/babu-cli/cmd/babu-cli@latest
Get-Command babu-cli
babu-cli --help

If @latest resolves to an older commit, use:

macOS/Linux:

GOPROXY=direct go install github.com/Dev-devadath/babu-cli/cmd/babu-cli@master

Windows (PowerShell):

$env:GOPROXY = "direct"
go install github.com/Dev-devadath/babu-cli/cmd/babu-cli@master

Update pre-built binaries

  1. Download the newest archive from GitHub Releases.
  2. Extract it.
  3. Replace your existing babu-cli binary (babu-cli.exe on Windows) in your PATH.
  4. Open a new terminal and run:
babu-cli --help

Quick start

# Create a working default profile (uses profile name "default")
babu-cli config set \
  --ip 192.168.1.200 \
  --serial AC12309BH109 \
  --access-code YOUR_ACCESS_CODE

# Optional: use a named profile
babu-cli config set --printer lab \
  --ip 192.168.1.200 \
  --serial AC12309BH109 \
  --access-code YOUR_ACCESS_CODE \
  --default

# Status
babu-cli status

# Start a print
babu-cli print start ./benchy.3mf --plate 1

Print and File Commands

# List files on printer storage
babu-cli files list
babu-cli files list --dir cache

# Upload local file to printer storage
babu-cli files upload ./benchy.3mf
babu-cli files upload ./benchy.3mf --as cache/benchy.3mf

# Download file from printer storage
babu-cli files download cache/benchy.3mf --out ./benchy-copy.3mf

# Delete file from printer storage
babu-cli files delete cache/benchy.3mf
# Start print from local file (uploads first, then starts)
babu-cli print start ./benchy.3mf --plate 1

# Start print from file already on printer (no upload)
babu-cli print start --no-upload --plate 1 "cache/benchy.3mf"

# Print controls
babu-cli print pause
babu-cli print resume
babu-cli print stop

Notes:

  • Use .3mf for print start --no-upload.
  • Keep flags before the filename (for example: print start --no-upload --plate 1 "file.3mf").
  • --plate 1 maps to Metadata/plate_1.gcode inside the 3MF.

Config

  • User config: <os.UserConfigDir>/bambu/config.json
    • macOS usually: ~/Library/Application Support/bambu/config.json
    • Linux usually: ~/.config/bambu/config.json
    • Windows usually: %AppData%\bambu\config.json
  • Project config: ./.bambu.json
  • Precedence: flags > env > project config > user config
  • Missing config file is treated as empty; it is created on first config set.

Expected config format

babu-cli expects default_profile + profiles. Example:

{
  "default_profile": "lab",
  "profiles": {
    "lab": {
      "ip": "192.168.11.234",
      "serial": "0300DA610705389",
      "access_code": "YOUR_ACCESS_CODE"
    }
  }
}

Note: configs using machines, token, etc. are from other tools and are not read by babu-cli.

Access code

Get the printer access code from the device or Bambu Studio, then set it directly:

babu-cli config set --ip 192.168.1.200 --serial AC12309BH109 --access-code YOUR_ACCESS_CODE

Or use a file if you prefer:

mkdir -p ~/.config/bambu
printf "%s" "YOUR_ACCESS_CODE" > ~/.config/bambu/lab.code
chmod 600 ~/.config/bambu/lab.code

In Bambu Studio on macOS: open the Device view for your printer, open its settings, and look for "LAN Access" or "Access Code" (often shown alongside IP/serial details).

Env vars

  • BAMBU_PROFILE
  • BAMBU_IP
  • BAMBU_SERIAL
  • BAMBU_ACCESS_CODE
  • BAMBU_ACCESS_CODE_FILE
  • BAMBU_TIMEOUT
  • BAMBU_NO_CAMERA
  • BAMBU_MQTT_PORT
  • BAMBU_FTP_PORT
  • BAMBU_CAMERA_PORT

Troubleshooting

zsh: command not found: babu-cli

go install likely succeeded but your shell PATH does not include Go bin.

go env GOBIN
go env GOPATH
ls -l "$(go env GOPATH)/bin" | grep babu-cli

Then add the correct bin path to PATH in ~/.zshrc.

access code not set

This means no access code source was resolved for the active profile.

Resolution order:

  • --access-code-stdin
  • --access-code-file
  • BAMBU_ACCESS_CODE
  • BAMBU_ACCESS_CODE_FILE
  • profiles.<name>.access_code
  • profiles.<name>.access_code_file

Profile selection order:

  • --printer
  • BAMBU_PROFILE
  • default_profile

Set it explicitly:

babu-cli config set --ip 192.168.1.200 --serial AC12309BH109 --access-code YOUR_ACCESS_CODE

Print starts but pauses with filament errors

If the job starts heating/extruding and then pauses with filament-related prompts, check AMS mode.

  • Default behavior is --ams auto.
    • If AMS is not detected, the print starts with use_ams=false.
    • If AMS is detected, the CLI tries to auto-select loaded tray IDs for ams_mapping.
  • Use --ams on to force AMS mode (optionally with --ams-mapping).
  • Use --ams off or --no-ams to disable AMS for that print.

Use --no-ams only when printing from an external spool/manual feed path that matches your loaded filament.

Notes

  • Printer must be reachable on ports 8883 (MQTT), 990 (FTPS), 6000 (camera).
  • access_code is stored as plain text in config when set directly.

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages