
* Documentation and fix on description to use plain text. * Updates (#10) * Create pypi.yml * Documentation and fix on description to use plain text. (#8) * Documentation and fix on description to use plain text. (#9) * Update pypi.yml * Update pypi.yml * Update pypi.yml * Update pypi.yml * Update setup.py * Package update * Requests for production data and changes to provide 2 PRM
Enedis data connect client
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.
Connecting the client to authenticate and get the token
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.
Closing or deleting token data
To clear the token data, you just have to use:
client.close()
Other methods
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 helper
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)
Get the maximum consumed power per day
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)
Get the consumption per day
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)
Get the consumption per half an hour
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)
Get the production per day
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)
Get the production per half an hour
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)