Files
vet-print-client/README.md
2026-02-06 16:30:15 +00:00

59 lines
1.6 KiB
Markdown

# 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
1. Configure the environment variables in `.env`:
- `MQTT_HOST`: MQTT broker hostname
- `MQTT_PORT`: MQTT broker port
- `MQTT_TOPIC_SUB`: Topic to subscribe for print requests
- `MQTT_TOPIC_PUB_ERRORS`: Topic to publish 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)
2. Build and run with Docker Compose:
```bash
docker-compose up --build
```
## MQTT Message Format
The client subscribes to the configured topic and expects JSON messages like:
```json
{
"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 content
- `test`: If true, saves PNG to `/app/output/` instead of printing
## Error Handling
Any errors during processing are published to the error topic as JSON:
```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.