Enedis data connect client is a client for the REST API of the Enedis company.
The client is used to retrieve the consumption and production data, refer to the documentation provided by the Enedis API on https://datahub-enedis.fr/services-api/data-connect/documentation.
To connect you need to provide at least one PRM identifier (for consumption and / or production) described in the contract.
You have to pass the client identifier and the secret key generated by the Enedis portal.
client = EnedisClient(pdl, id, secret)
client.connect()
If the authentication fails, an InvalidAccess exception is thrown otherwise the token data will be stored internally.
To clear the token data, you just have to use:
client.close()
The client has some getters to access counters and basic data.
client.get_consumption_prm()
client.get_production_prm()
client.get_client_id()
client.get_token_data()
client.get_requests_count()
client.get_errors_count()
client.is_connected()
The module provides a helper class useful for retrieving data from the API.
To instantiate the helper, you just need to pass the client instance.
helper = EnedisApiHelper(client)
To use the helper, it is not necessary to authenticate first. The helper will manage the authentication process (with retry on token expiration)
The maximum consumed power per day is returned as a dictionary of integers indexed by the datetime. To request the API you have to pass a start date and the end date.
To request data of consumption you need to provide the PRM identifier for consumption when instantiating the client.
data: dict[datetime, int] = helper.get_max_daily_consumed_power(start_time, end_time)
The consumption per day is returned as a dictionary of integers indexed by the date. To request the API you have to pass a start date and the end date.
To request data of consumption you need to provide the PRM identifier for consumption when instantiating the client.
data: dict[date, int] = helper.get_daily_consumption(start_time, end_time)
The consumption is returned as a dictionary of integers indexed by the datetime. To request the API you have to pass a start date and the end date.
To request data of consumption you need to provide the PRM identifier for consumption when instantiating the client.
data: dict[datetime, int] = helper.get_consumption_load_curve(start_time, end_time)
The production per day is returned as a dictionary of integers indexed by the date. To request the API you have to pass a start date and the end date.
To request data of production you need to provide the PRM identifier for production when instantiating the client.
data: dict[date, int] = helper.get_daily_production(start_time, end_time)
The production is returned as a dictionary of integers indexed by the datetime. To request the API you have to pass a start date and the end date.
To request data of production you need to provide the PRM identifier for production when instantiating the client.
data: dict[datetime, int] = helper.get_production_load_curve(start_time, end_time)