9bcce9564d8204b26f4ca6352225f7fdf939f0be
Vet Label Printer Client
This is a Docker-based MQTT client that listens for print requests, generates vet drug prescription labels, and prints them using a Brother QL printer.
Setup
-
Configure the environment variables in
.env:MQTT_HOST: MQTT broker hostnameMQTT_PORT: MQTT broker portMQTT_TOPIC_SUB: Topic to subscribe for print requestsMQTT_TOPIC_PUB_STATUS: Topic to publish status messages (success and errors)PRINTER_DEVICE: Printer device path (e.g., /dev/usb/lp0)PRINTER_MODEL: Printer model (e.g., QL-800)LABEL_SIZE_DEFAULT: Default label size (e.g., 29x90)
-
Build and run with Docker Compose:
docker-compose up --build
MQTT Message Format
The client subscribes to the configured topic and expects JSON messages like:
{
"template_id": "vet_label",
"label_size": "29x90",
"variables": {
"practice_name": "Many Tears Animal Rescue",
"animal_name": "Rosie 468837",
"drug_name": "Amoxicillin 50mg",
"dosage": "1 tablet twice daily with food",
"quantity": "14 tablets",
"vet_initials": "Frank Molina"
},
"test": false
}
template_id: Identifier for the label template (currently only "vet_label" supported)label_size: Size of the label (passed to brother-ql)variables: Key-value pairs for label contenttest: If true, saves PNG to/app/output/instead of printing
Error Handling
Any errors during processing are published to the error topic as JSON:
{
"error": "Error message",
"original_payload": "{original message}"
}
Adding New Templates
To add new label templates, edit templates.py and add to the TEMPLATES dict.
Description
Languages
Python
97.9%
Dockerfile
2.1%