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.
- 📧 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-8 -
Run with Docker Compose:
docker-compose up --build
The generated PDF will be available in the
./pdfsdirectory.
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 also manually specify a year and month:
python3 generate_pdf_report.py --year 2023 --month 12
- 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.
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