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
|
"""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:
try:
gios = await Gios.create(websession, GIOS_STATION_ID)
data = await gios.async_update()
except (
ApiError,
NoStationError,
InvalidSensorsDataError,
ClientError,
) as error:
print(error)
return
print(f"Measurement stations: {gios.measurement_stations}")
print(f"Station: {gios.station_name} ({gios.latitude}, {gios.longitude})")
print(data)
loop = asyncio.new_event_loop()
loop.run_until_complete(main())
loop.close()
|