Skip to main content

Python ERSE

A Python package for Portuguese energy tariffs and ERSE information. Requires Python 3.11 or newer.

This follows ERSE information such as https://www.erse.pt/atividade/regulacao/tarifas-e-precos-eletricidade/#periodos-horarios

Installation

python -m pip install pyerse

Development

python3 -m venv .venv
source .venv/bin/activate
python -m pip install -e ".[dev]"
pre-commit install
pre-commit run --all-files
ruff check .
ruff format --check .
python -m pytest
python -m pytest --cov=pyerse --cov-branch --cov-report=term-missing --cov-fail-under=90
python -m build
python -m twine check --strict dist/*

The installed pre-commit hook runs Ruff lint fixes and formatting before each commit. Run pre-commit run --all-files to check the whole tracked repository; Ruff and its hooks use the same pinned version as CI. Hooks may edit files; review and stage those edits before committing. New files must be staged to be included in pre-commit checks.

Use ruff format . to format code. CI checks Python 3.11–3.14 and builds both a source distribution and a wheel, then tests the installed wheel outside the source tree. Package metadata and tool configuration live in pyproject.toml; VERSION remains the single source of the package version.

Regional time-of-use cycles

The standard mainland classes remain Ciclo_Diario and Ciclo_Semanal. Azores and Madeira each provide daily, optional daily, and weekly cycles:

Region Daily Optional daily Weekly
Azores Ciclo_Diario_Acores Ciclo_Diario_Opcional_Acores Ciclo_Semanal_Acores
Madeira Ciclo_Diario_Madeira Ciclo_Diario_Opcional_Madeira Ciclo_Semanal_Madeira
from datetime import datetime, timezone
from pyerse.ciclos import Ciclo_Semanal_Acores
from pyerse.comercializador import Plano, Opcao_Horaria

plan = Plano(6.9, Opcao_Horaria.TRI_HORARIA, Ciclo_Semanal_Acores)
tariff = plan.tarifa_actual(datetime.now(timezone.utc))

Regional cycles convert aware timestamps to Atlantic/Azores or Atlantic/Madeira. Naive timestamps are interpreted as regional local time; plan methods called without a timestamp use the region's clock. Returned regional interval bounds use the regional timezone for aware inputs. Weekly regional seasons run June–October and November–May; daily cycles use summer/winter legal-hour seasons.

Cycle names are also accepted, such as "Ciclo Semanal Açores" and "Ciclo Diário Opcional Madeira". Comercializador.opcao_ciclo() lists all supported names. These schedules come from ERSE's chart retrieved on 8 October 2026; see the extraction and audit. Prices and taxes are not regionalized by selecting a cycle.

Consumption VAT (January 2025 rules)

Consumption costs use mainland VAT: 6% on up to 200 kWh per 30 billed days (300 kWh with familia_numerosa=True) for power up to 6.9 kVA, and 23% on the remainder. Above 6.9 kVA, the entire consumption has 23% VAT. custo_kWh_final also adds electricity excise duty, taxed at 23%.

For multi-tariff plans, pass total_kwh as the combined consumption of all periods so the allowance is allocated proportionally. dias defaults to 30. Without total_kwh, the supplied tariff consumption is treated as the total; that default is appropriate for single-tariff plans.

cost = plan.custo_kWh_final(tariff, kwh_consumidos=98, total_kwh=350, dias=30)

The same keyword arguments are accepted by custo_kWh and custo_kWh_actual. Prices supplied with definir_custo_kWh exclude taxes. These methods apply current rules and do not calculate historical VAT. See ERSE's explanation.

Metadata

Release files for pyerse 0.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyerse 0.0.8
File Size Uploaded
pyerse-0.0.8.tar.gz 18.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyerse 0.0.8
File Interpreter ABI Platform
pyerse-0.0.8-py3-none-any.whl Python 3 none any Details

Total release size: 30.6 kB

Release files / pyerse-0.0.8.tar.gz

Download URL pyerse-0.0.8.tar.gz
Size 18.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f5a0a0911b84ac4689d513a958b7cdf59e00877237d661dc6577f11c5a46d024
BLAKE2b-256 checksum
How to use checksums
0450280ad4a3479e4f64880e827b54c3b8b1b9dd16021a9d18165f46ac1bfc61
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 8, 2026.

Transparency log

Release files / pyerse-0.0.8-py3-none-any.whl

Download URL pyerse-0.0.8-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2534d97c7d6e995aae33f4f351cd1b2e1ac90c01b7187b2d5f219abae05c17f6
BLAKE2b-256 checksum
How to use checksums
bbe20abb6916c79db8ccdd453041119cfaef688f2894cc2f83969eff3c12bf40
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 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.0.8 This release

2 release files

0.0.7

2 release files

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page