From eceb2e918b5dfc224fe32055267ae7f000ba0501 Mon Sep 17 00:00:00 2001 From: James Pattinson Date: Fri, 6 Feb 2026 16:30:15 +0000 Subject: [PATCH] first commit --- README.md | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..9ef8060 --- /dev/null +++ b/README.md @@ -0,0 +1,59 @@ +# 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. \ No newline at end of file