-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsync_addstatus.py
38 lines (32 loc) · 1.01 KB
/
sync_addstatus.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
38
""" addstatus example """
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", encoding="utf8") as config_file:
config_data: Dict[str, Any] = json.load(config_file)
return config_data
def main() -> None:
"""main cli"""
configuration = get_apikey_systemid_sync()
data = {
"v2": 500, # power generation
"v4": 450, # power consumption
"v5": 23.5, # temperature
"v6": 234.0, # voltage
"m1": "Testing", # custom message
}
pvo = PVOutput(
apikey=configuration["apikey"],
systemid=configuration["systemid"],
donation_made=configuration["donation_made"],
)
try:
response = pvo.addstatus(data)
print(response)
except Exception as err: # pylint: disable=broad-except
print(f"{err=}")
# print(response.request.method)
if __name__ == "__main__":
main()