-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
example.py
41 lines (31 loc) · 953 Bytes
/
example.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
39
40
41
"""Example for GIOS."""
import asyncio
import logging
from aiohttp import ClientError, ClientSession
from gios import ApiError, Gios, InvalidSensorsDataError, NoStationError
GIOS_STATION_ID = 568
logging.basicConfig(level=logging.DEBUG)
async def main() -> None:
"""Run main function."""
async with ClientSession() as websession:
gios = Gios(GIOS_STATION_ID, websession)
try:
data = await gios.async_update()
except (
ApiError,
NoStationError,
InvalidSensorsDataError,
ClientError,
) as error:
print(error)
return
latitude = gios.latitude
longitude = gios.longitude
station_name = gios.station_name
print(f"Longitude: {longitude}")
print(f"Latitude: {latitude}")
print(f"Station name: {station_name}")
print(data)
loop = asyncio.new_event_loop()
loop.run_until_complete(main())
loop.close()