Files
POS-Automation/CONTEXT.md
T
Mortdecai 03aa1fc7c7 docs: retire cron, record MQTT/discovery/gemma4 decisions
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-07 13:43:26 -04:00

75 lines
3.8 KiB
Markdown

# POS-Automation Context
## Overview
POS-only daily news briefing for the **Epson TM-m30** receipt printer.
Fetches unread articles from FreshRSS, selects and summarizes them via Ollama, then sends a native ESC/POS receipt over TCP to the printer. No PDF generation, no CUPS, no full-size printer support.
Forked from `Seth/PrinterAutomation` on Gitea.
## Components
- `pos_briefing.py` — Main script. Run directly or via the MQTT bridge (Google Home button).
- `config.json` — Credentials and endpoints (not committed).
- `config.example.json` — Template for config.json.
## How It Works
1. Logs into FreshRSS (Google Reader API), fetches up to 100 unread items.
2. Sends headlines to Ollama — Phase 1 selects top 5, Phase 2 summarizes each in 30-50 words.
3. Collects dashboard data: weather (open-meteo), ZFS status (SSH to remote host), Grafana metrics, market data (yfinance), Uptime Kuma alerts (pct exec).
4. Builds ESC/POS receipt bytes via `python-escpos` (Dummy printer).
5. Sends raw bytes to printer via TCP socket on port 9100.
6. Marks articles as read in FreshRSS.
## Configuration (`config.json`)
| Key | Description | Example |
|---|---|---|
| `freshrss_url` | FreshRSS base URL | `http://192.168.0.157` |
| `freshrss_user` | FreshRSS username | `Admin` |
| `freshrss_api_key` | FreshRSS API password | `seth123!` |
| `ollama_url` | Ollama instance URL | `http://192.168.0.141:11434` |
| `ollama_model` | Model name | `qwen2.5:1.5b` |
| `yourls_url` | YOURLS API endpoint | `http://192.168.0.152:8080/yourls-api.php` |
| `yourls_user` | YOURLS username | `admin` |
| `yourls_pass` | YOURLS password | |
| `grafana_url` | Grafana base URL | `https://monitor.atermiter-x79.xyz` |
| `grafana_token` | Grafana service account token | `glsa_...` |
| `remote_host` | Host to SSH into for ZFS status | `192.168.0.197` |
| `remote_pass` | SSH password for remote_host | |
| `printer_ip` | TM-m30 IP address | `192.168.0.137` |
| `printer_port` | ESC/POS TCP port (default 9100) | `9100` |
## Infrastructure
- **Printer:** Epson TM-m30 at `192.168.0.137`, ESC/POS TCP port 9100.
- **FreshRSS:** CT 120, `192.168.0.157` / `fresh.sethpc.xyz`.
- **Ollama:** `192.168.0.141` (Gaming PC, `steel141`). Model: `qwen2.5:1.5b`.
- **YOURLS:** `192.168.0.152:8080` — shortens article URLs printed on receipt.
- **Grafana:** `monitor.atermiter-x79.xyz` — Proxmox node metrics (173, 112, 197).
- **ZFS:** SSH to `192.168.0.197` (node-197) — queries `zpool list tank`.
- **Uptime Kuma:** CT 147 — queried via `pct exec 147` (requires Proxmox host).
- **This script runs on:** steel141 (`192.168.0.141`). Previously CT 166 (retired).
## Trigger
On-demand only — **no cron**. Google Home button → HA `script.print_daily_briefing`
→ MQTT `posbriefing/button/press` on broker CT 301 (192.168.0.154) →
`pos-briefing-mqtt.service` on steel141 (systemd, `User=claude`) → `pos_briefing.py`
→ printer discovered by MAC → ESC/POS over TCP. See `docs/ha-setup.md` and
`docs/superpowers/specs/2026-06-07-ha-google-home-trigger-design.md`.
## Setup
```bash
pip3 install requests python-escpos yfinance qrcode
apt install sshpass
cp config.example.json config.json
# Edit config.json with credentials
python3 pos_briefing.py
```
## Known Issues / Notes
- `pct exec 147` (Uptime Kuma check) only works on a Proxmox host, not inside a CT — silently returns None.
- `printer_ip` direct access (`192.168.0.137`) may be unreachable from some CTs due to Proxmox bridge/firewall state; pinging first resolves intermittent ARP issues.
- FreshRSS direct IP (`192.168.0.157`) can be intermittently unreachable — `fresh.sethpc.xyz` (via Caddy) works as fallback but adds latency.
- yfinance ETH-USD occasionally fails with a NoneType error — non-fatal, other tickers still print.
## Gitea
- Repo: `https://git.sethpc.xyz/Seth/POS-Automation.git`
- Parent project: `https://git.sethpc.xyz/Seth/PrinterAutomation.git`