Skip to main content

Grocy Label Printer ESC/P

A Flask server that receives Grocy label requests and prints them to ESC/P thermal printers.

CI PyPI version Docker

Features

  • Grocy Integration: Compatible with Grocy's label printing system
  • ESC/P Support: Works with ESC/P thermal printers via network
  • QR Code Generation: Automatically generates QR codes from Grocy barcodes
  • Smart Layout: QR code at top, product information below
  • Font Management: Uses Roboto Bold fonts in multiple sizes
  • Container Support: Available as Docker images for easy deployment
  • Multi-Architecture: Supports AMD64 and ARM64 architectures

Quick Start

docker run -d \
  --name grocy-label-printer \
  -p 5000:5000 \
  -e PRINTER_HOST=192.168.1.100 \
  -e PRINTER_PORT=9100 \
  ghcr.io/miguelangel-nubla/grocy-label-printer-escpos:latest

Python Package

pip install grocy-label-printer-escpos
grocy-label-printer-escpos

From Source

git clone https://github.com/miguelangel-nubla/grocy-label-printer-escpos.git
cd grocy-label-printer-escpos
pip install -e .
python -m grocy_label_printer_escpos.server

Configuration

Environment Variables

Variable Default Description
PRINTER_HOST 192.168.1.100 IP address of the thermal printer
PRINTER_PORT 9100 Port of the thermal printer
LABEL_WIDTH 384 Width of labels in pixels
SERVER_HOST 0.0.0.0 Server bind address
SERVER_PORT 5000 Server port

Grocy Configuration

In Grocy, configure a new label printer:

  1. Go to Manage > Label printers
  2. Add a new printer with these settings:
    • Name: ESC/P Thermal Printer
    • Type: Generic
    • URL: http://your-server:5000/print
    • HTTP Method: POST

API Endpoints

POST /print

Print a label from Grocy data.

Request Body: Grocy label data (JSON or form-encoded)

Response:

  • 200 OK - Label printed successfully
  • 400 Bad Request - Invalid or missing data
  • 500 Internal Server Error - Print failed

GET|POST /image

Preview label image without printing.

Parameters: Same as /print

Response: PNG image of the label

GET /test

Print a test label with sample data.

Response:

{"status": "success", "message": "Test label printed"}

GET /

Server status and configuration.

Response:

{
  "status": "running",
  "printer": "192.168.1.100:9001",
  "service": "Grocy Thermal Label Server"
}

Label Format

Labels include:

  • QR Code: Generated from Grocy barcode (top, centered)
  • Product Name: Large bold font (centered)
  • Amount & Unit: Medium font (if available)
  • Best Before Date: Medium font (if available)
  • Purchase Date: Medium font (if available)

Special handling:

  • Long product names are automatically split across lines
  • Container weight items exclude amount/date information
  • Proper singular/plural unit names

Printer Compatibility

Tested with:

  • Sunmi integrated 58mm thermal printers

Development

Setup

git clone https://github.com/miguelangel-nubla/grocy-label-printer-escpos.git
cd grocy-label-printer-escpos
pip install -e ".[dev]"
pre-commit install

Testing

pytest

Code Quality

black src/ tests/
isort src/ tests/
flake8 src/ tests/
mypy src/

Building

python -m build

Deployment

Docker Compose

version: '3.8'
services:
  grocy-label-printer:
    image: ghcr.io/miguelangel-nubla/grocy-label-printer-escpos:latest
    ports:
      - "5000:5000"
    environment:
      - PRINTER_HOST=192.168.1.100
      - PRINTER_PORT=9100
    restart: unless-stopped

Kubernetes

apiVersion: apps/v1
kind: Deployment
metadata:
  name: grocy-label-printer
spec:
  replicas: 1
  selector:
    matchLabels:
      app: grocy-label-printer
  template:
    metadata:
      labels:
        app: grocy-label-printer
    spec:
      containers:
      - name: grocy-label-printer
        image: ghcr.io/miguelangel-nubla/grocy-label-printer-escpos:latest
        ports:
        - containerPort: 5000
        env:
        - name: PRINTER_HOST
          value: "192.168.1.100"
        - name: PRINTER_PORT
          value: "9100"
---
apiVersion: v1
kind: Service
metadata:
  name: grocy-label-printer
spec:
  selector:
    app: grocy-label-printer
  ports:
  - port: 5000
    targetPort: 5000

Troubleshooting

Printer Connection Issues

  1. Check network connectivity:

    telnet 192.168.1.100 9100
    
  2. Verify printer profile: Some printers may need different profiles. Try:

    • TM-T20
    • Generic
    • TM-T88III
  3. Check printer logs:

    docker logs grocy-label-printer
    

Label Not Printing

  1. Test with sample data:

    curl http://localhost:5000/test
    
  2. Check Grocy data format:

    curl -X POST http://localhost:5000/image \
      -H "Content-Type: application/json" \
      -d '{"product": "Test", "grocycode": "123"}'
    
  3. Verify printer buffer: Ensure the printer connection is properly closed after each print job.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Run the test suite
  6. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Releases

See GitHub Releases for version history and changes.

Metadata

Release files for grocy-label-printer-escpos 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for grocy-label-printer-escpos 0.1.0
File Size Uploaded Provenance Actions
grocy_label_printer_escpos-0.1.0.tar.gz 14.3 kB With provenance Details for grocy_label_printer_escpos-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for grocy-label-printer-escpos 0.1.0
File Interpreter ABI Platform Actions
grocy_label_printer_escpos-0.1.0-py3-none-any.whl Python 3 none any Details for grocy_label_printer_escpos-0.1.0-py3-none-any.whl

Total release size: 24.5 kB

Release files / grocy_label_printer_escpos-0.1.0.tar.gz

Download URL grocy_label_printer_escpos-0.1.0.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f66b95875b2619d9a6d005068667d061432043325d982e06d382a3262b686ef8
BLAKE2b-256 checksum
How to use checksums
820d135108b1355cdd471244555e6fa51685320c57df8335957725b02fde4a15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2025.

Transparency log

Release files / grocy_label_printer_escpos-0.1.0-py3-none-any.whl

Download URL grocy_label_printer_escpos-0.1.0-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d753b6be82e7fd549947b08639d55c8d1a0113207b7800bdf97c86ecf1833c2
BLAKE2b-256 checksum
How to use checksums
4fbd5dda7e453873a2237561a44f421a98b6a8843e5acdc50a8f7a3c49c88030
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2025.

Transparency log

Security for grocy-label-printer-escpos 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for grocy_label_printer_escpos-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page