This project automates the generation of PDF charging reports from your EVCC instance. It fetches charging session data for the previous month, formats it into a PDF report, and optionally sends it via email.
This project is designed primarily as a Dockerized solution.
- 📊 Automated Reporting: Fetches charging sessions from the EVCC API for the previous month.
- 📄 PDF Generation: Creates formatted PDF reports including session details, total energy, and total cost.
- 🧩 Configurable Columns: Pick which fields appear in the table (start/end time, vehicle, loadpoint, odometer, meter readings, energy, duration, price).
- 🔍 Filtering: Limit a report to specific vehicles or loadpoints, useful for per-car reports.
- 📧 Email Delivery: Automatically emails the generated PDF to a specified recipient.
- 🐳 Docker Support: Simple deployment using Docker Compose.
- 🌍 Localization: Supports locale settings for date and number formatting.
-
Clone the repository:
git clone https://github.com/MaizeShark/evcc-to-PDF cd evcc-to-PDF -
Configure the environment: Copy the example configuration file and edit it with your details.
cp .env.example .env nano .env
Configuration Variables:
Variable Description Default EVCC_URLURL of your EVCC instance http://localhost:7070EVCC_PASSWORDPassword for EVCC (if authentication is enabled) (empty) SMTP_SERVERSMTP Server address (Required for email) SMTP_PORTSMTP Server port 587SENDER_EMAILEmail address sending the report (Required for email) SENDER_PASSWORDPassword for the sender email (Required for email) RECIPIENT_EMAILRecipient email address (Required for email) SENDER_NAMEName displayed in the PDF header John DoeSENDER_STREETStreet address in PDF header Sample Street 123SENDER_CITYCity/Zip in PDF header 12345 Sample CityLOCALELocale for date/number formatting de_DE.UTF-8PDF_COLUMNSComma-separated column IDs to include in the table (see Columns) start_time,end_time,loadpoint,vehicle,energy,duration,priceFILTER_VEHICLESComma-separated vehicle whitelist (empty = all). (empty) FILTER_LOADPOINTSComma-separated loadpoint whitelist (empty = all). (empty) -
Run with Docker Compose:
docker-compose up --build
The generated PDF will be available in the
./outputdirectory.
If you wish to run the script without Docker (e.g., for development):
-
Install dependencies:
python3 -m venv venv source venv/bin/activate pip install -r requirements.txtNote:
WeasyPrintrequires system dependencies (likelibpango-1.0-0) which are automatically handled in the Docker image. -
Run the script: Ensure your environment variables are set (or use a
.envloader) and run:python3 generate_pdf_report.py
You can control which columns appear in the PDF and limit the report to specific vehicles or loadpoints. Configuration can be supplied either via environment variables or CLI flags. CLI flags override the corresponding env var.
| ID | Description |
|---|---|
start_time |
Session start (RFC3339 → formatted as YYYY-MM-DD HH:MM) |
end_time |
Session end |
loadpoint |
Loadpoint name (e.g. Garage) |
loadpoint_idx |
Loadpoint index (1-based, from evcc's id field) |
vehicle |
Vehicle name |
odometer |
Odometer reading in km (vehicle-side, see caveat below) |
meter_start |
Meter reading at start of session (kWh, from the charger) |
meter_end |
Meter reading at end of session (kWh, from the charger) |
energy |
Charged energy (kWh) |
duration |
Charging duration (computed from start/end) |
price |
Price (€) |
Odometer caveat:
odometercomes from the vehicle's own API and is only populated for vehicles that report it. A vehicle configured in evcc as "Generic vehicle (without API)" will leave this column blank. See the evcc vehicle docs if yours is compatible.
The report is rendered on A4 portrait by default. If the selected columns would be too wide for portrait, the report automatically switches to A4 landscape and logs an INFO message. If even landscape isn't wide enough, a WARNING is logged but the PDF is still generated (so the email still goes out)!
Default behaviour (unchanged if you set no new variables):
python3 generate_pdf_report.pyOnly Nissan Leaf sessions, with odometer and meter readings:
PDF_COLUMNS=start_time,vehicle,odometer,meter_start,meter_end,energy \
FILTER_VEHICLES="Nissan Leaf" \
python3 generate_pdf_report.pyCLI flags (override env per run, names with spaces should be quoted):
python3 generate_pdf_report.py \
--columns start_time,vehicle,energy,duration \
--vehicle "Nissan Leaf" \
--vehicle "Tesla Model 3" \
--loadpoint Garage \
--year 2026 \
--month 4--vehicle and --loadpoint are repeatable and also accept comma-separated lists. Unknown column IDs cause the script to exit with code 2 and print the list of valid IDs.
- Templates: The script uses
template_de.html(ortemplate_en.html) by default depending on locale. You can edit these files to change the PDF layout. The<thead>and<tbody>are driven by the configured columns, changePDF_COLUMNSrather than editing the template if you only want to reorder/hide columns.
You can set up this tool to run automatically on the 1st of every month to generate the report for the previous month.
Run the included setup script to automatically add a cron job to your system:
./setup_cron.shThis will configure a job to run at 02:00 AM on the 1st of every month.
-
Open your crontab:
crontab -e
-
Add the following line (adjust the path to your installation):
0 2 1 * * cd /path/to/evcc-to-PDF && docker-compose up >> cron.log 2>&1