PrinterPrinter is a local daemon that runs alongside Bambuddy, watches configured Bambu printers for print starts, and auto-prints job labels to a Brother QL-820NWB.
flowchart LR
A["Bambu P1S Printers"] -->|"Status + Print State"| B["Bambuddy API"]
B -->|"Poll every N seconds"| C["PrinterPrinter Daemon"]
C --> D[("SQLite Event Store")]
C --> E["Brother QL-820NWB"]
C --> F["Admin Endpoints\n/health /admin/events /admin/print-event/{id}"]
Latest label preview (DK1202 / 62x100):
- Bambuddy connectivity check and printer discovery
- Print-start detection from printer state transitions
- Event persistence in SQLite
- Automatic label print on new start events
- Manual reprint endpoint
- Configurable price-per-gram and optional price display
- User-friendly date/time and duration formatting
GET /healthGET /probes/bambuddyPOST /admin/poll-onceGET /admin/printersGET /admin/eventsPOST /admin/print-event/{event_id}
Copy .env.example to .env and update values.
PRINTERPRINTER_HOST(default0.0.0.0)PRINTERPRINTER_PORT(default8080)PRINTERPRINTER_LOG_LEVEL(defaultINFO)PRINTERPRINTER_DB_PATH(default./data/printerprinter.sqlite3)PRINTERPRINTER_POLL_INTERVAL_SECONDS(default5)PRINTERPRINTER_MONITORED_PRINTER_IDS(comma-separated Bambuddy numeric IDs, empty means all)PRINTERPRINTER_MONITORED_PRINTER_IDENTIFIERS(comma-separated IDs, names, serials, or IPs to auto-resolve)
BAMBUDDY_BASE_URL(examplehttp://10.206.50.172:8000)BAMBUDDY_API_TOKENBAMBUDDY_TIMEOUT_SECONDS(default15)BAMBUDDY_AUTH_MODE(bearer,api_key_header,none)BAMBUDDY_AUTH_HEADER_NAME(defaultX-API-Key)BAMBUDDY_JOBS_ENDPOINT(default/api/v1/print-log/)BAMBUDDY_PRINTERS_ENDPOINT(default/api/v1/printers/)BAMBUDDY_PRINTER_STATUS_ENDPOINT_TEMPLATE(default/api/v1/printers/{printer_id}/status)
BROTHER_ENABLED(true/false)BROTHER_MODEL(defaultQL-820NWB)BROTHER_PRINTER_URI(exampletcp://10.206.58.111:9100)BROTHER_LABEL_SIZE(default62x100, DK1202)BROTHER_CUT(true/false)
SHOW_PRICE_ON_LABEL(true/false)FILAMENT_PRICE_PER_GRAM(default0.10)
If price display is enabled, filament is shown as:
Filament: 42g ($4.20)
Mass is rounded to the nearest gram before both display and price calculation.
- Create and activate a virtual environment.
- Install dependencies.
- Configure
.env. - Run the daemon.
python3 -m venv .venv
. .venv/bin/activate
pip install -e .
uvicorn printerprinter.main:app --host 0.0.0.0 --port 8080Quick checks:
curl http://localhost:8080/health
curl http://localhost:8080/probes/bambuddy
curl http://localhost:8080/admin/printers
curl -X POST http://localhost:8080/admin/poll-once
curl http://localhost:8080/admin/eventsRun the setup script to fully set up PrinterPrinter with interactive configuration prompts. Choose one of the methods below:
If an existing .env is present, the installer will show the current values first and let you keep them to skip the prompts.
Method 1: Pipe directly to bash (requires bash 4.1+, use Method 2 if this fails)
curl -fsSL https://raw.githubusercontent.com/firstbuild/PrinterPrinter/main/scripts/setup-rpi.sh | sudo bashMethod 2: Download then run (most reliable, recommended if Method 1 fails)
curl -fsSL https://raw.githubusercontent.com/firstbuild/PrinterPrinter/main/scripts/setup-rpi.sh -o /tmp/setup.sh
sudo bash /tmp/setup.shMethod 3: Clone repo locally (manual)
cd /tmp
git clone -b main https://github.com/firstbuild/PrinterPrinter.git
cd PrinterPrinter
sudo bash scripts/setup-rpi.shSpecify a different branch by passing it as an argument (Methods 2 & 3):
sudo bash /tmp/setup.sh developThe setup script will:
- Check and install system dependencies
- Clone or update the repository
- Create a Python virtual environment
- Install dependencies
- Prompt you for all configuration values (Bambuddy address, API key, printer IPs, pricing, etc.)
- Create a systemd service file
- Enable and start the daemon
After setup completes, monitor logs with:
journalctl -u printerprinter -fIf you prefer to set up manually, follow these steps:
These instructions assume Raspberry Pi OS 64-bit and Python 3.11+.
- Install system packages.
sudo apt update
sudo apt install -y git python3 python3-venv python3-pip- Clone and install.
git clone <your-repo-url> PrinterPrinter
cd PrinterPrinter
python3 -m venv .venv
. .venv/bin/activate
pip install -e .
cp .env.example .env- Edit
.envfor your network:
BAMBUDDY_BASE_URL=http://<bambuddy-ip>:8000BROTHER_PRINTER_URI=tcp://<brother-ip>:9100BAMBUDDY_API_TOKEN=<token>
- Create systemd service.
/etc/systemd/system/printerprinter.service
[Unit]
Description=PrinterPrinter Daemon
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi/PrinterPrinter
EnvironmentFile=/home/pi/PrinterPrinter/.env
ExecStart=/home/pi/PrinterPrinter/.venv/bin/uvicorn printerprinter.main:app --host 0.0.0.0 --port 8080
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target- Enable and start.
sudo systemctl daemon-reload
sudo systemctl enable printerprinter
sudo systemctl start printerprinter
sudo systemctl status printerprinter- View logs.
journalctl -u printerprinter -fThis repository includes:
Dockerfiledocker-compose.example.yml
- Set
.envwith Bambuddy LAN URL, for example:
BAMBUDDY_BASE_URL=http://bambuddy.local:8000
- Build and run:
docker compose -f docker-compose.example.yml up -d --buildIf your Bambuddy service is named bambuddy in compose, set:
BAMBUDDY_BASE_URL=http://bambuddy.local:8000
Use shared compose network (default) so service DNS works.
- On Linux,
network_mode: hostmay simplify LAN printer discovery/access. - On macOS/Windows Docker Desktop, host networking differs; prefer direct IP routing where possible.
- Ensure container can reach TCP
9100on Brother printer.
- Keep API tokens out of git; do not commit
.env. - Use
PRINTERPRINTER_MONITORED_PRINTER_IDSto limit label scope. - If labels fail, test printer reachability:
ping <brother-ip>
nc -vz <brother-ip> 9100- Trigger manual reprint by event ID:
curl -X POST http://localhost:8080/admin/print-event/123Wrong roll type: verifyBROTHER_LABEL_SIZE=62x100for DK1202.- No prints: verify
BROTHER_ENABLED=trueand printer URI. - Bambuddy timeout/DNS issues: use direct IP in
BAMBUDDY_BASE_URL. - Price hidden unexpectedly: verify
SHOW_PRICE_ON_LABEL=true.
