Skip to main content

Async Python client for the Yuno Energy Heat API (Tridens Monetization)

Project description

pyyunoheat logo

An elegant, async-first Python client for the Yuno Energy Heat API.

PyPI version Supported Python versions License


pyyunoheat is an async Python client for the Yuno Energy Heat API (formerly Kaizen Energy), a communal heating scheme operating across apartment developments in Ireland.

The underlying API runs on the Tridens Monetization self-care platform. This library handles OAuth2/Keycloak authentication, dual-tier entity discovery, and telemetry data access with no browser automation or scraping required.

📖 Full Documentation: https://Irishsmurf.github.io/pyyunoheat/


Key Features

  • Async-First: Built on top of aiohttp for efficient, non-blocking network calls.
  • Dual-Tier Discovery: Automatically bootstraps the Tridens customer hierarchy (Person Account ➔ Payment Group ➔ Property Account ➔ Heat Meter Subscriptions) to retrieve entity identifiers.
  • Flexible Storage: Support for pluggable token stores, allowing you to easily inject secure database backends or Home Assistant configuration storage.
  • Consumption Telemetry: Fetch daily, weekly, or monthly usage reports with energy (kWh) and monetary cost (EUR) breakdowns.
  • Robust Exceptions: Standardized error classes extending YunoHeatError for clean error recovery.

Installation

Install via pip:

pip install pyyunoheat

Quick Start

1. Check your outstanding balance

import asyncio
from yunoheat import YunoHeatClient

async def main():
    async with await YunoHeatClient.login("you@example.com", "password") as client:
        balance = await client.get_open_bill_due()
        print(f"Outstanding balance: €{balance.open_bill_due:.2f}")

asyncio.run(main())

2. Daily usage report for the current month

from datetime import datetime, UTC
from yunoheat import YunoHeatClient

async def main():
    today = datetime.now(UTC)
    month_start = today.replace(day=1, hour=0, minute=0, second=0, microsecond=0)

    async with await YunoHeatClient.login("you@example.com", "password") as client:
        report = await client.get_usage_report(date_from=month_start, date_to=today)

    print(f"{'Date':<12} {'kWh':>6}  {'Cost':>7}")
    print("-" * 28)
    for r in report.readings:
        if r.kwh > 0:
            print(f"{r.date:%Y-%m-%d}  {r.kwh:6.1f}{r.eur:6.3f}")

asyncio.run(main())

Pluggable Token Storage

By default, the client persists authentication tokens to ~/.config/yunoheat/tokens.json. You can easily implement a custom TokenStore to save tokens elsewhere (e.g. database, secure vault, or Home Assistant configuration entry):

from pyyunoheat import YunoHeatClient, TokenStore, TokenData

class CustomTokenStore(TokenStore):
    async def load(self) -> TokenData | None:
        # Load tokens from database/store
        ...
    async def save(self, tokens: TokenData) -> None:
        # Save tokens to database/store
        ...

store = CustomTokenStore()
client = await YunoHeatClient.login(
    "you@example.com", 
    "password",
    token_store=store,
)

API Reference Overview

Below are the primary methods available on YunoHeatClient.

Factory Methods

Method Returns Description
login(username, password, *, token_store=None, session=None) YunoHeatClient Authenticate and create a new client session.
from_saved_tokens(username, password, *, token_store=None, session=None) YunoHeatClient Restore session from cached tokens (optionally supplying credentials for fallback refresh).

Client Methods

Method Returns Description
get_open_bill_due() OpenBillDue Fetch current outstanding balance (EUR).
get_usage_events(date_from, date_to, ...) UsageEventsResponse Fetch paginated raw meter readings.
get_usage_report(date_from, date_to, interval) UsageReport Retrieve aggregated kWh + EUR by day, week, month, etc.
get_person_customer() PersonCustomer Retrieve account and contact details.
get_invoices(date_from, date_to, ...) InvoicesResponse Retrieve list of historical invoices.
get_bill(bill_id) Bill Fetch a single bill by ID.
get_credit_balances() CreditBalancesResponse Fetch current prepaid credit balances.

Technical Notes

  • Sessions: Access tokens are valid for 30 minutes. The library automatically performs silent background refreshes when calling API methods.
  • External Session: Pass a shared aiohttp.ClientSession using the session keyword argument to reuse connections in integrations (e.g., Home Assistant).
  • Timestamps: All times are parsed to UTC. Monetary fields are returned in EUR. Energy usage is in kWh.

Contributing

Please see the Contributing Guide to set up a local development environment, run tests, and format code.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

pyyunoheat-0.2.3.tar.gz (162.3 kB view details)

Uploaded Source

Built Distribution

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

pyyunoheat-0.2.3-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file pyyunoheat-0.2.3.tar.gz.

File metadata

  • Download URL: pyyunoheat-0.2.3.tar.gz
  • Upload date:
  • Size: 162.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyyunoheat-0.2.3.tar.gz
Algorithm Hash digest
SHA256 dbad5f6884d4c276beb9fe0bc1318abe61689bdc2a21dacc1462831eddf11d54
MD5 510b17c0c53e9532e52d7e75e01f2bbf
BLAKE2b-256 6f30cacbf434d3f6d153456a5f4e197dbcec0f94e0ce71db2e3d2dae5e7a5ab3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyyunoheat-0.2.3.tar.gz:

Publisher: release.yml on Irishsmurf/pyyunoheat

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

File details

Details for the file pyyunoheat-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: pyyunoheat-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 19.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyyunoheat-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 03b828fe0f9e001d63e39b501af32eff7ea28fe7ffb911f307c14667b9774277
MD5 7bb33c115852e026380958299c0e9cae
BLAKE2b-256 53f5981c61e33efd635503f4cebce175eec09ec66891f59aa7e5b4018994e318

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyyunoheat-0.2.3-py3-none-any.whl:

Publisher: release.yml on Irishsmurf/pyyunoheat

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