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_update_collects() 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.

Release files for myelectricaldatapy 2.4.2

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.4.2
File Size Uploaded
myelectricaldatapy-2.4.2.tar.gz 118.5 kB Details

Built distribution (wheel)

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

Total release size: 150.2 kB

Release files / myelectricaldatapy-2.4.2.tar.gz

Download URL myelectricaldatapy-2.4.2.tar.gz
Size 118.5 kB
Tags Source
SHA-256 checksum
How to use checksums
1df6e394f5a7a651fd82663326cfea3415d1eef2b1d7860228739b0c55958e66
BLAKE2b-256 checksum
How to use checksums
6816e8d894914954b9e81777ccbdbc997012efba3ae1dea26c6e098f76cd15cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.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 Aug 30, 2026.

Transparency log

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

Download URL myelectricaldatapy-2.4.2-py3-none-any.whl
Size 31.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
81515f559b083bd8c11782910df5f0829b9e06fd104afff85b14ed14f164a474
BLAKE2b-256 checksum
How to use checksums
e6ace9f10699cacb5aba99a9b35b89f70feff1841887f7aa547e95724ad001c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.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 Aug 30, 2026.

Transparency log

Release history Release notifications | RSS feed

2.5.1

2 release files

2.5.0

2 release files

2.4.9

2 release files

2.4.8

2 release files

2.4.7

2 release files

2.4.5

2 release files

2.4.4

2 release files

2.4.3

2 release files

This release

2.4.2 This release

2 release files

2.4.1

2 release files

2.4.0

2 release files

2.3.1

2 release files

2.3.0

2 release files

2.2.9

2 release files

2.2.8

2 release files

2.2.7

2 release files

2.2.6

2 release files

2.2.5

2 release files

2.2.4

2 release files

2.2.3

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.9

2 release files

2.1.8

2 release files

2.1.7

2 release files

2.1.6

2 release files

2.1.5

2 release files

2.1.4

2 release files

2.1.3

2 release files

2.1.2

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.9.9

2 release files

1.9.8

2 release files

1.9.7

2 release files

1.9.6

2 release files

1.9.5

2 release files

1.9.4

2 release files

1.9.3

2 release files

1.9.2

2 release files

1.9.1

2 release files

1.8.9

2 release files

1.8.8

2 release files

1.8.7

2 release files

1.8.6

2 release files

1.8.5

2 release files

1.8.4

2 release files

1.8.3

2 release files

1.8.2

2 release files

1.8.1

2 release files

1.8.0

2 release files

1.7.3

2 release files

1.7.2

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.9

2 release files

1.6.8

2 release files

1.6.7

2 release files

1.6.6

2 release files

1.6.5

2 release files

1.6.4

2 release files

1.6.3

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.9

2 release files

1.5.8

2 release files

1.5.7

2 release files

1.5.6

2 release files

1.5.5

2 release files

1.5.4

2 release files

1.5.3

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.9

2 release files

1.4.6

2 release files

1.4.5

2 release files

1.4.4

2 release files

1.4.3

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.9

2 release files

1.3.8

2 release files

1.3.7

2 release files

1.3.6

2 release files

1.3.5

2 release files

1.3.4

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3

2 release files

1.2

2 release files

1.1

2 release files

1.0

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