pvpcbill
Electrical billing simulation for small consumers in Spain using PVPC (electricity hourly prices).
It uses aiopvpc to download PVPC data, and the usual suspects (pandas & matplotlib) to deal with time-series data and plotting.
Install
Install from pypi with pip install pvpcbill, or clone it to run tests or anything else ;-)
Usage
From a jupyter notebook, just call the create_bill async helper to instantiate a new 'bill' object:
from pvpcbill import create_bill
# Creación directa de factura
factura = await create_bill(
path_csv_consumo="/path/to/elec_data/consumo_facturado18_02_2020-18_03_2020-R.csv",
potencia_contratada=4.6, # kW
tipo_peaje="NOC", # GEN / NOC / VHC
zona_impuestos="IVA", # IVA / IGIC / IPSI
)
print(factura)
** If using it from a non-async script,
use asyncio.run(create_bill(**params)) to run the async method.
Output:
FACTURA ELÉCTRICA:
--------------------------------------------------------------------------------
* CUPS ES0012345678901234SN
* Fecha inicio 17/02/2020
* Fecha final 18/03/2020
* Peaje de acceso 2.0DHA (Nocturna)
* Potencia contratada 4.60 kW
* Consumo periodo 472.93 kWh
* ¿Bono Social? No
* Equipo de medida 0.80 €
* Impuestos Península y Baleares (IVA)
* Días facturables 30
--------------------------------------------------------------------------------
- CÁLCULO DEL TÉRMINO FIJO POR POTENCIA CONTRATADA:
Peaje acceso potencia:
4.60 kW x 0.103944 €/kW/día x 30 días (366/2020) = 14.34 €
Comercialización:
4.60 kW x 0.008505 €/kW/día x 30 días (366/2020) = 1.17 €
==> Término fijo 15.51 €
- CÁLCULO DEL TÉRMINO VARIABLE POR ENERGÍA CONSUMIDA (TARIFA 2.0DHA):
Periodo 1: 0.111867 €/kWh ---> 19.02€(P1)
- Peaje de acceso: 170 kWh * 0.062012 €/kWh = 10.54€
- Coste de la energía: 170 kWh * 0.049855 €/kWh = 8.48€
Periodo 2: 0.045617 €/kWh ---> 13.82€(P2)
- Peaje de acceso: 303 kWh * 0.002215 €/kWh = 0.67€
- Coste de la energía: 303 kWh * 0.043402 €/kWh = 13.15€
==> Término de consumo 32.84 €
- IMPUESTO ELÉCTRICO:
5.11269632% x (15.51€ + 32.84€ = 48.35€) 2.47 €
==> Subtotal 50.82 €
- EQUIPO DE MEDIDA:
30 días x 0.026667 €/día 0.80 €
==> Importe total 51.62 €
- IVA O EQUIVALENTE:
21% de 51.62€ 10.84 €
################################################################################
# TOTAL FACTURA 62.46 €
################################################################################
Consumo medio diario en el periodo facturado: 2.08 €/día
But there is much more:
# Reparto de costes en la factura
p_imp = (
+ factura.data.termino_impuesto_electrico
+ factura.data.termino_equipo_medida
+ factura.data.termino_iva_total
) / factura.data.total
p_ener = factura.data.termino_variable_total / factura.data.total
p_pot = factura.data.termino_fijo_total / factura.data.total
print(
f"El coste de la factura se reparte en:\n "
f"* un {100*p_ener:.1f} % por energía consumida,\n "
f"* un {100*p_pot:.1f} % por potencia contratada,\n "
f"* un {100*p_imp:.1f} % por impuestos aplicados\n\n"
)
print(factura.data.to_json())
Output:
El coste de la factura se reparte en:
* un 52.6 % por energía consumida,
* un 24.8 % por potencia contratada,
* un 22.6 % por impuestos aplicados
{
"config": {
"tipo_peaje": "NOC",
"potencia_contratada": 4.6,
"con_bono_social": false,
"zona_impuestos": "IVA",
"alquiler_anual": 9.72,
"impuesto_electrico": 0.0511269632,
"cups": "ES0012345678901234SN"
},
"num_dias_factura": 30,
"start": "2020-02-17 00:00:00",
"end": "2020-03-18 00:00:00",
"periodos_fact": [
{
"billed_days": 30,
"year": 2020,
"termino_fijo_peaje_acceso": 14.34,
"termino_fijo_comercializacion": 1.17,
"termino_fijo_total": 15.51,
"energy_periods": [
{
"name": "P1",
"coste_peaje_acceso_tea": 10.544458468,
"coste_energia_tcu": 8.477372039999999,
"energia_total": 170.03900000000002
},
{
"name": "P2",
"coste_peaje_acceso_tea": 0.67090578,
"coste_energia_tcu": 13.146024950000003,
"energia_total": 302.892
}
]
}
],
"descuento_bono_social": 0.0,
"termino_impuesto_electrico": 2.47,
"termino_equipo_medida": 0.8,
"termino_iva_gen": 10.6722,
"termino_iva_medida": 0.168,
"termino_iva_total": 10.84,
"total": 62.46
}
Examples
Metadata
Release files for pvpcbill 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pvpcbill-1.0.0.tar.gz | 15.6 kB | Without provenance | Details for pvpcbill-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pvpcbill-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for pvpcbill-1.0.0-py3-none-any.whl |
Total release size: 31.5 kB
Release files / pvpcbill-1.0.0.tar.gz
| Download URL | pvpcbill-1.0.0.tar.gz |
|---|---|
| Size | 15.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e9285047c11953281ca30e276f66eab378bef92c0955ae25ec5ef5caaffcaf18
|
|
BLAKE2b-256 checksum How to use checksums |
764d2165ffadf985d4f48a3e516c374f5f68674fdbfc15d9d06decadc8cf2a09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.5 CPython/3.7.1 Linux/4.15.0-1028-gcp
|
Release files / pvpcbill-1.0.0-py3-none-any.whl
| Download URL | pvpcbill-1.0.0-py3-none-any.whl |
|---|---|
| Size | 15.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c72f5b9171951c5297132809bffd97a75e205d3400c83fee22cb3dd35f4664ae
|
|
BLAKE2b-256 checksum How to use checksums |
17d370d853aaf3a7e7ca2692fa9a8e177538fcd55ea828bce2390784d487de36
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.5 CPython/3.7.1 Linux/4.15.0-1028-gcp
|
Security for pvpcbill 1.0.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.