-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.py
33 lines (24 loc) · 1.15 KB
/
Main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from linkpy import Linky, LinkyLoginException, LinkyServiceException
import datetime
from dateutil.relativedelta import relativedelta
def get_data_daily(deb,fin):
try:
res_hour = linky.get_data_per_hour(deb, fin)
dte_deb=datetime.datetime.strptime(res_hour['graphe']['periode']['dateDebut'], "%d/%m/%Y")
dte_current=dte_deb
for point in res_hour['graphe']['data']:
print(dte_current.strftime("%d/%m/%Y %H:%M:%S")+';'+str(point['ordre'])+';'+str(point['valeur']/2))
dte_current=dte_current+relativedelta(minutes=30)
except LinkyLoginException as exc:
logging.error(exc)
except LinkyServiceException as exc:
logging.error(exc)
#main
linky = Linky()
linky.login(USER, PASS) # Ici, log (email) et mot de passe de votre compte Enedis
date_deb=datetime.datetime(2019,11,1) # ici les dates de début et de fin de la période que vous voulez exporter
date_fin=datetime.datetime(2019,11,30)
print("Date;ordre;cons")
while date_deb<=date_fin:
get_data_daily(date_deb.strftime("%d/%m/%Y"),(date_deb+relativedelta(days=1)).strftime("%d/%m/%Y"))
date_deb=date_deb+relativedelta(days=1)