Python API client for Green Planet Energy electricity pricing data
Project description
Green Planet Energy API
A Python API client for retrieving electricity pricing data from Green Planet Energy, a German renewable energy provider.
This library is primarily designed for use with Home Assistant but can be used in any Python project that needs access to Green Planet Energy pricing data.
Features
- Async/await support
- Fetch hourly electricity prices for today and tomorrow
- Handles German decimal formatting
- Comprehensive error handling
- Type hints for better IDE support
- Lightweight with minimal dependencies
Installation
pip install greenplanet-energy-api
Quick Start
import asyncio
from greenplanet_energy_api import GreenPlanetEnergyAPI
async def main():
async with GreenPlanetEnergyAPI() as api:
# Get electricity prices for today and tomorrow
prices = await api.get_electricity_prices()
# Access today's prices
for hour in range(24):
price_key = f"gpe_price_{hour:02d}"
if price_key in prices:
print(f"Hour {hour:02d}: {prices[price_key]} €/kWh")
# Access tomorrow's prices
for hour in range(24):
price_key = f"gpe_price_{hour:02d}_tomorrow"
if price_key in prices:
print(f"Tomorrow Hour {hour:02d}: {prices[price_key]} €/kWh")
if __name__ == "__main__":
asyncio.run(main())
API Reference
GreenPlanetEnergyAPI
The main API client class.
Methods
async get_electricity_prices() -> dict[str, float]: Fetch electricity prices for today and tomorrowasync close(): Close the HTTP session- Context manager support for automatic cleanup
Response Format
The API returns a dictionary with the following keys:
gpe_price_00togpe_price_23: Today's hourly prices (€/kWh)gpe_price_00_tomorrowtogpe_price_23_tomorrow: Tomorrow's hourly prices (€/kWh)
Error Handling
The library raises the following exceptions:
GreenPlanetEnergyError: Base exception classGreenPlanetEnergyConnectionError: Network/connection issuesGreenPlanetEnergyAPIError: API-specific errors
Development
Setup
git clone https://github.com/petschni/greenplanet-energy-api.git
cd greenplanet-energy-api
pip install -e ".[dev]"
Running Tests
pytest
Code Quality
black src tests
ruff check src tests
mypy src
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue if needed
- For Home Assistant related issues, please use the Home Assistant Core Issues with the
green_planet_energylabel
Disclaimer
This library is not officially associated with Green Planet Energy. It uses publicly available endpoints for retrieving pricing data.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file greenplanet_energy_api-0.1.5.tar.gz.
File metadata
- Download URL: greenplanet_energy_api-0.1.5.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d001c9d5d90e6cd8d930fb1458078f219a98c7cb23ecaceacad30aff5aa07c90
|
|
| MD5 |
894cff79c0e9ac3484ca9d273c1d0c98
|
|
| BLAKE2b-256 |
a122d7b7f7f78782e887ae1ecf4f1a8611d5613f031339231348183589e1100f
|
Provenance
The following attestation bundles were made for greenplanet_energy_api-0.1.5.tar.gz:
Publisher:
publish.yml on petschni/greenplanet-energy-api
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
greenplanet_energy_api-0.1.5.tar.gz -
Subject digest:
d001c9d5d90e6cd8d930fb1458078f219a98c7cb23ecaceacad30aff5aa07c90 - Sigstore transparency entry: 928664061
- Sigstore integration time:
-
Permalink:
petschni/greenplanet-energy-api@d92ef48e72e35cac7d37546a09d900ca1c2c7951 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/petschni
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d92ef48e72e35cac7d37546a09d900ca1c2c7951 -
Trigger Event:
push
-
Statement type:
File details
Details for the file greenplanet_energy_api-0.1.5-py3-none-any.whl.
File metadata
- Download URL: greenplanet_energy_api-0.1.5-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f04797cb5ca7056c7aca9ffa29717f324ca2ed122414127775b1445ae087d62f
|
|
| MD5 |
43dc3fad55ad53dd65560196c94ab510
|
|
| BLAKE2b-256 |
53ef541bb61cb3372558e115ea0435ef27f01fac8beeb15f98954ac1612abf5a
|
Provenance
The following attestation bundles were made for greenplanet_energy_api-0.1.5-py3-none-any.whl:
Publisher:
publish.yml on petschni/greenplanet-energy-api
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
greenplanet_energy_api-0.1.5-py3-none-any.whl -
Subject digest:
f04797cb5ca7056c7aca9ffa29717f324ca2ed122414127775b1445ae087d62f - Sigstore transparency entry: 928664083
- Sigstore integration time:
-
Permalink:
petschni/greenplanet-energy-api@d92ef48e72e35cac7d37546a09d900ca1c2c7951 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/petschni
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d92ef48e72e35cac7d37546a09d900ca1c2c7951 -
Trigger Event:
push
-
Statement type: