Skip to main content

stromnetz-berlin-lastgang

An unofficial asynchronous Python client for historical electricity-consumption data from lastgang-online.stromnetz.berlin.

Features

  • Async authentication with automatic retry after portal session expiry.
  • Discovery of consumption locations, Zählpunkte, and time series.
  • Quarter-hour CSV exports explicitly requested and validated as kWh.
  • DST-safe timestamps, including both repeated autumn hours.
  • Missing provider intervals preserved as gaps.
  • Exact UTC-hour aggregation for statistics-oriented consumers.
  • Serialized 31-day exports with configurable request pacing.

The client deliberately uses the portal's CSV export. The chart endpoint rounds values and collapses the repeated hour at the end of daylight-saving time; CSV retains the original precision and all 100 quarter-hours. The client preserves quarter-hour readings and resolves DST by validated row order.

aggregate_hourly() aggregates exactly four consecutive UTC quarters and marks affected hours incomplete when provider intervals are absent.

Installation

python -m pip install stromnetz-berlin-lastgang

Example

from datetime import date

from aiohttp import ClientSession, CookieJar

from stromnetz_berlin_lastgang import Selection, StromnetzBerlinClient


async def read_day(username: str, password: str):
    async with ClientSession(cookie_jar=CookieJar(quote_cookie=False)) as session:
        client = StromnetzBerlinClient(session, username, password)
        location = (await client.get_consumption_locations())[0]
        point = (await client.get_metering_points(location))[0]
        series = point.time_series[0]
        selection = Selection(location, point, series)
        return await client.get_readings(
            selection,
            date(2026, 1, 1),
            date(2026, 1, 1),
        )

Reading.timestamp is the timezone-aware UTC interval end and Reading.value is a Decimal in kWh. Applications should let users choose a location, Zählpunkt, and compatible consumption series instead of silently selecting the first catalog entries as the short example does.

Development

Python 3.12 or newer is required.

python3 -m venv .venv
.venv/bin/python -m pip install --editable '.[test]'
.venv/bin/python -m pytest
.venv/bin/python -m ruff check src tests tools

Never add portal credentials, cookies, CSRF tokens, addresses, Zählpunkte, or raw consumption exports to fixtures, logs, or commits.

Home Assistant

The companion Home Assistant integration is maintained separately at ress/home-assistant-stromnetz-berlin-lastgang.

Security and privacy

The client accepts credentials only at runtime and never intentionally logs them. Applications remain responsible for protecting credential storage and consumption data.

See the architecture notes for the protocol and data model.

Released under the MIT License.

Metadata

Release files for stromnetz-berlin-lastgang 0.1.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 stromnetz-berlin-lastgang 0.1.1
File Size Uploaded
stromnetz_berlin_lastgang-0.1.1.tar.gz 25.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for stromnetz-berlin-lastgang 0.1.1
File Interpreter ABI Platform
stromnetz_berlin_lastgang-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 44.9 kB

Release files / stromnetz_berlin_lastgang-0.1.1.tar.gz

Download URL stromnetz_berlin_lastgang-0.1.1.tar.gz
Size 25.1 kB
Tags Source
SHA-256 checksum
How to use checksums
aff260f5c2b68379fa86463fe8659a6bd9148bd3374e40a9242db2b8ee371e74
BLAKE2b-256 checksum
How to use checksums
ebfa37246b154af9e00c8361e8c22a4e78339d7a6d5da7f589359c9dfd9a343a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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 Jul 19, 2026.

Transparency log

Release files / stromnetz_berlin_lastgang-0.1.1-py3-none-any.whl

Download URL stromnetz_berlin_lastgang-0.1.1-py3-none-any.whl
Size 19.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dd87f196c1c15c1761b2eb9807ebded0dc24b84cb3a6ef9f26a7eca83fa2ed9b
BLAKE2b-256 checksum
How to use checksums
df6c83e2ce24851ed6f390d1f79146bb9faa4a7abb964bbb13f9ecf46c7d43a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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 Jul 19, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

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