Skip to content
Snippets Groups Projects
enedis-sge.md 3.71 KiB
Newer Older
  • Learn to ignore specific revisions
  • Hugo NOUTS's avatar
    Hugo NOUTS committed
    This konnector fetches consumption measures from Enedis SGE SOAP API. 
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
    
    You should also check Cozy's official documentations for konnectors :
    [https://docs.cozy.io/en/tutorials/konnector/getting-started/](https://docs.cozy.io/en/tutorials/konnector/getting-started/)
    
    # Enedis SGE Konnector
    
    !!! warning "This konnector is in a POC state"
    
    ## Enedis context
    
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    The API used by this konnector are the one used by all energy providers (edf, total...), this one is supposed to have a high availability. Contrary to enedis oauth konnector, this is a regular auth konnector.
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
    
    ## Technical overview
    
    ### Lib used 
    
    - xml2js: Lib allowing easy parsing to json
    - easy-soap-request: Lib making soap request
    
    ### WSO2
    
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    For now enedis API are proxied by WSO1 api manager. You can find documentation and devportal [here](https://apis.grandlyon.fr/devportal).
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
    
    ### Scaffolding 
    
    - Aggregate.js: file holding method responsible for month and year aggregation 
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    - parsing.js: contain all methods for xml to json parsing and data formatting
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
    - request.js: hold SGE query methods 
    - types.js: file containing type definition to allow js type check.
    - index.js: main file where default konnector methods are launch (start, ...)
    
    ### ts-check
    
    In order to have better comfort while coding, we have enable ts-checking with vs-code. The verification is based on js-doc, please take time to maintain the js-doc.
    
    !!! note "ts-check"
        The ts-check is none blocking. It will only put information in vs-code ide.
    
    
    ### Konnector Methods
    | Method | Description |
    | ------ | ------ |
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    | start | Main method of konnector. Handle global flow and init method with provided params |
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
    | getDataStartDate | Retrieve user contract *startDate* in order to request an accurate time range of data |
    | getData | Get daily data |
    | getMaxPowerData | Get daily Max Power data |
    | getHalfHourData | Get half-hour data |
    | processData | Given a doctype, parse and format data before storing and aggregating |
    | processStartDate | Save startDate and process queries time range |
    | storeData | Save data to user's cozy |
    | agregateMonthAndYearData | Sum daily data for months and years |
    
    ## Dataflow
    
    ### Overview
    
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    [Lien du schema](https://whimsical.com/sge-tech-DxbYM8DdajRjTr6WZat1bV)
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
    
    ### Authentication
    
    **TODO: Write this part when full implementation will be done.**
    
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    Information required: 
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
    
    - Name
    - Surname
    - PointID (PDL)
    - Full address 
    
    ### Fetch Data
    
    In order to get data from the SGE API we have to request the following route :
    
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    1. Get user contract startDate
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
    
    Method : **POST**
    
    Data Route : **enedis_SGE_ConsultationDonneesTechniquesContractuelles/1.0**
    
    ```xml
    <soapenv:Body>
        <v2:consulterDonneesTechniquesContractuelles>
            <pointId>${pointId}</pointId>
            <loginUtilisateur>${userLogin}</loginUtilisateur>
            <autorisationClient>true</autorisationClient>
        </v2:consulterDonneesTechniquesContractuelles>
    </soapenv:Body>
    ```
    
    2. Get daily data
    3. Get Max Power data
    4. Get Half-hour data
    
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    The same endpoint is used to get the data. The soap body is the following:
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
    
    Method : **POST**
    
    Data Route : **enedis_SGE_ConsultationDonneesTechniquesContractuelles/1.0**
    
    ```xml
    <soapenv:Body>
        <v2:consulterMesuresDetaillees>
            <demande>
                <initiateurLogin>${userLogin}</initiateurLogin>
                <pointId>${pointId}</pointId>
                <mesuresTypeCode>${mesureType}</mesuresTypeCode>
                <grandeurPhysique>${unit}</grandeurPhysique>
                <soutirage>true</soutirage>
                <injection>false</injection>
                <dateDebut>${startDt}</dateDebut>
                <dateFin>${endDt}</dateFin>
                <mesuresCorrigees>false</mesuresCorrigees>
                <accordClient>true</accordClient>
            </demande>
        </v2:consulterMesuresDetaillees>
    </soapenv:Body>
    ```