e-data 1.2.15__tar.gz → 1.2.16__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {e-data-1.2.15/e_data.egg-info → e-data-1.2.16}/PKG-INFO +1 -1
- {e-data-1.2.15 → e-data-1.2.16/e_data.egg-info}/PKG-INFO +1 -1
- {e-data-1.2.15 → e-data-1.2.16}/edata/helpers.py +46 -14
- {e-data-1.2.15 → e-data-1.2.16}/edata/processors/billing.py +14 -14
- {e-data-1.2.15 → e-data-1.2.16}/setup.py +1 -1
- {e-data-1.2.15 → e-data-1.2.16}/LICENSE +0 -0
- {e-data-1.2.15 → e-data-1.2.16}/MANIFEST.in +0 -0
- {e-data-1.2.15 → e-data-1.2.16}/README.md +0 -0
- {e-data-1.2.15 → e-data-1.2.16}/e_data.egg-info/SOURCES.txt +0 -0
- {e-data-1.2.15 → e-data-1.2.16}/e_data.egg-info/dependency_links.txt +0 -0
- {e-data-1.2.15 → e-data-1.2.16}/e_data.egg-info/requires.txt +0 -0
- {e-data-1.2.15 → e-data-1.2.16}/e_data.egg-info/top_level.txt +0 -0
- {e-data-1.2.15 → e-data-1.2.16}/edata/__init__.py +0 -0
- {e-data-1.2.15 → e-data-1.2.16}/edata/connectors/__init__.py +0 -0
- {e-data-1.2.15 → e-data-1.2.16}/edata/connectors/datadis.py +0 -0
- {e-data-1.2.15 → e-data-1.2.16}/edata/connectors/redata.py +0 -0
- {e-data-1.2.15 → e-data-1.2.16}/edata/const.py +0 -0
- {e-data-1.2.15 → e-data-1.2.16}/edata/definitions.py +0 -0
- {e-data-1.2.15 → e-data-1.2.16}/edata/processors/__init__.py +0 -0
- {e-data-1.2.15 → e-data-1.2.16}/edata/processors/base.py +0 -0
- {e-data-1.2.15 → e-data-1.2.16}/edata/processors/consumption.py +0 -0
- {e-data-1.2.15 → e-data-1.2.16}/edata/processors/maximeter.py +0 -0
- {e-data-1.2.15 → e-data-1.2.16}/edata/processors/utils.py +0 -0
- {e-data-1.2.15 → e-data-1.2.16}/edata/storage.py +0 -0
- {e-data-1.2.15 → e-data-1.2.16}/setup.cfg +0 -0
|
@@ -53,6 +53,7 @@ class EdataHelper:
|
|
|
53
53
|
self.attributes = {}
|
|
54
54
|
self._storage_dir = storage_dir_path
|
|
55
55
|
self._cups = cups
|
|
56
|
+
self._scups = cups[-5:0]
|
|
56
57
|
self._authorized_nif = datadis_authorized_nif
|
|
57
58
|
self.last_update = {x: datetime(1970, 1, 1) for x in self.data}
|
|
58
59
|
self._date_from = datetime(1970, 1, 1)
|
|
@@ -111,6 +112,11 @@ class EdataHelper:
|
|
|
111
112
|
incremental_update: bool = True,
|
|
112
113
|
):
|
|
113
114
|
"""Synchronous update."""
|
|
115
|
+
|
|
116
|
+
_LOGGER.info(
|
|
117
|
+
"%s: update triggered",
|
|
118
|
+
self._scups,
|
|
119
|
+
)
|
|
114
120
|
self._date_from = date_from
|
|
115
121
|
self._date_to = date_to
|
|
116
122
|
|
|
@@ -131,6 +137,8 @@ class EdataHelper:
|
|
|
131
137
|
|
|
132
138
|
def update_supplies(self):
|
|
133
139
|
"""Synchronous data update of supplies."""
|
|
140
|
+
|
|
141
|
+
_LOGGER.info("%s: supplies update triggered", self._scups)
|
|
134
142
|
if datetime.today().date() != self.last_update["supplies"].date():
|
|
135
143
|
# if supplies haven't been updated today
|
|
136
144
|
supplies = self.datadis_api.get_supplies(
|
|
@@ -140,10 +148,14 @@ class EdataHelper:
|
|
|
140
148
|
self.data["supplies"] = supplies
|
|
141
149
|
# if we got something, update last_update flag
|
|
142
150
|
self.last_update["supplies"] = datetime.now()
|
|
143
|
-
_LOGGER.info("
|
|
151
|
+
_LOGGER.info("%s: supplies update succeeded", self._scups)
|
|
152
|
+
else:
|
|
153
|
+
_LOGGER.info("%s: supplies are already updated (skipping)", self._scups)
|
|
144
154
|
|
|
145
155
|
def update_contracts(self, cups: str, distributor_code: str):
|
|
146
156
|
"""Synchronous data update of contracts."""
|
|
157
|
+
|
|
158
|
+
_LOGGER.info("%s: contracts update triggered", self._scups)
|
|
147
159
|
if datetime.today().date() != self.last_update["contracts"].date():
|
|
148
160
|
# if contracts haven't been updated today
|
|
149
161
|
contracts = self.datadis_api.get_contract_detail(
|
|
@@ -155,7 +167,9 @@ class EdataHelper:
|
|
|
155
167
|
) # extend contracts data with new ones
|
|
156
168
|
# if we got something, update last_update flag
|
|
157
169
|
self.last_update["contracts"] = datetime.now()
|
|
158
|
-
_LOGGER.info("
|
|
170
|
+
_LOGGER.info("%s: contracts update succeeded", self._scups)
|
|
171
|
+
else:
|
|
172
|
+
_LOGGER.info("%s: contracts are already updated (skipping)", self._scups)
|
|
159
173
|
|
|
160
174
|
def update_consumptions(
|
|
161
175
|
self,
|
|
@@ -168,6 +182,7 @@ class EdataHelper:
|
|
|
168
182
|
):
|
|
169
183
|
"""Synchronous data update of consumptions."""
|
|
170
184
|
|
|
185
|
+
_LOGGER.info("%s: consumptions update triggered", self._scups)
|
|
171
186
|
if (datetime.now() - self.last_update["consumptions"]) > self.UPDATE_INTERVAL:
|
|
172
187
|
consumptions = self.datadis_api.get_consumption_data(
|
|
173
188
|
cups,
|
|
@@ -184,12 +199,17 @@ class EdataHelper:
|
|
|
184
199
|
)
|
|
185
200
|
self.last_update["consumptions"] = datetime.now()
|
|
186
201
|
_LOGGER.info(
|
|
187
|
-
"
|
|
202
|
+
"%s: consumptions update succeeded (%s new records)",
|
|
203
|
+
self._scups,
|
|
188
204
|
len(consumptions),
|
|
189
205
|
)
|
|
206
|
+
else:
|
|
207
|
+
_LOGGER.info("%s: consumptions are already updated (skipping)", self._scups)
|
|
190
208
|
|
|
191
209
|
def update_maximeter(self, cups, distributor_code, start_date, end_date):
|
|
192
210
|
"""Synchronous data update of maximeter."""
|
|
211
|
+
|
|
212
|
+
_LOGGER.info("%s: maximeter update triggered", self._scups)
|
|
193
213
|
if (datetime.now() - self.last_update["maximeter"]) > self.UPDATE_INTERVAL:
|
|
194
214
|
maximeter = self.datadis_api.get_max_power(
|
|
195
215
|
cups,
|
|
@@ -204,9 +224,12 @@ class EdataHelper:
|
|
|
204
224
|
)
|
|
205
225
|
self.last_update["maximeter"] = datetime.now()
|
|
206
226
|
_LOGGER.info(
|
|
207
|
-
"
|
|
227
|
+
"%s: maximeter update succeeded (%s new records)",
|
|
228
|
+
self._scups,
|
|
208
229
|
len(maximeter),
|
|
209
230
|
)
|
|
231
|
+
else:
|
|
232
|
+
_LOGGER.info("%s: maximeter is already updated (skipping)", self._scups)
|
|
210
233
|
|
|
211
234
|
def update_datadis(
|
|
212
235
|
self,
|
|
@@ -215,9 +238,10 @@ class EdataHelper:
|
|
|
215
238
|
date_to: datetime = datetime.today(),
|
|
216
239
|
):
|
|
217
240
|
"""Synchronous data update."""
|
|
241
|
+
|
|
218
242
|
_LOGGER.info(
|
|
219
|
-
"
|
|
220
|
-
|
|
243
|
+
"%s: datadis update triggered (from %s to %s)",
|
|
244
|
+
self._scups,
|
|
221
245
|
date_from.isoformat(),
|
|
222
246
|
date_to.isoformat(),
|
|
223
247
|
)
|
|
@@ -228,7 +252,8 @@ class EdataHelper:
|
|
|
228
252
|
if len(self.data["supplies"]) == 0:
|
|
229
253
|
# return if no supplies were discovered
|
|
230
254
|
_LOGGER.warning(
|
|
231
|
-
"
|
|
255
|
+
"%s: supplies update failed or no supplies found in the provided account",
|
|
256
|
+
self._scups,
|
|
232
257
|
)
|
|
233
258
|
return False
|
|
234
259
|
|
|
@@ -237,9 +262,7 @@ class EdataHelper:
|
|
|
237
262
|
if supply is None:
|
|
238
263
|
# return if specified cups seems not valid
|
|
239
264
|
_LOGGER.error(
|
|
240
|
-
"
|
|
241
|
-
cups[-4:],
|
|
242
|
-
[x["cups"] for x in self.data["supplies"]],
|
|
265
|
+
"%s: CUPS not found, please check configured CUPS", self._scups
|
|
243
266
|
)
|
|
244
267
|
return False
|
|
245
268
|
|
|
@@ -252,7 +275,8 @@ class EdataHelper:
|
|
|
252
275
|
self.update_contracts(cups, distributor_code)
|
|
253
276
|
if len(self.data["contracts"]) == 0:
|
|
254
277
|
_LOGGER.warning(
|
|
255
|
-
"
|
|
278
|
+
"%s: contracts update failed or no contracts found in the provided account",
|
|
279
|
+
self._scups,
|
|
256
280
|
)
|
|
257
281
|
return False
|
|
258
282
|
|
|
@@ -275,13 +299,15 @@ class EdataHelper:
|
|
|
275
299
|
miss_cons, miss_maxim = sort_and_filter(date_from, date_to)
|
|
276
300
|
|
|
277
301
|
_LOGGER.info(
|
|
278
|
-
"
|
|
302
|
+
"%s: missing consumptions: %s",
|
|
303
|
+
self._scups,
|
|
279
304
|
", ".join(
|
|
280
305
|
[x["from"].isoformat() + " - " + x["to"].isoformat() for x in miss_cons]
|
|
281
306
|
),
|
|
282
307
|
)
|
|
283
308
|
_LOGGER.info(
|
|
284
|
-
"
|
|
309
|
+
"%s, missing maximeter: %s",
|
|
310
|
+
self._scups,
|
|
285
311
|
", ".join(
|
|
286
312
|
[
|
|
287
313
|
x["from"].isoformat() + " - " + x["to"].isoformat()
|
|
@@ -335,7 +361,8 @@ class EdataHelper:
|
|
|
335
361
|
[date_from, supply_date_start]
|
|
336
362
|
):
|
|
337
363
|
_LOGGER.info(
|
|
338
|
-
"
|
|
364
|
+
"%s: supplies and contract start date do not match, exploring non-registered contracts",
|
|
365
|
+
self._scups,
|
|
339
366
|
)
|
|
340
367
|
start = max([supply_date_start, date_from])
|
|
341
368
|
self.update_consumptions(
|
|
@@ -361,6 +388,11 @@ class EdataHelper:
|
|
|
361
388
|
):
|
|
362
389
|
"""Fetch PVPC prices using REData API."""
|
|
363
390
|
|
|
391
|
+
_LOGGER.info(
|
|
392
|
+
"%s: updating PVPC prices",
|
|
393
|
+
self._scups,
|
|
394
|
+
)
|
|
395
|
+
|
|
364
396
|
self.data["pvpc"], missing = utils.extract_dt_ranges(
|
|
365
397
|
self.data["pvpc"],
|
|
366
398
|
date_from,
|
|
@@ -92,19 +92,19 @@ class BillingProcessor(Processor):
|
|
|
92
92
|
|
|
93
93
|
env = Environment()
|
|
94
94
|
energy_expr = env.compile_expression(
|
|
95
|
-
f'({self._input["rules"]["energy_formula"]})|float
|
|
95
|
+
f'({self._input["rules"]["energy_formula"]})|float'
|
|
96
96
|
)
|
|
97
97
|
power_expr = env.compile_expression(
|
|
98
|
-
f'({self._input["rules"]["power_formula"]})|float
|
|
98
|
+
f'({self._input["rules"]["power_formula"]})|float'
|
|
99
99
|
)
|
|
100
100
|
others_expr = env.compile_expression(
|
|
101
|
-
f'({self._input["rules"]["others_formula"]})|float
|
|
101
|
+
f'({self._input["rules"]["others_formula"]})|float'
|
|
102
102
|
)
|
|
103
103
|
surplus_expr = env.compile_expression(
|
|
104
|
-
f'({self._input["rules"]["surplus_formula"]})|float
|
|
104
|
+
f'({self._input["rules"]["surplus_formula"]})|float'
|
|
105
105
|
)
|
|
106
106
|
main_expr = env.compile_expression(
|
|
107
|
-
f'({self._input["rules"]["main_formula"]})|float
|
|
107
|
+
f'({self._input["rules"]["main_formula"]})|float'
|
|
108
108
|
)
|
|
109
109
|
|
|
110
110
|
_data = sorted([_data[x] for x in _data], key=lambda x: x["datetime"])
|
|
@@ -136,10 +136,10 @@ class BillingProcessor(Processor):
|
|
|
136
136
|
_surplus_term = 0
|
|
137
137
|
|
|
138
138
|
with contextlib.suppress(Exception):
|
|
139
|
-
_energy_term = round(energy_expr(**x),
|
|
140
|
-
_power_term = round(power_expr(**x),
|
|
141
|
-
_others_term = round(others_expr(**x),
|
|
142
|
-
_surplus_term = round(surplus_expr(**x),
|
|
139
|
+
_energy_term = round(energy_expr(**x), 6)
|
|
140
|
+
_power_term = round(power_expr(**x), 6)
|
|
141
|
+
_others_term = round(others_expr(**x), 6)
|
|
142
|
+
_surplus_term = round(surplus_expr(**x), 6)
|
|
143
143
|
|
|
144
144
|
new_item = PricingAggData(
|
|
145
145
|
datetime=x["datetime"],
|
|
@@ -208,8 +208,8 @@ class BillingProcessor(Processor):
|
|
|
208
208
|
|
|
209
209
|
for item in self._output:
|
|
210
210
|
for cost in self._output[item]:
|
|
211
|
-
cost["
|
|
212
|
-
cost["
|
|
213
|
-
cost["
|
|
214
|
-
cost["
|
|
215
|
-
cost["
|
|
211
|
+
cost["value_eur"] = round(main_expr(**cost, **self._input["rules"]), 6)
|
|
212
|
+
cost["energy_term"] = round(cost["energy_term"], 6)
|
|
213
|
+
cost["power_term"] = round(cost["power_term"], 6)
|
|
214
|
+
cost["others_term"] = round(cost["others_term"], 6)
|
|
215
|
+
cost["surplus_term"] = round(cost["surplus_term"], 6)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|