tariff-core
tariff-core is a pure Python library for modelling electricity, gas and water tariffs. It parses and validates tariff plans, calculates rates and bills, and works offline without Home Assistant or other application-specific dependencies.
Install
python -m pip install tariff-core
YAML support is optional: install tariff-core[yaml] to parse YAML documents.
Example
This example loads the Origin Ergon fixture, prints its current tariff rate, then bills one day of hourly usage:
from datetime import datetime, time, timedelta
from decimal import Decimal
from importlib.resources import files
from zoneinfo import ZoneInfo
from tariff_core import BillingPeriod, Interval, bill, parse_plan, rate_at
plan = parse_plan(files("tariff_core").joinpath("data", "origin_ergon.json").read_text())
zone = ZoneInfo("Australia/Brisbane")
now = datetime.now(zone)
start = now.replace(hour=0, minute=0, second=0, microsecond=0)
rate = rate_at(plan, now)
print(f"Current rate: {rate.rate} per kWh ({rate.period_label})")
intervals = [
Interval(start + timedelta(hours=hour), timedelta(hours=1), "general", "kWh", Decimal("1"))
for hour in range(1, 25)
]
result = bill(
plan,
intervals,
period=BillingPeriod(start, start + timedelta(days=1)),
)
print(f"One-day total: {result.total_rounded}")
See the tariff plan schema for the data model and validation rules.
Metadata
Release files for tariff-core 2026.10.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| tariff_core-2026.10.1.tar.gz | 66.0 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tariff_core-2026.10.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 109.1 kB
Release files / tariff_core-2026.10.1.tar.gz
| Download URL | tariff_core-2026.10.1.tar.gz |
|---|---|
| Size | 66.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
99185fcaf6fad6f1c7d56395011758a472151a80c808c1ef2d7945baca2abbe0
|
|
BLAKE2b-256 checksum How to use checksums |
d56f145e37731228c69672a6902f7f66c0fbeca3d663771a47446faaa528967c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.
Transparency logRelease files / tariff_core-2026.10.1-py3-none-any.whl
| Download URL | tariff_core-2026.10.1-py3-none-any.whl |
|---|---|
| Size | 43.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e5532c7ca8de3c1ab1bda9f990a91a68eabccd1bcbe39a0fe6d69a2f5bfc6591
|
|
BLAKE2b-256 checksum How to use checksums |
43006ac5a2c0bb747eb886629c2b88951b81b197c3c117c0577ebb156e01527c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.
Transparency logSecurity for tariff-core 2026.10.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for tariff_core-2026.10.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.