Add driver for temperature probes
This commit is contained in:
parent
84a643e69c
commit
127c6ef91c
22
w1therm.py
Normal file
22
w1therm.py
Normal 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()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user