@@ -10,12 +10,12 @@ You should also check Cozy's official documentations for konnectors :
## Enedis Konnector
The Oauth protocol does not take place in the konnector code, therefore it is also important to take a look at the [proxy](../proxy/description.md) to fully understand all the interactions that will be told below.
The Oauth protocol does not take place in the konnector code, therefore it is also important to take a look at the [proxy](../../proxy/description.md) to fully understand all the interactions that will be told below.
All the actions performed by the stack are targetted from pre-registered paramaters, here is the list of all parameters needed by the stack to perform the Oauth protocol and allow the konnector to fetch data.
On its first launch, following the Oauth Client Connect authentification.
- The cozy stack calls the **authentification_endpoint** and start the oauth protocol, see [proxy doc](../proxy/description.md).
- The cozy stack calls the **authentification_endpoint** and start the oauth protocol, see [proxy doc](../../proxy/description.md).
- The account has now an access_token and an id_token from the oauth call
!!! info ""
...
...
@@ -32,8 +32,52 @@ This token holds several meta datas, including the pce_id (id of user's meter) t
## Enedis API
API Url for Production : [https://gw.prd.api.enedis.fr](https://gw.prd.api.enedis.fr)
API url for Development : [https://gw.hml.api.enedis.fr](https://gw.hml.api.enedis.fr)
Enpoints :
Once you've finished the OAuth protocol and have a valid token, you can go fetch the data. Currently we use the two following endpoints in Ecolyo:
For more information about Datahub-Enedis API, checkout the [Datahub documentation](https://datahub-enedis.fr/data-connect/documentation/metering-data-v4/).
| getDailyData | Retrieve data from the API. Format: `{ value: "Wh", "date": "YYYY-MM-DD" }`" |
| startLoadDataProcess | Check if history is loaded. If not, call several time the api to retrieve 1 month of history for load data. If yes only call once the api |
| launchLoadDataProcess | Launch process to handle load data |
| getLoadData | Retrieve data from the API. Format: `{ value: "W", "date": "YYYY-MM-DD hh:mm:ss" }` |
| processData | Parse data. Remove existing data from DB using hydrateAndFilter, store filtered data and return the list of filtered data |
| agregateMonthAndYearData | Agregate data from daily data to monthly and yearly data |
| agregateHourlyData | Agregate data from load data (every 30 min) to Hourly data |
| storeData | Save data in the right doctype db and prevent duplicated keys |
| formateData | Format data for DB storage and remove bad data |
| buildAgregatedData | Retrieve and remove old data for a specific doctype and return an array of agregated data |
| buildDataFromKey | Format an entry for DB storage using key and value. For year doctype: key = "YYYY". For month doctype: key = "YYYY-MM" |
| isHistoryLoaded | Function checking if the history is loaded |
| resetInProgressAggregatedData | Function handling special case.The temporary aggregated data need to be remove in order for the most recent one te be saved. Ex for com.grandlyon.enedis.year : `{ load: 76.712, year: 2020, ... }` need to be replace by `{ load: 82.212, year: 2020, ... }` after enedis data reprocess |