Skip to main content

ekzexport

This is an exporter for EKZ data provided on the http://my.ekz.ch customer portal written in Python. It uses your credentials to login and then calls the EKZ API the website uses to directly export the data. Data can be synced either to a CSV file or InfluxDB.

Installing

Get it from PyPI:

$ python -m pip install ekzexport

You can then use the ekzexport CLI.

Example Usage

To authenticate, you can either put your credentials into a JSON file ekzexport.json in your home directory:

{
  "user": "myusername",
  "password": "mypassword"
}

If you're using a TOTP token via an authenticator app, you can create a dedicated token to use. Click on the "can't scan QR code" link to get the code to manually enter and put it in the JSON file so it looks similar to this:

{
  "user": "myusername",
  "password": "mypassword",
  "otp": "AAAA BBBB CCCC DDDD EEEE FFFF GGGG HHHH"
}

Instead of the JSON config file, you can also use the --user and --password (and --otp) CLI options directly. The following examples use a JSON file.

First, list your contracts to find the installation ID of interest:

$ ekzexport overview
                                        Contracts                                        
                  ╷                                      ╷              ╷
  Installation ID │ Address                              │ Move-in Date │ Move-out Date 
╺━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━╸
  123             │ Somestreet 1, 8000 Someplace         │ 2010-01-01   │ 2020-01-01
  456             │ Some Other Street 2, 8001 Otherplace │ 2020-01-02   │
                  ╵                                      ╵              ╵

With the installation ID, we can then figure out what kind of data is available for your account:

$ ekzexport installation 456 properties
                 Properties                 
                 ╷            ╷
  Property       │ From       │ Until      
╺━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━┿━━━━━━━━━━━━╸
  CONTRACT       │ 2020-01-02 │ 2024-05-01
  SMART_METER    │ 2020-01-02 │ 2024-05-01
  VERB_15MIN     │ 2020-01-02 │ 2024-05-01
  VERB_TAG_EDM   │ 2020-01-02 │ 2024-05-01
  VERB_TAG_METER │ 2020-01-02 │ 2024-05-01
                 ╵            ╵

If you do not see any entry for 15 minute values, you likely have to enable granular data on myEKZ first.

You can print consumption data to get an idea what is available:

$ ekzexport installation 456 data --type PK_VERB_TAG_EDM --from 2024-04-01 --to 2024-04-02 show
                 Consumption Data                 
                      ╷        ╷        ╷
  Time                │ kWh    │ Tariff │ Status 
╺━━━━━━━━━━━━━━━━━━━━━┿━━━━━━━━┿━━━━━━━━┿━━━━━━━━╸
  2024-04-01 00:00:00 │ 12.123 │ NT     │ VALID
  2024-04-01 00:00:00 │ 10.123 │ HT     │ VALID
  2024-04-02 00:00:00 │ 12.678 │ NT     │ VALID
  2024-04-02 00:00:00 │ 8.678  │ HT     │ VALID
                      ╵        ╵        ╵

But the more interesting use-case is to export data. Available exporters are:

  • csv to sync data to a CSV file in the same format as myEKZ offers
  • influxdb to sync data to an InfluxDB 2.x server

The CLI's help command will provide further detail on the exporter-specific options, for example:

$ ekzexport installation 456 data export csv --help

Running Exports Periodically

If you're using a Linux distribution using systemd, you can create a service and trigger to run the export periodically. To do so, create /etc/systemd/system/ekzexport.service with something like:

[Unit]
Description=Pull EKZ data

[Service]
Type=oneshot
ExecStart=/path/to/ekzexport/venv/bin/ekzexport installation 456 data export csv -f data.csv
WorkingDirectory=/path/to/ekzexport

This example assumes you created a Python virtualenv to install ekzexport in (which keeps the dependencies local in the venv). You can also set up an OnFailure hook to send emails in case the export fails.

A corresponding timer can look something like this in /etc/systemd/system/ekzexport.timer:

[Unit]
Description=Run ekzexport once a day

[Timer]
OnCalendar=*-*-* 04:00:00
RandomizedDelaySec=30m
Persistent=true

[Install]
WantedBy=timers.target

Please keep the randomized delay to avoid myEKZ getting a flood of requests at exactly 04:00 every night. Remember to enable and start the timer.

LEG Data

If you are a manager of an LEG, you can also get data about the LEGs you manage. For example, the list the LEGs your account is managing, run:

$ ekzexport legs
                                   Legs                                    
                                   ╷                                       
  LEG ID                           │ Leg Name                              
╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸
  0123456789ABCDEF123456789ABCDEF1 │ My awesome LEG number 1              
  0123456789ABCDEF123456789ABCDEF2 │ My awesome LEG number 2                

See help output for more LEG commands.

Metadata

Release files for ekzexport 0.3.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 ekzexport 0.3.1
File Size Uploaded Provenance Actions
ekzexport-0.3.1.tar.gz 36.2 kB Without provenance Details for ekzexport-0.3.1.tar.gz

Built distribution (wheel)

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

Total release size: 60.4 kB

Release files / ekzexport-0.3.1.tar.gz

Download URL ekzexport-0.3.1.tar.gz
Size 36.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e64966a55bd4065a28d53b30fc8d9043b9ee8165ef2bcb634a658b09a5f59e85
BLAKE2b-256 checksum
How to use checksums
f229d0f63f2858ea419750846d484d615475f8d6e9f4ca3dabe28e43fe8c0d32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / ekzexport-0.3.1-py3-none-any.whl

Download URL ekzexport-0.3.1-py3-none-any.whl
Size 24.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3322eb098cef567b0b57e38098d1b04bff5d5791f23dfc0c8342fc7c8d79c9c9
BLAKE2b-256 checksum
How to use checksums
11159b2df041161612bce3ce5538736d5330f7aa04356eee71f0c1d63357d839
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for ekzexport 0.3.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.

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.

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