From 127c6ef91c0d881111a251d98b237c8fd75695c7 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Tue, 19 Apr 2022 02:45:08 +0100 Subject: [PATCH] Add driver for temperature probes --- w1therm.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 w1therm.py diff --git a/w1therm.py b/w1therm.py new file mode 100644 index 0000000..d78374d --- /dev/null +++ b/w1therm.py @@ -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() +