Snapmaker Printer Control
Control Snapmaker U1 printers via the Moonraker API.
Configuration
Create a config file at ~/clawd/config/snapmaker.json:
CODEBLOCK0
Or use environment variables:
CODEBLOCK1
Config search order:
- 1.
SNAPMAKER_IP environment variable (highest priority) - INLINECODE2
- INLINECODE3
Quick Commands
Check Status
CODEBLOCK2
Filament Info
scripts/snapmaker.py filament
Shows RFID tag data for each slot: material type, color (hex), temp ranges, and sensor status.
Monitor Print (Live)
CODEBLOCK4
Print Control
CODEBLOCK5
Temperature
CODEBLOCK6
API Reference
The U1 uses Moonraker REST API on port 80:
| Endpoint | Description |
|---|
| INLINECODE4 | Server status |
| INLINECODE5 |
Printer info |
|
/printer/objects/query?heater_bed&extruder&print_stats | Status |
|
/printer/print/pause | Pause print |
|
/printer/print/resume | Resume print |
|
/printer/print/cancel | Cancel print |
Status Response Fields
- -
print_stats.state: standby, printing, paused, complete, INLINECODE15 - INLINECODE16 : Current file
- INLINECODE17 : Seconds elapsed
- INLINECODE18 : 0.0 to 1.0
- INLINECODE19 /
heater_bed.target: Bed temps - INLINECODE21 /
extruder.target: Nozzle temps
Filament & Sensor Data
Query filament RFID and sensors:
CODEBLOCK7
filament_detect.info[]
Array of 4 slots with RFID tag data (or defaults if no tag):
| Field | Description |
|---|
| INLINECODE23 | "Snapmaker" or "NONE" if no RFID |
| INLINECODE24 |
e.g. "Polymaker" |
|
MAIN_TYPE | Material: "PLA", "PETG", "ABS", etc. |
|
SUB_TYPE | Variant: "SnapSpeed", "generic", etc. |
|
RGB_1 | Color as decimal int (convert:
#${(rgb>>16&0xFF).toString(16)}...) |
|
ARGB_COLOR | Color with alpha (decimal) |
|
WEIGHT | Spool weight in grams |
|
HOTEND_MIN_TEMP /
HOTEND_MAX_TEMP | Nozzle temp range |
|
BED_TEMP | Recommended bed temp |
|
OFFICIAL | true if official Snapmaker filament |
filamentmotionsensor e{0-3}_filament
| Field | Description |
|---|
| INLINECODE35 | Boolean - filament present in slot |
| INLINECODE36 |
Boolean - sensor active |
Note: Slots can have filament_detected: true but VENDOR: NONE — this means third-party filament without RFID tag.
Snapmaker 打印机控制
通过Moonraker API控制Snapmaker U1打印机。
配置
在 ~/clawd/config/snapmaker.json 创建配置文件:
json
{
ip: 192.168.x.x,
port: 80
}
或使用环境变量:
bash
export SNAPMAKER_IP=192.168.x.x
export SNAPMAKER_PORT=80 # 可选,默认为80
配置搜索顺序:
- 1. SNAPMAKER_IP 环境变量(最高优先级)
- ~/clawd/config/snapmaker.json
- ~/.config/clawdbot/snapmaker.json
快速命令
检查状态
bash
scripts/snapmaker.py status
耗材信息
bash
scripts/snapmaker.py filament
显示每个槽位的RFID标签数据:材料类型、颜色(十六进制)、温度范围和传感器状态。
监控打印(实时)
bash
scripts/snapmaker.py monitor
打印控制
bash
scripts/snapmaker.py pause
scripts/snapmaker.py resume
scripts/snapmaker.py cancel
温度
bash
scripts/snapmaker.py temps
API参考
U1在80端口使用Moonraker REST API:
| 端点 | 描述 |
|---|
| /server/info | 服务器状态 |
| /printer/info |
打印机信息 |
| /printer/objects/query?heater
bed&extruder&printstats | 状态 |
| /printer/print/pause | 暂停打印 |
| /printer/print/resume | 恢复打印 |
| /printer/print/cancel | 取消打印 |
状态响应字段
- - printstats.state:standby(待机)、printing(打印中)、paused(已暂停)、complete(完成)、error(错误)
- printstats.filename:当前文件
- printstats.printduration:已用秒数
- virtualsdcard.progress:0.0 到 1.0
- heaterbed.temperature / heater_bed.target:热床温度
- extruder.temperature / extruder.target:喷嘴温度
耗材与传感器数据
查询耗材RFID和传感器:
/printer/objects/query?filamentdetect&filamentmotionsensor%20e0filament&filamentmotionsensor%20e1filament&filamentmotionsensor%20e2filament&filamentmotionsensor%20e3_filament
filament_detect.info[]
包含4个槽位的RFID标签数据数组(若无标签则为默认值):
| 字段 | 描述 |
|---|
| VENDOR | Snapmaker 或 NONE(无RFID时) |
| MANUFACTURER |
例如 Polymaker |
| MAIN_TYPE | 材料:PLA、PETG、ABS 等 |
| SUB_TYPE | 变体:SnapSpeed、generic 等 |
| RGB_1 | 颜色十进制整数(转换:#${(rgb>>16&0xFF).toString(16)}...) |
| ARGB_COLOR | 带透明度的颜色(十进制) |
| WEIGHT | 线盘重量(克) |
| HOTEND
MINTEMP / HOTEND
MAXTEMP | 喷嘴温度范围 |
| BED_TEMP | 推荐热床温度 |
| OFFICIAL | 是否为Snapmaker官方耗材 |
filamentmotionsensor e{0-3}_filament
| 字段 | 描述 |
|---|
| filament_detected | 布尔值 - 槽位中是否有耗材 |
| enabled |
布尔值 - 传感器是否启用 |
注意: 槽位可能出现 filament_detected: true 但 VENDOR: NONE 的情况——这表示使用了无RFID标签的第三方耗材。