-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.py
More file actions
48 lines (32 loc) · 1.61 KB
/
example.py
File metadata and controls
48 lines (32 loc) · 1.61 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""Example of using python-frank-energie."""
import asyncio
import os
from datetime import datetime, timedelta
from python_frank_energie import FrankEnergie
async def main():
"""Fetch and print data from Frank energie."""
today = datetime.utcnow().date()
tomorrow = today + timedelta(days=1)
day_after_tomorrow = today + timedelta(days=2)
async with FrankEnergie() as fe:
prices_today = await fe.prices(today, tomorrow)
prices_tomorrow = await fe.prices(tomorrow, day_after_tomorrow)
for price in (prices_today.electricity + prices_tomorrow.electricity).all:
print(f"Electricity: {price.date_from} -> {price.date_till}: {price.total}")
for price in (prices_today.gas + prices_tomorrow.gas).all:
print(f"Gas: {price.date_from} -> {price.date_till}: {price.total}")
async with FrankEnergie() as fe:
authToken = await fe.login(os.getenv("USERNAME"), os.getenv("PASSWORD"))
user_prices_today = await fe.userPrices(today)
user_prices_tomorrow = await fe.userPrices(tomorrow)
for price in (
user_prices_today.electricity + user_prices_tomorrow.electricity
).all:
print(f"Electricity: {price.date_from} -> {price.date_till}: {price.total}")
for price in (user_prices_today.gas + user_prices_tomorrow.gas).all:
print(f"Gas: {price.date_from} -> {price.date_till}: {price.total}")
print(await fe.monthSummary())
async with FrankEnergie(auth_token=authToken.authToken) as fe:
print(await fe.monthSummary())
print(await fe.me())
asyncio.run(main())