-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhistorical_data.py
29 lines (24 loc) · 958 Bytes
/
historical_data.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
from viessmann_gridbox_connector import GridboxConnector
from importlib.resources import files
from datetime import datetime, timezone, timedelta
import json
import time
import urllib.parse
now = datetime.now(timezone(timedelta(hours=1)))
now = now.replace(hour=0, minute=0, second=0, microsecond=0)
today = now.isoformat()
tomorrow = now + timedelta(days=1)
loop = False
config_file = files('viessmann_gridbox_connector').joinpath('config.json')
with open(config_file, 'r') as file:
data = json.load(file)
data["login"]["username"] = "username"
data["login"]["password"] = "password"
connector = GridboxConnector(data)
# Retrieve live data
historical_data = connector.retrieve_historical_data(start=today, end=tomorrow.isoformat())
print(historical_data)
while loop:
historical_data = connector.retrieve_historical_data(start=today, end=tomorrow.isoformat())
print(historical_data)
time.sleep(60)