-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcontrol.py
More file actions
57 lines (50 loc) · 2.15 KB
/
Copy pathcontrol.py
File metadata and controls
57 lines (50 loc) · 2.15 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
49
50
51
52
53
54
55
56
57
# pylint: disable=W0621
"""Asynchronous Python client for GeoSphere Austria weather data."""
import asyncio
import src.zamg.zamg
from src.zamg.exceptions import ZamgError
async def main():
"""Sample of getting data"""
try:
async with src.zamg.zamg.ZamgData() as zamg_instance:
# option to disable verify of ssl check
zamg_instance.verify_ssl = False
# trying to read GeoSphere Austria station id of the closest station
data = await zamg_instance.closest_station(46.99, 15.499)
# set closest station as default one to read
zamg_instance.set_default_station(data)
# print station location of the closest station
print("get_station_location = " + str(zamg_instance.get_station_location))
print(
"closest_station = "
+ str(zamg_instance.get_station_name)
+ " / "
+ str(data)
)
# print list with all possible parameters
print(f"Possible station parameters: {zamg_instance.get_all_parameters()}")
# set parameters directly
zamg_instance.station_parameters = "TL,SO"
# or set parameters as list
zamg_instance.set_parameters(("TL", "SO"))
# if none of the above parameters are set, all possible parameters are read
# do an update
await zamg_instance.update()
print(
f"---------- Weather for station {zamg_instance.get_station_name} ({data})"
)
for param in zamg_instance.get_parameters():
print(
str(param)
+ " -> "
+ str(zamg_instance.get_data(parameter=param, data_type="name"))
+ " -> "
+ str(zamg_instance.get_data(parameter=param))
+ " "
+ str(zamg_instance.get_data(parameter=param, data_type="unit"))
)
print(f"last update: {zamg_instance.last_update}")
except ZamgError as exc:
print(exc)
if __name__ == "__main__":
asyncio.run(main())