-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsync_addoutput.py
37 lines (30 loc) · 985 Bytes
/
sync_addoutput.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
34
35
36
37
""" synchronous addoutput example """
import datetime
import json
from typing import Any, Dict
from pvoutput import PVOutput
def get_apikey_systemid_sync() -> Dict[str, Any]:
"""non-asyncio config loader"""
with open("pvoutput.json", "r", encoding="utf8") as config_file:
config_data: Dict[str, Any] = json.load(config_file)
return config_data
def main() -> None:
"""main func"""
configuration = get_apikey_systemid_sync()
pvo = PVOutput(
apikey=configuration["apikey"],
systemid=configuration["systemid"],
donation_made=configuration["donation_made"],
)
testdate = datetime.date.today()
data = {
"d": testdate.strftime("%Y%m%d"),
"g": 500, # Generated (Wh)
"e": 450, # Exported (Wh)
}
print("Adding output")
result = pvo.addoutput(data)
print(f"Status code: {result.status_code}")
print(f"Response content: '{result.text}'")
if __name__ == "__main__":
main()