Skip to main content

Python API client for Green Planet Energy electricity pricing data

Project description

Green Planet Energy API

PyPI version Python Support License: MIT

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 tomorrow
  • async close(): Close the HTTP session
  • Context manager support for automatic cleanup

Response Format

The API returns a dictionary with the following keys:

  • gpe_price_00 to gpe_price_23: Today's hourly prices (€/kWh)
  • gpe_price_00_tomorrow to gpe_price_23_tomorrow: Tomorrow's hourly prices (€/kWh)

Error Handling

The library raises the following exceptions:

  • GreenPlanetEnergyError: Base exception class
  • GreenPlanetEnergyConnectionError: Network/connection issues
  • GreenPlanetEnergyAPIError: 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:

  1. Check the Issues page
  2. Create a new issue if needed
  3. For Home Assistant related issues, please use the Home Assistant Core Issues with the green_planet_energy label

Disclaimer

This library is not officially associated with Green Planet Energy. It uses publicly available endpoints for retrieving pricing data.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

greenplanet_energy_api-0.1.4.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

greenplanet_energy_api-0.1.4-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file greenplanet_energy_api-0.1.4.tar.gz.

File metadata

  • Download URL: greenplanet_energy_api-0.1.4.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for greenplanet_energy_api-0.1.4.tar.gz
Algorithm Hash digest
SHA256 c765e277dadb9050907feb42bec0a1b1fb08760b3dd3abc547cd2716e4f52620
MD5 2a550a9a2d93ec8187fdc6df491669c5
BLAKE2b-256 7690f54bc2f5b7f17b1b7a166feca846c8db6ad526daa17b8910d2ece7d7c3cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for greenplanet_energy_api-0.1.4.tar.gz:

Publisher: publish.yml on petschni/greenplanet-energy-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file greenplanet_energy_api-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for greenplanet_energy_api-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3b3cb7bdcf127d453e0060ed14408b64595f69442a91c6e6aa5f8c40e2042457
MD5 605bf79fcec7e05af6109022a4325b46
BLAKE2b-256 53a3ad5e66d7cea55d18d4dcad8139bdd9e0ebe5b4e8ea4658f73249b6fc8e19

See more details on using hashes here.

Provenance

The following attestation bundles were made for greenplanet_energy_api-0.1.4-py3-none-any.whl:

Publisher: publish.yml on petschni/greenplanet-energy-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page