Add driver for temperature probes

This commit is contained in:
Tanner Collin 2022-04-19 02:45:08 +01:00
parent 84a643e69c
commit 127c6ef91c

22
w1therm.py Normal file
View File

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