- Notifications
You must be signed in to change notification settings - Fork0
Brother QL Grocy Label Printer Service
License
sam159/brotherql_grocylabels
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This project is intended to be a webhook target forGrocy to print labels to a brother QL label printer.
Datamatrix or QR codes can be used with Datamatrix being the default. Datamatrix will fit better in smaller labels but I've found aren't as easily read by the Grocybarcode reader or by theAndroid App.
Only die-cut labels are supported as I don't have any endless rolls to test with.
Once you have this running somewhere update your config atapp/data/config.php
to match the following. Presuming that you have this running on localhost at port 8000.
// Label printer settings Setting('LABEL_PRINTER_WEBHOOK', 'http://127.0.0.1:8000/print'); Setting('LABEL_PRINTER_RUN_SERVER', true); Setting('LABEL_PRINTER_PARAMS', []); Setting('LABEL_PRINTER_HOOK_JSON', false); Setting('FEATURE_FLAG_LABEL_PRINTER', true);
The label size and printer are configured via environmental variables. You can also create a.env
file instead.
Variable | Default | Description |
---|---|---|
LABEL_SIZE | 62x29 | See thebrother_ql readme for the names of the labels |
PRINTER_MODEL | QL-500 | The printer model. One of the values accepted by brother_ql |
PRINTER_PATH | file:///dev/usb/lp1 | Where the printer is found on the system. For network printers usetcp://printer.address |
BARCODE_FORMAT | Datamatrix | Datamatrix orQRCode |
NAME_FONT | NotoSerif-Regular.ttf | The file name of the font in the fonts directory |
NAME_FONT_SIZE | 48 | The size of that font |
NAME_MAX_LINES | 4 | The maximum number of lines to use for the name |
DUE_DATE_FONT | NotoSerif-Regular.ttf | The file name of the font in the fonts directory |
DUE_DATE_FONT_SIZE | 30 | The size of that font |
ENDLESS_MARGIN | 10 | The top & bottom margin to add when using endless labels |
Included fonts areNotoSans-Regular.ttf
andNotoSerif-Regular.ttf
These are supported, for example the62
label size. The length of the label will be big enough to accommodate the max number of lines including a margin.You may want to experiment with font sizes and line count to get the most out of it.
Two endpoints are available/print
and/image
both accept the same parameters./image
will return the rendered image as a PNG instead of sending to the printer.
POST or GET accepted.
Name | Use |
---|---|
product | name |
battery | name |
chore | name |
recipe | name |
grocycode | the barcode |
due_date | the text at the bottom of the label |
The name will use whichever parameter is given.
Note: Theres no security on this web service, so don't make it publicly available.
This has been tested with python 3.10, newer may work fine.
You will need to install thelibdmtx
library for the barcodes to generate, seepylibdmtx documentation on pypi.
Its advisable to run and install in avenv. For example:
# Create and enter the venv python -m venv .venv source ./.venv/bin/activate # Install packages python -m pip install -U -r requirements.txt # exit with ./.venv/bin/deactivate
For development you can useflask run --debug
to run the service on port 5000. Alternatively usegunicorn -c gunicorn_conf.py app:app
to run the service on port 8000.
- Some more formatting options
A Dockerfile is included based on a python 3.10 alpine image. The default port is 8000.
Published to Dockerhub assam159/brotherql_grocylabels for architectures amd64, arm64, and armv7.
As an example, you can launch this withdocker run -d -p 8000:8000 -e PRINTER_MODEL=QL-500 -e PRINTER_PATH=file:///dev/usb/lp1 sam159/brotherql_grocylabels:latest
.
An exampledocker-compose.yml
file can be foundhere.
I'll try to keep on top of bugs but feature requests may go unfulfilled. Please use the issue tracking in Github.
PRs are welcome!
About
Brother QL Grocy Label Printer Service