← 返回
开发者工具 Key 中文

Snapmaker

Control and monitor Snapmaker 2.0 3D printers via their HTTP API. Status, job management, progress watching, and event monitoring.
通过 HTTP API 控制和监控 Snapmaker 2.0 3D 打印机。支持状态查询、任务管理、进度监控及事件监视。
odrobnik odrobnik 来源
开发者工具 clawhub v1.2.2 2 版本 99906.6 Key: 需要
★ 1
Stars
📥 2,120
下载
💾 45
安装
2
版本
#latest

概述

Snapmaker 2.0 Skill

Control and monitor Snapmaker 2.0 3D printers via their HTTP API.

Features

  • Status monitoring - Real-time printer status (temperatures, progress, position)
  • Job management - Send, start, pause, resume, and stop print jobs
  • Safety features - Prevents interfering with active prints without confirmation
  • Progress watching - Live monitoring of print progress
  • Notification support - Detect print completion, filament issues, errors

Configuration

Create config.json in your workspace's snapmaker/ folder (e.g. ~/clawd/snapmaker/config.json).

Start from config.json.example.

Config format:

{
  "ip": "192.168.0.32",
  "token": "your-token-here",
  "port": 8080
}

Finding your token:

Open the Snapmaker Luban app, connect to your printer, and find the token

in the connection settings. Copy it into your config.json.

Usage

Discovery

# Find Snapmaker printers on the local network (UDP broadcast, port 20054)
python3 scripts/snapmaker.py discover

# Probe a specific IP (useful across subnets)
python3 scripts/snapmaker.py discover --target 192.168.0.32

# JSON output
python3 scripts/snapmaker.py discover --json

Discovery uses the Snapmaker UDP broadcast protocol (no auth required).

Falls back to HTTP probe using config if UDP gets no reply (e.g. different subnet).

Basic Commands

# Get current printer status
python3 scripts/snapmaker.py status

# Watch print progress (updates every 5 seconds)
python3 scripts/snapmaker.py watch

# Get status as JSON
python3 scripts/snapmaker.py status --json

Job Control

# Send a file (prepares but doesn't start)
python3 scripts/snapmaker.py send ~/prints/model.gcode

# Send and start immediately
python3 scripts/snapmaker.py send ~/prints/model.gcode --start --yes

# Pause current print
python3 scripts/snapmaker.py pause --yes

# Resume paused print
python3 scripts/snapmaker.py resume --yes

# Stop/cancel print (requires confirmation)
python3 scripts/snapmaker.py stop

Safety Flags

  • --yes - Skip confirmation prompts (use with caution!)
  • --force - Override safety checks (NOT RECOMMENDED)

All commands that modify state require confirmation unless --yes is provided.

API Endpoints

The skill uses these Snapmaker HTTP API v1 endpoints:

  • POST /api/v1/connect - Establish connection
  • GET /api/v1/status - Get printer status
  • POST /api/v1/prepare_print - Upload file
  • POST /api/v1/start_print - Start printing
  • POST /api/v1/pause - Pause print
  • POST /api/v1/resume - Resume print
  • POST /api/v1/stop - Stop/cancel print
  • GET /api/v1/print_file - Download last file

Status Fields

The status command returns:

  • status - Overall state (IDLE, RUNNING, PAUSED)
  • printStatus - Printing / Idle
  • progress - 0.0 to 1.0
  • fileName - Current/last file
  • currentLine / totalLines - G-code progress
  • elapsedTime / remainingTime - In seconds
  • nozzleTemperature1 / nozzleTargetTemperature1
  • heatedBedTemperature / heatedBedTargetTemperature
  • x / y / z - Current position
  • isFilamentOut - Filament runout detection
  • isEnclosureDoorOpen - Door state

Notifications

To detect events:

# Watch for completion
python3 scripts/snapmaker.py watch

# Or poll status in a loop
while true; do
  python3 scripts/snapmaker.py status --json | jq -r '.printStatus'
  sleep 10
done

Event detection:

  • Print complete - status == "IDLE" && progress >= 0.99
  • Filament out - isFilamentOut == true
  • Door opened - isEnclosureDoorOpen == true
  • Error - Check status field for errors

Safety Features

  1. Active print protection - Cannot send files while printing
  2. Confirmation prompts - All destructive actions require confirmation
  3. State validation - Commands check printer state before executing
  4. Clear warnings - Stop command shows prominent warning

Examples

Check if printer is busy

python3 scripts/snapmaker.py status | grep -q "RUNNING" && echo "Busy" || echo "Available"

Get remaining time

python3 scripts/snapmaker.py status --json | jq -r '.remainingTime'

Monitor temperatures

python3 scripts/snapmaker.py status --json | jq '{nozzle: .nozzleTemperature1, bed: .heatedBedTemperature}'

Troubleshooting

"Machine is not connected yet" (401 error):

  • The API requires calling /api/v1/connect first before any status queries
  • Example: curl -X POST "http://192.168.0.32:8080/api/v1/connect?token=YOUR_TOKEN"
  • The Python script handles this automatically on first request
  • Connection establishes a session that persists until the printer is powered off
  • If using raw curl commands, always call connect first

Connection refused:

  • Verify printer IP: ping 192.168.0.32
  • Check printer is powered on
  • Ensure you're on the same network

Invalid token:

  • Reconnect Luban to the printer (accept on touchscreen)
  • Copy the new token from Luban's connection settings
  • Update your config.json

Can't send file:

  • Check if printer is busy: python3 scripts/snapmaker.py status
  • Wait for current print to finish
  • Use --force only if absolutely necessary

References

Dependencies

  • Python 3.6+
  • requests library (install: pip3 install requests)

License

Part of OpenClaw skills collection.

版本历史

共 2 个版本

  • v1.2.2 当前
    2026-03-28 16:16 安全 安全
  • v1.2.1
    2026-03-07 11:40

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

it-ops-security

OpenClaw Backup

alex3alex
备份与恢复 OpenClaw 数据。适用于创建备份、设置自动备份计划、从备份恢复或管理备份轮转。处理 ~/.openclaw 目录归档并包含适当的排除规则。
★ 90 📥 30,733
it-ops-security

1password

steipete
设置和使用 1Password CLI (op)。适用于:安装 CLI、启用桌面应用集成、登录(单/多账户)、通过 op 读取/注入/运行密钥。
★ 53 📥 31,397
dev-programming

Codex Quota

odrobnik
通过读取 ~/.codex/sessions/ 的本地会话日志,检查 OpenAI Codex CLI 的速率限制状态(日/周配额)。便携式 Python 脚本。
★ 3 📥 6,690