Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • web-et-numerique/factory/llle_project/self-data-technical-doc
1 result
Select Git revision
Show changes
Commits on Source (2)
......@@ -7,4 +7,21 @@ On the server, we can see that the server is underwater by using "top" command:
![oops_error_1](/img/known_errors/oops_error_1.png)
To fix this issue, just restart the service on the server with "docker-compose down / docker-compose up -d" in the easy-cozy folder:
![oops_error_2](/img/known_errors/oops_error_2.png)
\ No newline at end of file
![oops_error_2](/img/known_errors/oops_error_2.png)
### Impossible instance delete
When you get this issue after trying to delete instance :
![delete_issue](/img/known_errors/instance_delete_issue.png)
You have to remove it from db, in order to do that follow this steps :
1. Get instance UUID
```sh
docker-compose exec cozy ./cozy instances show-db-prefix --host 0.0.0.0 demo.cozy.self-data.alpha.grandlyon.com
```
2. Connect to database with ssh port forwarding or use curl requests
3. Remove instance in `gloabal/instances` db by searching for UUID. (Ex: cozy5e2af113e04eb2319ef1b7645c5790e1)
docs/img/known_errors/instance_delete_issue.png

6.83 KiB

......@@ -20,16 +20,16 @@ The API used by this konnector are the one used by all energy providers (edf, to
### WSO2
For now enedis API are proxied by WSO1 api manager. You can find documentation and devportal [here](https://apis.grandlyon.fr/devportal).
For now enedis API are proxied by WSO2 api manager. You can find documentation and devportal [here](https://apis.grandlyon.fr/devportal).
### Scaffolding
- Aggregate.js: file holding method responsible for month and year aggregation
- parsing.js: contain all methods for xml to json parsing and data formatting
- request.js: hold SGE query methods
- types.js: file containing type definition to allow js type check.
- core/types: contains jsdoc types
- core/: requests wrapper with error handling logic
- helpers/ : contains helpers for aggregation, env and parsing
- requests/: contain all methods for : Parsing sge requests, Send/get backoffice data, interacte with cozy stack
- index.js: main file where default konnector methods are launch (start, ...)
- onDeleteAccount.js: hold consent suppresion when a user delete an account. Automatically launched on delete.
### 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.
......@@ -37,42 +37,84 @@ In order to have better comfort while coding, we have enable ts-checking with vs
!!! note "ts-check"
The ts-check is none blocking. It will only put information in vs-code ide.
### Local dev
In order to local test you have to put the following configuration in `konnector-dev-config`:
```json
{
"COZY_URL": "http://cozy.tools:8080",
"fields": {
"pointId": "<POINT_ID>",
"lastname": "<LASTNAME>",
"firstname": "<FIRSTNAME>",
"address": "<ADDRESSE>",
"sgeLogin": "donnees.energie@grandlyon.com",
"postalCode": "<CP>",
"city": "<CITY>",
"contractId": "<CONTRACT_ID ex: 1234567>",
"wso2BaseUrl": "https://apis.grandlyon.fr",
"boBaseUrl": "https://ecolyo-agent-rec.grandlyon.com/api/sge",
"boToken": "<BO_TOKEN>",
"apiToken": "<SGE_TOKEN>"
}
}
```
Replace every `<***>` with yout test values and corresponding secrets.
!!! warning "user consent"
While running in dev mode, be sure to have user consent, either on production env or with enedis standard form.
You can now run the following commands to run the konnector :
```sh
yarn standalone #Run inside shell with no cozy env dependencies
yarn dev #Run with your local cozy. For this one you need local stack to run
yarn onDeleteAccount:standalone #Run onDeleteAccount script
yarn onDeleteAccount #Run onDeleteAccount script with real cozy
```
For standalone cmd you can find konnector resulte in `/data/importedData.json`
### Konnector Methods
| Method | Description |
| ------ | ------ |
| start | Main method of konnector. Handle global flow and init method with provided params |
| getDataStartDate | Retrieve user contract *startDate* in order to request an accurate time range of data |
| gatherData | Wrapper for getting daily, half-hour and max power 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 |
| setStartDate | Save startDate with the right time range |
| storeData | Save data to user's cozy |
| agregateMonthAndYearData | Sum daily data for months and years |
| isFirstStart | Check if it's first start or an alternate starte base on boId in cozy.account |
## Dataflow
### Overview
Fonctionnal and technichal flow chart:
[Lien du schema](https://whimsical.com/sge-tech-DxbYM8DdajRjTr6WZat1bV)
### Authentication
**TODO: Write this part when full implementation will be done.**
Information required:
- Name
- Surname
- PointID (PDL)
- Full address
- Postal Code
- City
### Fetch Data
In order to get data from the SGE API we have to request the following route :
1. Get user contract startDate
#### Get user contract startDate
Method : **POST**
......@@ -88,9 +130,208 @@ Data Route : **enedis_SGE_ConsultationDonneesTechniquesContractuelles/1.0**
</soapenv:Body>
```
2. Get daily data
3. Get Max Power data
4. Get Half-hour data
#### Get daily data and Get Half-hour data
Method : **POST**
Data Route : **enedis_SGE_ConsultationMesuresDetaillees/1.0**
```xml
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v2="http://www.enedis.fr/sge/b2b/services/consultationmesuresdetaillees/v2.0"
xmlns:v1="http://www.enedis.fr/sge/b2b/technique/v1.0">
<soapenv:Header/>
<soapenv:Body>
<v2:consulterMesuresDetaillees>
<demande>
<initiateurLogin>${appLogin}</initiateurLogin>
<pointId>${pointId}</pointId>
<mesuresTypeCode>${mesureType}</mesuresTypeCode>
<grandeurPhysique>${unit}</grandeurPhysique>
<soutirage>true</soutirage>
<injection>false</injection>
<dateDebut>${startDate}</dateDebut>
<dateFin>${endDate}</dateFin>
<mesuresCorrigees>false</mesuresCorrigees>
<accordClient>true</accordClient>
</demande>
</v2:consulterMesuresDetaillees>
</soapenv:Body>
</soapenv:Envelope>
```
#### Get Max Power data
Method : **POST**
Data Route : **enedis_SGE_ConsultationMesuresDetaillees/1.0**
```xml
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v2="http://www.enedis.fr/sge/b2b/services/consultationmesuresdetaillees/v2.0"
xmlns:v1="http://www.enedis.fr/sge/b2b/technique/v1.0">
<soapenv:Header/>
<soapenv:Body>
<v2:consulterMesuresDetaillees>
<demande>
<initiateurLogin>${appLogin}</initiateurLogin>
<pointId>${pointId}</pointId>
<mesuresTypeCode>${mesureType}</mesuresTypeCode>
<grandeurPhysique>${unit}</grandeurPhysique>
<soutirage>true</soutirage>
<injection>false</injection>
<dateDebut>${startDate}</dateDebut>
<dateFin>${endDate}</dateFin>
<mesuresPas>P1D</mesuresPas>
<mesuresCorrigees>false</mesuresCorrigees>
<accordClient>true</accordClient>
</demande>
</v2:consulterMesuresDetaillees>
</soapenv:Body>
</soapenv:Envelope>
```
#### Get contract information
Method : **POST**
Data Route : **enedis_SGE_enedis_SGE_ConsultationDonneesTechniquesContractuelles/1.0**
```xml
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v2="http://www.enedis.fr/sge/b2b/services/consulterdonneestechniquescontractuelles/v1.0"
xmlns:v1="http://www.enedis.fr/sge/b2b/technique/v1.0">
<soapenv:Header/>
<soapenv:Body>
<v2:consulterDonneesTechniquesContractuelles>
<pointId>${pointId}</pointId>
<loginUtilisateur>${appLogin}</loginUtilisateur>
<autorisationClient>true</autorisationClient>
</v2:consulterDonneesTechniquesContractuelles>
</soapenv:Body>
</soapenv:Envelope>
```
#### Get user PDL <a name="recherche_services_mesures"></a>
Method : **POST**
Data Route : **enedis_SGE_RechercheServicesMesures/1.0**
```xml
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v2="http://www.enedis.fr/sge/b2b/services/rechercherpoint/v2.0"
xmlns:v1="http://www.enedis.fr/sge/b2b/technique/v1.0">
<soapenv:Header/>
<soapenv:Body>
<v2:rechercherPoint>
<criteres>
<adresseInstallation>
<numeroEtNomVoie>${address}</numeroEtNomVoie>
<codePostal>${postalCode}</codePostal>
<codeInseeCommune>${inseeCode}</codeInseeCommune>
</adresseInstallation>
<nomClientFinalOuDenominationSociale>${name}</nomClientFinalOuDenominationSociale>
<rechercheHorsPerimetre>true</rechercheHorsPerimetre>
</criteres>
<loginUtilisateur>${appLogin}</loginUtilisateur>
</v2:rechercherPoint>
</soapenv:Body>
</soapenv:Envelope>
```
#### Get User services subscriptions
Method : **POST**
Data Route : **enedis_SGE_RechercheServicesMesures/1.0**
```xml
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v2="http://www.enedis.fr/sge/b2b/rechercherservicessouscritsmesures/v1.0"
xmlns:v1="http://www.enedis.fr/sge/b2b/technique/v1.0">
<soapenv:Header/>
<soapenv:Body>
<v2:rechercherServicesSouscritsMesures>
<criteres>
<pointId>${pointId}</pointId>
<contratId>${contractId}</contratId>
</criteres>
<loginUtilisateur>${appLogin}</loginUtilisateur>
</v2:rechercherServicesSouscritsMesures>
</soapenv:Body>
</soapenv:Envelope>
```
#### Start user contract <a name="user_contract_start"></a>
Method : **POST**
Data Route : **enedis_SGE_CommandeCollectePublicationMesures/1.0**
```xml
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v2="http://www.enedis.fr/sge/b2b/commandercollectepublicationmesures/v3.0"
xmlns:v1="http://www.enedis.fr/sge/b2b/technique/v1.0">
<soapenv:Header/>
<soapenv:Body>
<v2:commanderCollectePublicationMesures>
<demande>
<donneesGenerales>
<objetCode>AME</objetCode>
<pointId>${pointId}</pointId>
<initiateurLogin>${appLogin}</initiateurLogin>
<contratId>${contractId}</contratId>
</donneesGenerales>
<accesMesures>
<dateDebut>${startDate}</dateDebut>
<dateFin>${endDate}</dateFin>
<declarationAccordClient>
<accord>true</accord>
<personnePhysique>
<nom>${name}</nom>
</personnePhysique>
</declarationAccordClient>
<mesuresTypeCode>CDC</mesuresTypeCode>
<soutirage>true</soutirage>
<injection>false</injection>
<mesuresPas>PT30M</mesuresPas>
<mesuresCorrigees>false</mesuresCorrigees>
<transmissionRecurrente>true</transmissionRecurrente>
<periodiciteTransmission>P1D</periodiciteTransmission>
</accesMesures>
</demande>
</v2:commanderCollectePublicationMesures>
</soapenv:Body>
</soapenv:Envelope>
```
#### Stop User contract
```xml
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v2="http://www.enedis.fr/sge/b2b/commanderarretservicesouscritmesures/v1.0"
xmlns:v1="http://www.enedis.fr/sge/b2b/technique/v1.0">
<soapenv:Header/>
<soapenv:Body>
<v2:commanderArretServiceSouscritMesures>
<demande>
<donneesGenerales>
<objetCode>ASS</objetCode>
<pointId>${pointId}</pointId>
<initiateurLogin>${appLogin}</initiateurLogin>
<contratId>${contractId}</contratId>
</donneesGenerales>
<arretServiceSouscrit>
<serviceSouscritId>${serviceSouscritId}</serviceSouscritId>
</arretServiceSouscrit>
</demande>
</v2:commanderArretServiceSouscritMesures>
</soapenv:Body>
</soapenv:Envelope>
```
The same endpoint is used to get the data. The soap body is the following:
......@@ -117,3 +358,29 @@ Data Route : **enedis_SGE_ConsultationDonneesTechniquesContractuelles/1.0**
</soapenv:Body>
```
### Known Issues
#### Contract deletion and creation on same day
If you stop a contract on a day, (for exemple 8/08/22), you cannot start a new contract for this date with [start contract route](#user_contract_start). You have to wait for the next day. This might cause somme production issues
#### User data collect opposition
Users can remove consent from enedis account on data collecting. This will return the following when [checking contracts](recherche_services_mesures).
```xml
<serviceSouscritMesures>
<serviceSouscritId>74472322</serviceSouscritId>
<pointId>19176410771132</pointId>
<serviceSouscritType code="OPPENR"/>
<serviceSouscritLibelle>Opposition à l'enregistrement de la courbe de charge</serviceSouscritLibelle>
<injection>false</injection>
<soutirage>true</soutirage>
<etatCode>ACTIF</etatCode>
<dateDebut>2022-06-24+02:00</dateDebut>
<dateFin>2022-08-10+02:00</dateFin>
<motifFinLibelle>Arrêt par le client</motifFinLibelle>
</serviceSouscritMesures>
```
We cannot override that, the only solution is to tell the user to activate data collect on [enedis](https://mon-compte-particulier.enedis.fr/donnees/).
\ No newline at end of file