Skip to main content

hydropeak-opendata

Async Python client for Hydro-Québec's public peak events (pointes hivernales) open data. No account, no login — just the open data feed.

Extracted from the HydroPeak Home Assistant integration.

Data sources

Data comes from Hydro-Québec's open data portal.

During Quebec winters (December 1 to March 31), Hydro-Québec triggers peak demand events (événements de pointe) when electricity demand is high due to cold weather and operational constraints. Customers enrolled in participating offers (e.g. Winter Credit, Flex, Hilo) are asked to reduce their consumption during these events — typically in the morning (AM) or evening (PM) — and receive bill credits in return. The dataset is updated as events are scheduled, and covers both residential and business customers.

  • Peak events — scheduled peak demand events with start/end times, time period (AM/PM), duration, applicable offer, and customer sector.
  • Available offers — the list of programs available each season, with descriptions and validity dates (rate limited; intended for occasional use such as setup flows).

Usage

import aiohttp
from hydropeak_opendata import OpenDataClient

async def main():
    async with aiohttp.ClientSession() as session:
        client = OpenDataClient(session)

        offers = await client.get_available_offers()
        # ('Credit hivernal Residentiel (CPC-D)', 'Flex Residentiel (TPC-DPC)', ...)

        events = await client.get_events(offers[0])
        for event in events:
            print(event.start, event.end, event.period, event.duration)

Example output:

2026-01-22 06:00:00-05:00  2026-01-22 09:00:00-05:00  AM  3:00:00
2026-01-22 16:00:00-05:00  2026-01-22 20:00:00-05:00  PM  4:00:00

Check if a peak event is happening right now:

from datetime import datetime, timezone

events = await client.get_events()
now = datetime.now(timezone.utc)
active = [e for e in events if e.is_active(now)]

Notes:

  • Offer identifiers are the strings published in offresDisponibles, returned verbatim.
  • Hydro-Québec names the same offer differently across sources: the feed uses display names (Flex Residentiel (TPC-DPC)) while the offers and historical events datasets use bare codes (TPC-DPC). get_events(offer) matches on the normalized code, ignoring accents, letter case and extra whitespace, so TPC-DPC, tpc-dpc and Flex Résidentiel (TPC-DPC) all select the same events. normalize_offer_code() exposes that mapping (its known aliases live in OFFER_CODE_ALIASES in const.py), and PeakEvent.offer_code gives the code for an event.
  • get_offer_labels() maps each canonical offer identifier to a display label for UIs. Labels currently equal the identifiers; once Hydro-Québec publishes display titles in its open data, a library update will source labels from there without any change to the method's contract — persist the keys, show the values.
  • The client sends conditional requests (If-None-Match) and serves its cached parse on 304 Not Modified, so frequent polling is cheap for both sides. Concurrent refreshes are serialized on a lock.
  • All datetimes from the feed are timezone-aware. PeakEventsFeed.last_execution is naive (the feed publishes it without an offset).
  • Errors raise typed exceptions: OpenDataConnectionError, OpenDataRateLimitError, OpenDataResponseError, OpenDataParseError — all subclasses of OpenDataError. Failures never silently return empty data.

Development

pip install -e .[dev]
ruff check .
mypy
pytest

License

MIT

Metadata

Release files for hydropeak-opendata 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hydropeak-opendata 0.3.0
File Size Uploaded Provenance Actions
hydropeak_opendata-0.3.0.tar.gz 12.6 kB With provenance Details for hydropeak_opendata-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hydropeak-opendata 0.3.0
File Interpreter ABI Platform Actions
hydropeak_opendata-0.3.0-py3-none-any.whl Python 3 none any Details for hydropeak_opendata-0.3.0-py3-none-any.whl

Total release size: 23.4 kB

Release files / hydropeak_opendata-0.3.0.tar.gz

Download URL hydropeak_opendata-0.3.0.tar.gz
Size 12.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9c67ac35c4a292653238c6bac9089acb7c7ae9f266f990991e3b77b980a0a7d9
BLAKE2b-256 checksum
How to use checksums
bd0c379546546e86ff3c813ce36eea7825670d085cfb1fdc719dbcd291226ce9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 15, 2026.

Transparency log

Release files / hydropeak_opendata-0.3.0-py3-none-any.whl

Download URL hydropeak_opendata-0.3.0-py3-none-any.whl
Size 10.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e54353d7df427d4ba523ce99d7341aca61d45a75ac68415c28cd2d71f5d33d1
BLAKE2b-256 checksum
How to use checksums
f065929c8900dda58ee1df8717ea50684e87af0c00cb1e854d1315f4a1427c2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 15, 2026.

Transparency log

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

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for hydropeak_opendata-0.3.0.tar.gz

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 Nov 15, 2026.

Transparency log

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