Skip to main content

Tauron eLicznik scrapper

Project description

Tauron eLicznik Scraper

This Python 3 package allows to read electric energy meter reading history from the Tauron eLicznik website.

Installation

The package can be installed using pip:

$ pip3 install elicznik

or alternatively:

$ pip3 install git@github.com:mlesniew/elicznik.git

Command line usage

With the package installed readings can be retrieved by simply running the elicznik command:

usage: elicznik [-h] [--format {table,csv}] [--api {chart,csv}] [--site SITE] username password [start_date] [end_date]

positional arguments:
  username              tauron-dystrybucja.pl user name
  password              tauron-dystrybucja.pl password
  start_date            Start date of date range to be retrieved, in ISO8601 format. If the end date is omitted, it's the only date for which measurements are retrieved.
  end_date              End date of date range to be retrieved, inclusive, in ISO8601 format. Can be omitted to only retrieve a single day's measurements.

options:
  -h, --help            show this help message and exit
  --format {table,csv}  Specify the output format
  --api {chart,csv}     Specify which Tauron API to use to get the measurements
  --site SITE           site identifier, must match '[0-9]+_[0-9]+_[0-9]+'
(venv) ~/src/elicznik (site) $ elicznik --help | cat
usage: elicznik [-h] [--format {table,csv}] [--api {chart,csv}] [--site SITE]
                username password [start_date] [end_date]

positional arguments:
  username              tauron-dystrybucja.pl user name
  password              tauron-dystrybucja.pl password
  start_date            Start date of date range to be retrieved, in ISO8601
                        format. If the end date is omitted, it's the only date
                        for which measurements are retrieved.
  end_date              End date of date range to be retrieved, inclusive, in
                        ISO8601 format. Can be omitted to only retrieve a
                        single day's measurements.

options:
  -h, --help            show this help message and exit
  --format {table,csv}  Specify the output format
  --api {chart,csv}     Specify which Tauron API to use to get the
                        measurements
  --site SITE           site identifier, must match '[0-9]+_[0-9]+_[0-9]+'

Example

$ elicznik freddy@example.com secretpassword 2022-07-20
timestamp              consumed    produced    net consumption    net production
-------------------  ----------  ----------  -----------------  ----------------
2022-07-20 00:00:00       0.133       0                  0.133             0
2022-07-20 01:00:00       0.127       0                  0.127             0
2022-07-20 02:00:00       0.119       0                  0.119             0
2022-07-20 03:00:00       0.119       0                  0.119             0
2022-07-20 04:00:00       0.124       0                  0.124             0
2022-07-20 05:00:00       0.02        0.226              0                 0.206
2022-07-20 06:00:00       0           1.058              0                 1.058
2022-07-20 07:00:00       0.086       1.607              0                 1.521
2022-07-20 08:00:00       0           2.09               0                 2.09
2022-07-20 09:00:00       0           2.302              0                 2.302
2022-07-20 10:00:00       0.223       2.427              0                 2.204
2022-07-20 11:00:00       0.031       2.723              0                 2.692
2022-07-20 12:00:00       0           2.818              0                 2.818
2022-07-20 13:00:00       0           2.735              0                 2.735
2022-07-20 14:00:00       0           2.413              0                 2.413
2022-07-20 15:00:00       0           1.953              0                 1.953
2022-07-20 16:00:00       0.316       1.407              0                 1.091
2022-07-20 17:00:00       0.183       1.2                0                 1.017
2022-07-20 18:00:00       0.001       0.843              0                 0.842
2022-07-20 19:00:00       0.446       0.274              0.172             0
2022-07-20 20:00:00       0.712       0                  0.712             0
2022-07-20 21:00:00       0.225       0                  0.225             0
2022-07-20 22:00:00       0.207       0                  0.207             0
2022-07-20 23:00:00       0.15        0                  0.15              0

API usage

import datetime
import elicznik

with elicznik.ELicznik("freddy@example.com", "secretpassword", "optional_site_identifier") as m:
    # date range
    print("July 2021")

    readings = m.get_readings(datetime.date(2021, 7, 1), datetime.date(2021, 7, 31))

    for timestamp, consumed, produced, consumed_net, produced_net in readings:
        print(timestamp, consumed, produced, consumed_net, produced_net)

    # single day
    print("Yesterday")

    yesterday = datetime.date.today() - datetime.timedelta(days=1)
    readings = m.get_readings(yesterday)

    for timestamp, consumed, produced, consumed_net, produced_net in readings:
        print(timestamp, consumed, produced, consumed_net, produced_net)

Notes on APIs and the --api command line switch

Tauron exposes two API endpoints for retrieving meter readings -- one for downloading CSV (and XLS) data, the other is a back-end supporting the charts in the Web UI. In theory, both endpoints are equivalent. They can be used to get exactly the same data. In practice, the endpoint for downloading CSV data seems more stable -- in contrast to the chart one, which changed a few times in the past. The CSV endpoint is also more robust and allows downloading more data with fewer requests.

This project supports fetching data from both. CSV is the default and recommended one, but it's possible to switch to the chart API endpoint in case of problems.

This can be done by adding --api=chart on the command line:

$ elicznik --api=chart freddy@example.com secretpassword 2021-07-10

Both APIs can also be used explicitly from code. The elicznik module defines two classes for that ELicznikChart and ELicznikCSV. ELicznik is just an alias for ELicznikCSV:

import elicznik

with elicznik.ELicznikChart("freddy@example.com", "secretpassword") as m:
    ...

TODO & bugs

  • Convert the dates to UTC and handle switches from and to DST properly
  • Make the dependency on tabulate optional

Similar projects

This project is based on the excellent tauron-elicznik-scrapper project by Michał Zaniewicz, but there are several other available out there.

Among the other similar eLicznik projects on GitHub there's one especially worth checking out: the Tauron AMIplus sensor -- it's an eLicznik Home Assistant integration.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

elicznik-2.4.0.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

elicznik-2.4.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file elicznik-2.4.0.tar.gz.

File metadata

  • Download URL: elicznik-2.4.0.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for elicznik-2.4.0.tar.gz
Algorithm Hash digest
SHA256 7728607934a43b25c7ab21ae2a489a4acae27001558b3e5921d3761923d6a952
MD5 1645605f3e22b9160c99f64ae8fc473d
BLAKE2b-256 54ba5c1e1dfef2ae8c97b824764ba339ccdd3b6965afad5e86bd1b1074c8bf3a

See more details on using hashes here.

Provenance

The following attestation bundles were made for elicznik-2.4.0.tar.gz:

Publisher: release.yml on mlesniew/elicznik

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file elicznik-2.4.0-py3-none-any.whl.

File metadata

  • Download URL: elicznik-2.4.0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for elicznik-2.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ccaa33fded18b2e28146ac0864ba5a1c4d4fc05027e668a1e26e204efdf82169
MD5 ed569dacaf90bfc15ad1b0d680569502
BLAKE2b-256 ebb6a0a9b17cbdb3b9d808db219a54b7b7af900a696221fb47b3cf9ec3343803

See more details on using hashes here.

Provenance

The following attestation bundles were made for elicznik-2.4.0-py3-none-any.whl:

Publisher: release.yml on mlesniew/elicznik

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page