Newer
Older
223001
223002
223003
223004
223005
223006
223007
223008
223009
223010
223011
223012
223013
223014
223015
223016
223017
223018
223019
223020
223021
223022
223023
223024
223025
223026
223027
223028
223029
223030
223031
223032
223033
223034
223035
223036
223037
223038
223039
223040
223041
223042
223043
if (result && result.length > 0) {
// Filter data to remove
var filtered = []
if (doctype === 'com.grandlyon.enedis.year') {
// Yearly case
filtered = result.filter(function(el) {
return el.year == data.year
})
} else if (doctype === 'com.grandlyon.enedis.month') {
// Monthly case
filtered = result.filter(function(el) {
return el.year == data.year && el.month == data.month
})
} else {
// Hourly case
filtered = result.filter(function(el) {
return (
el.year == data.year &&
el.month == data.month &&
el.day == data.day &&
el.hour == data.hour
)
})
}
// Remove data
let sum = 0.0
// eslint-disable-next-line no-unused-vars
for (const doc of filtered) {
sum += doc.load
log('debug', doc, 'Removing this entry for ' + doctype)
await cozyClient.data.delete(doctype, doc)
}
return sum
}
return 0.0
}
module.exports = {
buildAgregatedData,
}
/***/ }),
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const { log } = __webpack_require__(1)
223050
223051
223052
223053
223054
223055
223056
223057
223058
223059
223060
223061
223062
223063
223064
223065
223066
223067
223068
223069
223070
223071
223072
223073
223074
223075
223076
223077
223078
223079
223080
223081
223082
223083
223084
223085
223086
223087
223088
223089
223090
223091
223092
223093
223094
223095
223096
223097
223098
223099
223100
223101
223102
223103
223104
223105
223106
223107
223108
223109
223110
223111
223112
223113
223114
223115
223116
223117
223118
223119
223120
223121
223122
223123
223124
223125
223126
223127
223128
223129
223130
223131
223132
223133
223134
/**
* Return start date
* @param {string} result
* @returns {string}
*/
function parseSgeXmlTechnicalData(result) {
log('info', 'Parsing technical data')
let json = JSON.stringify(result)
return JSON.parse(json)['Envelope']['Body'][
'consulterDonneesTechniquesContractuellesResponse'
]['point']['donneesGenerales'][
'dateDerniereModificationFormuleTarifaireAcheminement'
]
}
/**
* Parsing SGE xml reply to get only mesure data
* @param {string} result
* @returns {SGEData[]}
*/
function parseSgeXmlData(result) {
log('info', 'Parsing list of documents')
let json = JSON.stringify(result)
return JSON.parse(json)['Envelope']['Body'][
'consulterMesuresDetailleesResponse'
]['grandeur']['mesure']
}
/**
* Format data for DB storage
* @param {SGEData[]} data
* @returns {Promise<EnedisKonnectorData[]>} Parsed timestamp array
*/
async function formateDataForDoctype(data) {
log('info', 'Formating data')
return data.map(record => {
let date = moment(record.d, 'YYYY/MM/DD h:mm:ss')
return {
load: record.v,
year: parseInt(date.format('YYYY')),
month: parseInt(date.format('M')),
day: parseInt(date.format('D')),
hour: parseInt(date.format('H')),
minute: parseInt(date.format('m')),
}
})
}
/**
* Format tag in order to be manipulated easly
* @param {string} name
* @returns {string} name
*/
function parseTags(name) {
if (name.split(':')[1] !== undefined) {
return name.split(':')[1]
}
return name
}
/**
*
* @param {string} value
* @param {string} name
* @returns {string|number} value
*/
function parseValue(value, name) {
// Wh => KWh
if (name === 'v') {
return parseFloat((parseInt(value) / 1000).toFixed(2))
}
return value
}
module.exports = {
parseSgeXmlData,
parseSgeXmlTechnicalData,
formateDataForDoctype,
parseTags,
parseValue,
}
/***/ }),
223136
223137
223138
223139
223140
223141
223142
223143
223144
223145
223146
223147
223148
223149
223150
223151
223152
223153
223154
223155
223156
223157
223158
223159
223160
223161
223162
223163
223164
223165
223166
223167
223168
223169
223170
223171
223172
223173
223174
223175
223176
223177
223178
223179
223180
223181
223182
223183
223184
223185
223186
223187
223188
223189
223190
223191
223192
223193
223194
223195
223196
223197
223198
223199
223200
223201
223202
223203
223204
223205
223206
223207
223208
223209
223210
223211
223212
223213
223214
223215
223216
223217
223218
223219
223220
223221
223222
223223
223224
223225
223226
223227
223228
223229
223230
223231
223232
223233
223234
223235
223236
223237
223238
223239
223240
223241
223242
223243
223244
223245
223246
223247
223248
223249
223250
223251
223252
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const { log } = __webpack_require__(1)
/**
* Query SGE in order to get info
* @param {number} pointId
* @param {string} userLogin
* @param {string} startDt
* @param {string} endDt
* @returns {string}
*/
function userMesureDetailles(
pointId,
userLogin,
startDt,
endDt,
mesureType = 'ENERGIE',
unit = 'EA'
) {
log(
'info',
`Query data ${mesureType}/${unit} between ${startDt} and ${endDt}`
)
return `<?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>${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>
</soapenv:Envelope>
`
}
/**
* Get user technical data
* @param {number} pointId
* @param {string} userLogin
* @returns {string}
*/
function userTechnicalData(pointId, userLogin) {
log('info', `Query userMesureDetailles`)
return `<?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>${userLogin}</loginUtilisateur>
<autorisationClient>true</autorisationClient>
</v2:consulterDonneesTechniquesContractuelles>
</soapenv:Body>
</soapenv:Envelope>
`
}
/**
* Get user max power
* @param {number} pointId
* @param {string} userLogin
* @param {string} startDt
* @param {string} endDt
* @returns {string}
*/
function userMaxPower(pointId, userLogin, startDt, endDt) {
log('info', `Query userMesureDetailles`)
return `<?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>${userLogin}</initiateurLogin>
<pointId>${pointId}</pointId>
<mesuresTypeCode>PMAX</mesuresTypeCode>
<grandeurPhysique>PMA</grandeurPhysique>
<soutirage>true</soutirage>
<injection>false</injection>
<dateDebut>${startDt}</dateDebut>
<dateFin>${endDt}</dateFin>
<mesuresPas>P1D</mesuresPas>
<mesuresCorrigees>false</mesuresCorrigees>
<accordClient>true</accordClient>
</demande>
</v2:consulterMesuresDetaillees>
</soapenv:Body>
</soapenv:Envelope>
`
}
module.exports = {
userTechnicalData,
userMaxPower,
userMesureDetailles,
}
223253
223254
223255
223256
223257
223258
223259
223260
223261
223262
223263
223264
223265
223266
223267
223268
223269
223270
223271
223272
223273
223274
223275
223276
223277
223278
223279
223280
223281
223282
223283
223284
223285
223286
223287
223288
223289
223290
223291
223292
223293
223294
223295
223296
223297
223298
223299
223300
223301
223302
/***/ }),
/* 1557 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
const { log } = __webpack_require__(1)
const easySoapRequest = __webpack_require__(1331)
const { userTechnicalData } = __webpack_require__(1556)
async function soapAxios(url, headers, request) {
return easySoapRequest({
url: url,
headers: headers,
xml: request,
}).catch(err => {
log('error', url)
log('error', err)
return err
})
}
async function getContractData(url, apiAuthKey, userLogin, pointId) {
const sampleHeaders = {
'Content-Type': 'text/xml;charset=UTF-8',
apikey: apiAuthKey,
}
return soapAxios(
url,
sampleHeaders,
userTechnicalData(pointId, userLogin)
).catch(err => {
return err
})
}
async function getDetailedData(url, apiAuthKey, template) {
const sampleHeaders = {
'Content-Type': 'text/xml;charset=UTF-8',
apikey: apiAuthKey,
}
return soapAxios(url, sampleHeaders, template).catch(err => {
return err
})
}
module.exports = {
getContractData,
getDetailedData,
}
223303
223304
223305
223306
223307
223308
223309
223310
223311
223312
223313
223314
223315
223316
223317
223318
223319
223320
223321
223322
223323
223324
223325
223326
223327
223328
223329
223330
223331
223332
223333
223334
223335
223336
223337
223338
223339
223340
223341
223342
223343
223344
223345
223346
223347
223348
223349
223350
223351
223352
223353
223354
223355
223356
223357
223358
223359
223360
223361
223362
223363
223364
223365
223366
223367
223368
223369
223370
223371
223372
223373
223374
223375
223376
223377
223378
223379
223380
223381
223382
223383
223384
223385
223386
223387
223388
223389
223390
223391
223392
223393
223394
/***/ })
/******/ ]);
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ id: moduleId,
/******/ loaded: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = __webpack_module_cache__;
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
/******/ (() => {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = (module) => {
/******/ var getter = module && module.__esModule ?
/******/ () => (module['default']) :
/******/ () => (module);
/******/ __webpack_require__.d(getter, { a: getter });
/******/ return getter;
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/node module decorator */
/******/ (() => {
/******/ __webpack_require__.nmd = (module) => {
/******/ module.paths = [];
/******/ if (!module.children) module.children = [];
/******/ return module;
/******/ };
/******/ })();
/******/
/************************************************************************/
/******/
/******/ // module cache are used so entry inlining is disabled
/******/ // startup
/******/ // Load entry module and return exports
/******/ var __webpack_exports__ = __webpack_require__(__webpack_require__.s = 0);
/******/
/******/ })()
;