This project provides a comprehensive system for collecting, analyzing, and visualizing electricity tariffs and spot prices. It consists of three main components:
- Data Collection & Analysis System
- REST API Service
- WordPress Integration Plugin
├── api/ # API client implementations
├── db/ # Database models and operations
├── electricity/ # fastapi api used by wordpress plugin to read data
├── strom-tarif-plugin/ # WordPress plugin
└── tests/ # Test suite
- Fetches spot prices from multiple sources:
- Awattar API (
awattar/client.py
) - SmartEnergy API (
smartenergy/client.py
)
- Awattar API (
- Automated data updates with gap detection
- Handles API failures gracefully
- Crawls electricity provider websites (
get_tarife.py
) - Uses LLM-based analysis for tariff extraction (
llm_analyze.py
) - Supports multiple LLM providers:
- OpenRouter (Llama, Gemini)
- Groq
- Local deployment options
- SQLite database with SQLAlchemy ORM
- Models for:
- Spot prices (
spot_prices.py
) - Daily statistics
- Spot prices (
- Automated database maintenance
- SVG chart generation (
gen_chartsvg.py
)- Daily and weekly price trends
- Min/max price indicators
- Responsive design
- Matplotlib-based charts (
print_chart.py
) - Support for multiple time ranges
The strom-tarif-plugin
provides:
- Shortcodes for tariff display:
- Table layout
- Card layout
- Price chart integration
- Responsive design
- API integration with caching
- Custom styling options
The electricity API
provides:
- Serving for retrieving Spotprice and Tarif data.
- Bearer TOKEN Security
- serving eg
- tarif table in json
- spotprice chart as svg or png
The system uses a central config.py
for:
- Database settings
- API credentials
- LLM configurations
- Crawling settings
- Query templates
- Python 3.8+
- SQLite
- WordPress 5.0+ (for plugin)
# Create virtual environment
python -m venv venv
source venv/bin/activate
# Install requirements
pip install -r requirements.txt
# Initialize database
python -m db.models.spot_prices
# Test data collection
python get_tarife.py
- Copy
strom-tarif-plugin
towp-content/plugins/
- Activate plugin in WordPress admin
- Use shortcodes:
[tarifliste]
- Display tariff comparison[diagrammxyz]
- Display price charts
The system serves data via REST API:
/api/v1/tarifliste
- Current tariff data/api/v1/spotprices
- Spot price data and charts
from get_tarife import fetch_and_convert_csv_to_dict
tariffs = fetch_and_convert_csv_to_dict()
from gen_chartsvg import gen_chart_svg
gen_chart_svg(startday=date.today(), endday=date.today() + timedelta(days=1))
// Display tariff table
[tarifliste rows="10" layout="table"]
// Display price chart
[diagrammxyz type="bar" title="Daily Prices"]
- Fork the repository
- Create a feature branch
- Submit a pull request
This project is licensed under the MIT License.