Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
enedis-konnector
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
web-et-numerique
Factory
LLLE_Project
enedis-konnector
Commits
2e6466cd
Commit
2e6466cd
authored
3 years ago
by
Guilhem CARRON
Browse files
Options
Downloads
Patches
Plain Diff
feat(analysis): Add maxpower data endpoint
parent
8d0e2c60
No related branches found
No related tags found
1 merge request
!10
feat(analysis): Add maxpower data endpoint
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/index.js
+35
-0
35 additions, 0 deletions
src/index.js
with
35 additions
and
0 deletions
src/index.js
+
35
−
0
View file @
2e6466cd
...
...
@@ -31,6 +31,7 @@ const endDateString = endDate.format('YYYY-MM-DD')
const
baseUrl
=
'
https://gw.prd.api.enedis.fr
'
const
dailyDataURL
=
`
${
baseUrl
}
/v4/metering_data/daily_consumption`
const
loadCurveURL
=
`
${
baseUrl
}
/v4/metering_data/consumption_load_curve`
const
maxPowerURL
=
`
${
baseUrl
}
/v4/metering_data/daily_consumption_max_power`
/**
* The start function is run by the BaseKonnector instance only when it got all the account
...
...
@@ -80,6 +81,16 @@ async function start(fields, cozyParameters, doRetry = true) {
await
agregateMonthAndYearData
(
processedDailyData
)
log
(
'
info
'
,
'
Process enedis load data
'
)
await
startLoadDataProcess
(
access_token
,
usage_point_id
)
log
(
'
info
'
,
'
Fetching enedis max Power data
'
)
const
fetchedMaxPowerData
=
await
getMaxPower
(
access_token
,
usage_point_id
)
log
(
'
info
'
,
'
Process enedis maxPower data
'
)
await
processData
(
fetchedMaxPowerData
,
'
com.grandlyon.enedis.maxpower
'
,
[
'
year
'
,
'
month
'
,
'
day
'
,
])
}
catch
(
err
)
{
if
(
err
.
statusCode
===
403
||
err
.
code
===
403
)
{
if
(
!
fields
.
refresh_token
)
{
...
...
@@ -137,6 +148,30 @@ async function getDailyData(token, usagePointID) {
return
response
}
/**
* Retrieve data from the max Power endpoint
* Format: { value: "VA", "date": "YYYY-MM-DD" }
*/
async
function
getMaxPower
(
token
,
usagePointID
)
{
const
dataRequest
=
{
method
:
'
GET
'
,
uri
:
maxPowerURL
+
'
?start=
'
+
startDailyDateString
+
'
&end=
'
+
endDateString
+
'
&usage_point_id=
'
+
usagePointID
,
headers
:
{
Accept
:
'
application/json
'
,
Authorization
:
'
Bearer
'
+
token
,
},
}
const
response
=
await
rp
(
dataRequest
)
return
response
}
/**
* Check if history is loaded
* If not, call several time the api to retrieve 1 month of history for load data
...
...
This diff is collapsed.
Click to expand it.
Guilhem CARRON
@gcarron
mentioned in commit
3f1faa07
·
3 years ago
mentioned in commit
3f1faa07
mentioned in commit 3f1faa07f40cb5da83395640942b571063dbbefd
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment