Report PDF emailing

This commit is contained in:
2026-06-18 21:07:34 +01:00
parent 7254719794
commit 364f4fe57e
16 changed files with 1428 additions and 16 deletions
+19
View File
@@ -9,6 +9,7 @@ Dockerised SwitchBot temperature monitor with:
- Configurable collection interval, defaulting to 15 minutes.
- Day-so-far temperature graph with high/low cards.
- Date-range reports with CSV export.
- PDF report generation and manual email sending through SMTP2GO.
## Quick Start
@@ -65,10 +66,28 @@ scripts/remove_zero_readings.sh --dry-run
Open `/reports` in the web app to generate a date-range summary. Use the
download button for a CSV export.
The same page can create and email a PDF report for the selected date range and
device filter. Configure SMTP2GO in `.env` before using it:
```sh
REPORT_SENDER_EMAIL=reports@example.com
REPORT_SENDER_NAME="SwitchBot Temps"
SMTP2GO_API_KEY=your-smtp2go-api-key
```
Generated PDFs and chart images are written under `REPORT_OUTPUT_DIR`, which
defaults to `/tmp/switchbot-reports` inside the web container.
Open `/report-settings` to manage scheduled report recipients and daily,
weekly, or monthly schedules. The `report-scheduler` service sends the previous
complete day, week, or month and records each period in the database before
sending so restarts do not duplicate emails.
## Services
- `db`: MySQL 8.4 with persistent `mysql_data` volume.
- `web`: Flask app served by Gunicorn on port 8000.
- `report-scheduler`: recurring PDF report sender.
- `collector`: SwitchBot polling loop.
## POC Script