Skip to main content

pycurenergia

Librería Python que lee las facturas en PDF de CurEnergía (electricidad y gas) y devuelve sus datos como objetos tipados. Todos los importes, kWh, m³ y porcentajes son decimal.Decimal.

Proyecto no oficial: no está afiliado, respaldado ni patrocinado por CurEnergía.

Licencia MIT.

Uso

from pycurenergia import check_consistency, parse_invoice_pdf

with open("factura.pdf", "rb") as f:
    invoice = parse_invoice_pdf(f.read())

print(invoice.supply, invoice.total)
print(check_consistency(invoice))  # [] si los importes cuadran
  • parse_invoice_pdf(data: bytes) lee un PDF; parse_invoice_text(text: str) parsea el texto ya extraído.
  • Errores (todos derivan de Exception; ninguno incluye texto de la factura en su mensaje):
    • InvoiceReadError: el PDF no se puede leer (dañado, vacío, cifrado con contraseña) o es demasiado grande (más de 10 MiB o de 20 páginas). Solo lo lanza parse_invoice_pdf; el error original de pypdf queda en __cause__.
    • UnsupportedInvoiceError: el documento no es una factura de luz o de gas, o es una factura rectificativa o de abono (no soportadas).
    • InvoiceParseError (con el atributo field): falta algún dato obligatorio o no tiene el formato esperado.
  • check_consistency(invoice) devuelve una lista de Problem; vacía si todo cuadra.
  • invoice.energy_price_kwh es el precio de la energía en €/kWh, o None si la factura no lo indica.
  • Lecturas del contador, como MeterReading (value, read_on, estimated), o None si la factura no las trae o no se entienden (nunca la invalidan): en luz, reading_p1, reading_p2 y reading_p3 (kWh); en gas, reading_m3 y previous_reading_m3 (m³).

Publicar

El workflow .github/workflows/lib-release.yml construye y publica en PyPI al subir una etiqueta pycurenergia-v* (por ejemplo pycurenergia-v0.1.0), usando trusted publishing (sin tokens).

Paso manual previo, una sola vez:

  1. Crear la cuenta en PyPI.
  2. En PyPI, añadir un pending trusted publisher con estos datos:
    • Proyecto: pycurenergia
    • Owner: yuuues
    • Repositorio: hacs-curenergia
    • Workflow: lib-release.yml
    • Entorno: pypi
  3. Crear el entorno pypi en los ajustes del repositorio de GitHub y configurar en él required reviewers (revisores obligatorios), de modo que subir una etiqueta por sí solo no publique nada sin una aprobación manual.
  4. Etiquetar y subir: git tag pycurenergia-v0.1.0 && git push origin pycurenergia-v0.1.0.

Metadata

Release files for pycurenergia 0.2.0

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

Source distribution (sdist)

Source distribution for pycurenergia 0.2.0
File Size Uploaded Provenance Actions
pycurenergia-0.2.0.tar.gz 52.8 kB With provenance Details for pycurenergia-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 69.3 kB

Release files / pycurenergia-0.2.0.tar.gz

Download URL pycurenergia-0.2.0.tar.gz
Size 52.8 kB
Tags Source
SHA-256 checksum
How to use checksums
23423a84373593bc2eeb65310e4c2efd4836057d028f451978f5be652821a1a6
BLAKE2b-256 checksum
How to use checksums
ca55c23b0fb1324559f80fb3eba6126997593c4035a84dde62866e7de37a8319
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 30, 2026.

Transparency log

Release files / pycurenergia-0.2.0-py3-none-any.whl

Download URL pycurenergia-0.2.0-py3-none-any.whl
Size 16.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0058604e34b475a9495ff0ca6d55b8ccf2cfbcbd337d43bc1101c8f26ce7d1f0
BLAKE2b-256 checksum
How to use checksums
ae79e774ded07f06b5ae2c4884d9a8685aaeb6ec97f67b8579a1db9eb758d561
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 30, 2026.

Transparency log

Security for pycurenergia 0.2.0

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pycurenergia-0.2.0.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 30, 2026.

Transparency log

A 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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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