Skip to content

Commit d12070d

Browse files
committed
Migrate to httpx
1 parent 61cec18 commit d12070d

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

example.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
11
"""Example for getting the data from a station."""
22
import asyncio
33

4-
import aiohttp
5-
64
from luftdaten import Luftdaten
75

8-
SENSOR_ID = 155
6+
SENSOR_ID = 152
97

108

119
async def main():
1210
"""Sample code to retrieve the data."""
13-
async with aiohttp.ClientSession() as session:
14-
data = Luftdaten(SENSOR_ID, loop, session)
15-
await data.get_data()
11+
data = Luftdaten(SENSOR_ID)
12+
await data.get_data()
1613

17-
if not await data.validate_sensor():
18-
print("Station is not available:", data.sensor_id)
19-
return
14+
if not await data.validate_sensor():
15+
print("Station is not available:", data.sensor_id)
16+
return
2017

21-
if data.values and data.meta:
22-
# Print the sensor values
23-
print("Sensor values:", data.values)
18+
if data.values and data.meta:
19+
# Print the sensor values
20+
print("Sensor values:", data.values)
2421

25-
# Print the coordinates fo the sensor
26-
print("Location:", data.meta['latitude'], data.meta['longitude'])
22+
# Print the coordinates fo the sensor
23+
print("Location:", data.meta["latitude"], data.meta["longitude"])
2724

2825

2926
loop = asyncio.get_event_loop()

0 commit comments

Comments
 (0)