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

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.1
File Size Uploaded Provenance Actions
pycurenergia-0.2.1.tar.gz 52.7 kB With provenance Details for pycurenergia-0.2.1.tar.gz

Built distribution (wheel)

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

Total release size: 69.2 kB

Release files / pycurenergia-0.2.1.tar.gz

Download URL pycurenergia-0.2.1.tar.gz
Size 52.7 kB
Tags Source
SHA-256 checksum
How to use checksums
06492047117f370016216d6b65da0f8c813d5e2613b1a24c4cde9355a6790a65
BLAKE2b-256 checksum
How to use checksums
2d52e24ab779dff3884b2d8e27b64408aed02111022cdca6a47af12a5f66f2d2
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 Nov 13, 2026.

Transparency log

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

Download URL pycurenergia-0.2.1-py3-none-any.whl
Size 16.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
85101aa17e56987ec3cd718e67a2d4bc0dbc4fc7892849d5c524f3492487776b
BLAKE2b-256 checksum
How to use checksums
86f038473bcdc31dce8fb2b47fbca16e32d5848578e25326b39ae7c19091eaaa
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 Nov 13, 2026.

Transparency log

Security for pycurenergia 0.2.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

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

Select from 2 files

Attestation for pycurenergia-0.2.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 Nov 13, 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