soakforjesus/rpiserver/w1therm.py

23 lines
508 B
Python

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()