You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
508 B
22 lines
508 B
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() |
|
|
|
|