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:
- Optionally declare what you want to collect with
set_data_fetch(...),set_ecowatt_subscription(True)andset_maxpower_subscription(True). - Call
await async_update()(orasync_update(force_refresh=True)). - 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.
Release files for myelectricaldatapy 2.4.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| myelectricaldatapy-2.4.7.tar.gz | 121.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| myelectricaldatapy-2.4.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 154.9 kB
Release files / myelectricaldatapy-2.4.7.tar.gz
| Download URL | myelectricaldatapy-2.4.7.tar.gz |
|---|---|
| Size | 121.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b9b001777b990f0b6c33dad8d61c3afc9ba21794782b385de43249554702cc25
|
|
BLAKE2b-256 checksum How to use checksums |
3f35ae359d97bcc50901bf320d549be27ae2a73855d9c69bc27592d7c03a3e99
|
| 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 Sep 5, 2026.
Transparency logRelease files / myelectricaldatapy-2.4.7-py3-none-any.whl
| Download URL | myelectricaldatapy-2.4.7-py3-none-any.whl |
|---|---|
| Size | 33.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
af5d4f67ee8273bcb569ace4e6e8ad771ffd3678054b14bf785ee4a96d37add0
|
|
BLAKE2b-256 checksum How to use checksums |
57fdaa981b820367e17ee16461edb823477aee4a143e2a0ae99507f6cc3eb50c
|
| 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 Sep 5, 2026.
Transparency log