parent
84a643e69c
commit
127c6ef91c
1 changed files with 22 additions and 0 deletions
@ -0,0 +1,22 @@ |
|||||||
|
import asyncio |
||||||
|
from w1thermsensor import AsyncW1ThermSensor, Unit |
||||||
|
|
||||||
|
async def get_temperatures(): |
||||||
|
temps = {} |
||||||
|
|
||||||
|
for sensor in AsyncW1ThermSensor.get_available_sensors(): |
||||||
|
temps[sensor.id] = await sensor.get_temperature() |
||||||
|
|
||||||
|
return temps |
||||||
|
|
||||||
|
async def test(): |
||||||
|
temps = await get_temperatures() |
||||||
|
|
||||||
|
for id_, temp in temps.items(): |
||||||
|
print('sensor', id_, ':' , temp, 'C') |
||||||
|
|
||||||
|
if __name__ == '__main__': |
||||||
|
loop = asyncio.get_event_loop() |
||||||
|
loop.run_until_complete(test()) |
||||||
|
loop.close() |
||||||
|
|
Loading…
Reference in new issue