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

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.2
File Size Uploaded Provenance Actions
pycurenergia-0.2.2.tar.gz 55.7 kB With provenance Details for pycurenergia-0.2.2.tar.gz

Built distribution (wheel)

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

Total release size: 73.8 kB

Release files / pycurenergia-0.2.2.tar.gz

Download URL pycurenergia-0.2.2.tar.gz
Size 55.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c92b3f3dacffdbc27a408b2ebf9d656de1c254a66263000d8d7fcbf8b1f5d527
BLAKE2b-256 checksum
How to use checksums
f17669780bb3cafc578725f21a137a6b56603047b6e66ae59de67ca8c6931e77
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.2-py3-none-any.whl

Download URL pycurenergia-0.2.2-py3-none-any.whl
Size 18.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
14aea04d812a03a573fd59ff86ee2ca78c6e16d340117addc5224e3d0e56b5a1
BLAKE2b-256 checksum
How to use checksums
4f1e63900314e54dddd6cf80533814cbe45ca7267c4d3bffc692d89fdf2e7ba4
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.2

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