From 36b55ffc01a239b41454a76d8722bdab9498fdc9 Mon Sep 17 00:00:00 2001 From: matt Date: Wed, 21 Oct 2026 20:26:08 -0700 Subject: [PATCH] ble - put discovery back --- api/ble.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/api/ble.py b/api/ble.py index af6c771..05d819b 100644 --- a/api/ble.py +++ b/api/ble.py @@ -182,18 +182,18 @@ def _is_match(mac: str, name: str) -> bool: #################################################### async def read_data(mac: str) -> Optional[SensorReading]: -# try: -# address = await asyncio.wait_for( -# _discover_device(mac), -# timeout=DISCOVER_TIMEOUT, -# ) -# except asyncio.TimeoutError: -# log.warning("Device discovery timed out for %s after %.1fs", mac, DISCOVER_TIMEOUT) -# return None -# -# if not address: -# return None - address = mac + try: + address = await asyncio.wait_for( + _discover_device(mac), + timeout=DISCOVER_TIMEOUT, + ) + except asyncio.TimeoutError: + log.warning("Device discovery timed out for %s after %.1fs", mac, DISCOVER_TIMEOUT) + return None + + if not address: + return None + try: async with BleakClient(address, timeout=CONNECT_TIMEOUT) as client: # NEW BLOCK ----------------------------------------------