How to use
-
Install from pip
pip install cez-distribution-data-fetcher
-
Use
get_energy_measurements()functionfrom datetime import datetime, timedelta from cez_distribuce_data_fetcher import get_energy_measurements, offset today = datetime.now() yesterday = today - timedelta(days=1) pnd_device = "ELM 777777" pnd_password = "SECRET" pnd_user = "USERNAME" measurements = get_energy_measurements( from_time=offset(target_time=yesterday), pnd_device=pnd_device, pnd_password=pnd_password, pnd_user=pnd_user, to_time=offset(target_time=today), ) for date, from_grid, to_grid in measurements: print(f"date: {date} | from_grid: {from_grid} | to_grid: {to_grid}")
API
get_energy_measurements()
This function gets energy consumption and energy creation measurements from ČEZ Distribuce PND. It returns tuple with date, from grid and to grid measurements.
Following parameters are available:
| Parameter | Description |
|---|---|
| from_time | The starting time for fetching energy measurements. |
| pnd_device | The device identifier (eg ELM 777777). |
| pnd_password | The password for accessing the ČEZ Distribuce Portal. |
| pnd_user | The username for accessing the ČEZ Distribuce Portal. |
| pnd_url | The URL of the ČEZ Distribuce Portal. Default value is "https://dip.cezdistribuce.cz/irj/portal/?zpnd=". |
| to_time | The ending time for fetching energy measurements. |
| remote_connection | A boolean value indicating whether to use a remote connection for Selenium. Default value is False. |
| selenium_driver | The driver for Selenium. Default value is "chromedriver". |
| selenium_url | The URL for Selenium. Default value is "http://localhost:4444". |
To see more about how to configure Selenium, check out How to configure Selenium section.
offset()
Data availabe in the ČEZ Distribuce Portal are not live. They have 8-9 hours offset. This function is a helper utility to set this offset for provided from_time and to_time parameters.
How to configure Selenium
As ČEZ Distribuce Portal does not offer publicly accesible API, the Selenium framework is used to scrape the data. Selenium needs a browser to work (only Chromium is supported). There are two methods available:
-
Remote (recommended)
- Use docker-selenium to start Selenium browser in a container.
docker run --rm -it -p 4444:4444 -p 5900:5900 -p 7900:7900 --shm-size 2g selenium/standalone-chromium:latest
- Set
remote_connectiontoTrueand optionally updateselenium_url(defaults tohttp://localhost:4444).
- Use docker-selenium to start Selenium browser in a container.
-
Local
- Set
remote_connectiontoFalse(default value) and optionally updateselenium_driverpath (defaults tochromedriver). - Chromedriver binaries are available here.
- Set
Changelog 📝
See release notes.
How to contribute ✌
Every contribution is much appreciated.
Metadata
Release files for cez-distribuce-data-fetcher 0.0.2
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 |
|---|---|---|---|---|
| cez_distribuce_data_fetcher-0.0.2.tar.gz | 5.8 kB | Without provenance | Details for cez_distribuce_data_fetcher-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cez_distribuce_data_fetcher-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for cez_distribuce_data_fetcher-0.0.2-py3-none-any.whl |
Total release size: 12.8 kB
Release files / cez_distribuce_data_fetcher-0.0.2.tar.gz
| Download URL | cez_distribuce_data_fetcher-0.0.2.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1b4fec4b9634a522aff517d94d08cb786fdb7546b014957a866d7efe4465abfd
|
|
BLAKE2b-256 checksum How to use checksums |
3453f0939b876b681be2bbf8efdc8f155148f76566b151b7a133ddc66fdb99e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.0
|
Release files / cez_distribuce_data_fetcher-0.0.2-py3-none-any.whl
| Download URL | cez_distribuce_data_fetcher-0.0.2-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7032bcbee6c7c4963738e170701392f70c54f933114973a9053f1b8c3d0a1eae
|
|
BLAKE2b-256 checksum How to use checksums |
f9d9b321b728bda4da1c5e6c20f9885c1b0127b59a1e1565a95182c7760864b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.0
|
Security for cez-distribuce-data-fetcher 0.0.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.
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.