summaryrefslogtreecommitdiffstats
path: root/src/discover.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/discover.py')
-rw-r--r--src/discover.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/discover.py b/src/discover.py
index 1632af6..e2351b3 100644
--- a/src/discover.py
+++ b/src/discover.py
@@ -1,15 +1,27 @@
import asyncio
from bleak import BleakScanner
+import os
-async def discover():
+async def discover(debug=False):
try:
devices = await BleakScanner.discover()
- return [{"name": device.name, "address": device.address} for device in devices]
+ if debug:
+ return [{"name": device.name, "address": device.address} for device in devices]
+ else:
+ return [
+ {"name": device.name, "address": device.address}
+ for device in devices
+ if device.name and "TP350S" in device.name
+ ]
except Exception:
return []
async def main():
- devices = await discover()
+ check_debug = os.getenv("DEBUG", "FALSE").upper() == "TRUE"
+ if check_debug:
+ print("DEBUG MODE ENABLED")
+ devices = await discover(debug=check_debug)
+
print(devices)
if __name__ == "__main__":
git.ajschof.me — hosted by ajschofield — powered by cgit