Metadata-Version: 2.5
Name: tariff-core
Version: 2026.10.1
Summary: Pure Python electricity, gas and water tariff modelling and evaluation.
Project-URL: Documentation, https://github.com/cabberley/tariff-core/blob/main/docs/schema.md
Project-URL: Issues, https://github.com/cabberley/tariff-core/issues
Project-URL: Source, https://github.com/cabberley/tariff-core
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: Implementation :: CPython
Requires-Python: >=3.13
Provides-Extra: dev
Requires-Dist: hatch-vcs>=0.5.0; extra == 'dev'
Requires-Dist: hatchling>=1.32.4; extra == 'dev'
Requires-Dist: holidays>=0.106; extra == 'dev'
Requires-Dist: hypothesis>=6.168.5; extra == 'dev'
Requires-Dist: jsonschema>=4.26.0; extra == 'dev'
Requires-Dist: mypy>=2.4.0; extra == 'dev'
Requires-Dist: pytest-cov>=7.1.0; extra == 'dev'
Requires-Dist: pytest>=9.1.1; extra == 'dev'
Requires-Dist: pyyaml>=6.0.2; extra == 'dev'
Requires-Dist: ruff>=0.16.10; extra == 'dev'
Provides-Extra: holidays
Requires-Dist: holidays>=0.106; extra == 'holidays'
Provides-Extra: yaml
Requires-Dist: pyyaml>=6.0.2; extra == 'yaml'
Description-Content-Type: text/markdown

# 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

```sh
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:

```python
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](docs/schema.md) for the data model and validation rules.
