Skip to main content

myelectricaldatapy

Fetch Enedis Linky data from myelectricaldata.fr (enedisgateway.tech)

Install

Use the PIP package manager

$ pip install myelectricaldatapy

Or manually download and install the last version from github

$ git clone https://github.com/cyr-ius/myelectricaldatapy.git
$ pip install .

Public API

from myelectricaldatapy import Enedis, EnedisByPDL, EnedisException
  • Enedis : thin async client, one method per myelectricaldata.fr endpoint.
  • EnedisByPDL : higher level helper that aggregates every piece of information for a single delivery point (PDL) and computes analytics.
  • EnedisException : base exception. Every library error (HttpRequestError, LimitReached, PayloadError, TimeoutExceededError, AnalyticsError) derives from it.

All payloads are validated and returned as pydantic models (Contract, UsagePoint, DataCollect, TempoDays, Prices, ...).

Enedis

Enedis(token: str, session: ClientSession | None = None, timeout: int = 30)
Method Description
async_fetch_datas(service, pdl, start=None, end=None) Raw call to any service
async_valid_access(pdl) / async_has_access(pdl) Access / quota status
async_get_contract(pdl) / async_get_contracts(pdl) Contract(s)
async_get_address(pdl) / async_get_addresses(pdl) Address(es)
async_get_identity(pdl) Identity
async_get_daily_consumption(pdl, start, end) Daily consumption (max 1095 days)
async_get_daily_production(pdl, start, end) Daily production (max 1095 days)
async_get_details_consumption(pdl, start, end) Load curve consumption (max 7 days)
async_get_details_production(pdl, start, end) Load curve production (max 7 days)
async_get_max_power(pdl, start, end) Max power
async_get_ecowatt(start=None, end=None) Ecowatt forecast
async_get_tempo(start=None, end=None) Tempo day colors on a range
async_get_tempo_days() Tempo calendar
async_get_tempo_prices() Tempo prices
async_has_offpeak(pdl) / async_check_offpeak(pdl, start) Off-peak helpers
async_close() Close the aiohttp session

EnedisByPDL

EnedisByPDL(
    pdl: str,
    token: str,
    subscription: str = "standard",   # "standard" | "hphc" | "tempo"
    session: ClientSession | None = None,
    timeout: int = 30,
    timezone: tzinfo | None = None,
)

Workflow:

  1. Optionally declare what you want to collect with set_data_fetch(...), set_ecowatt_subscription(True) and set_maxpower_subscription(True).
  2. Call await async_update() (or async_update(force_refresh=True)).
  3. Read the aggregated results.
Member Description
set_data_fetch(service, start=None, end=None, intervals=None, prices=None, cum_value=None, cum_price=None) Register a collect (service is one of DAILY_CONSUM, DAILY_PROD, DETAIL_CONSUM, DETAIL_PROD)
set_ecowatt_subscription(activate=False) Enable Ecowatt retrieval
set_maxpower_subscription(activate=False) Enable max power retrieval
async_update(force_refresh=False) Refresh access, contract, address, tempo, ecowatt, collects
_async_fetch_data() Refresh only the registered collects
stats dict keyed by mode ("consumption" / "production") with the computed analytics
access, contract, address, ecowatt, max_power, tempo, tempo_days, tempo_prices Last fetched models
is_connected, has_intervals, has_tempo_subscription, has_offpeak_hours_subscription, has_standard_subscription, has_ecowatt_subscription, has_maxpower_subscription Boolean state
ecowatt_day, tempo_day, consum_prices, prod_prices Convenience accessors for today
async_close() Close the aiohttp session

Timezone

Enedis/RTE APIs return naive timestamps that represent local wall-clock time. This library needs to know which timezone that is in order to compute things like off-peak hours or hourly statistics correctly.

By default it falls back to the timezone of the host machine running the code (/etc/localtime), but that has no reason to match the timezone your application is actually configured for (e.g. Home Assistant's hass.config.time_zone). Pass it explicitly to avoid a fixed-offset shift in the reported times:

api = EnedisByPDL(pdl=PDL, token=TOKEN, timezone=ZoneInfo("Europe/Paris"))

Alternatively, set it once globally for every instance:

from myelectricaldatapy import set_local_timezone

set_local_timezone(ZoneInfo("Europe/Paris"))

Get started

import asyncio
from datetime import timedelta

from myelectricaldatapy import DETAIL_CONSUM, EnedisByPDL, EnedisException
from myelectricaldatapy.tz import local_now

TOKEN = "012345"
PDL = "012345012345"


async def main() -> None:
    api = EnedisByPDL(pdl=PDL, token=TOKEN)

    try:
        # Off-peak intervals and per-interval prices are optional.
        api.set_data_fetch(
            DETAIL_CONSUM,
            start=local_now() - timedelta(days=7),
            end=local_now(),
            intervals=[("08:00", "12:00")],
            prices={"standard": {"price": 0.18}, "offpeak": {"price": 0.1641}},
        )
        await api.async_update()

        print(api.contract)
        print(api.address)
        print(api.stats["consumption"])
    except EnedisException as error:
        print(error)
    finally:
        await api.async_close()


asyncio.run(main())

Have a look at example.py for a more complete overview.

Metadata

Release files for myelectricaldatapy 2.5.3

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

Source distribution (sdist)

Source distribution for myelectricaldatapy 2.5.3
File Size Uploaded Provenance Actions
myelectricaldatapy-2.5.3.tar.gz 140.7 kB With provenance Details for myelectricaldatapy-2.5.3.tar.gz

Built distribution (wheel)

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

Total release size: 176.6 kB

Release files / myelectricaldatapy-2.5.3.tar.gz

Download URL myelectricaldatapy-2.5.3.tar.gz
Size 140.7 kB
Tags Source
SHA-256 checksum
How to use checksums
02acad6bbe215df83b4617aefd1df7c183b22a9e09961d317489493a4aee08b2
BLAKE2b-256 checksum
How to use checksums
88d2c9d7097826e216856513eeb852458028840e08e11683163a52369d14c82f
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 11, 2026.

Transparency log

Release files / myelectricaldatapy-2.5.3-py3-none-any.whl

Download URL myelectricaldatapy-2.5.3-py3-none-any.whl
Size 35.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5b2cbfde44f62403231ccbbd6eee1e90cfd0d59cf94270be46557ae3a3ee2be9
BLAKE2b-256 checksum
How to use checksums
cb3f3f284c72b3c4ea7bb0c950cdc31a9ccb503726c1ebf12bf7c5f706c688bf
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 11, 2026.

Transparency log

Security for myelectricaldatapy 2.5.3

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 myelectricaldatapy-2.5.3.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 11, 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.

Release history Release notifications | RSS feed

This release

2.5.3 This release

2 release files Full provenance

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