From c5bd13ea52921c09d11c4a0ebd5ad3f59147e771 Mon Sep 17 00:00:00 2001 From: Smittix Date: Wed, 4 Feb 2026 23:31:54 +0000 Subject: [PATCH] Filter WiFi connected clients by selected access point The /wifi/v2/clients endpoint was returning all clients regardless of query parameters, because a duplicate route in wifi.py took precedence over the filtered one in wifi_v2.py. Added bssid, associated, and min_rssi filtering to the active route. Co-Authored-By: Claude Opus 4.5 --- routes/wifi.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/routes/wifi.py b/routes/wifi.py index 218b978..c6464b5 100644 --- a/routes/wifi.py +++ b/routes/wifi.py @@ -1240,10 +1240,32 @@ def v2_get_networks(): @wifi_bp.route('/v2/clients') def v2_get_clients(): - """Get all discovered clients.""" + """Get discovered clients with optional filtering.""" try: scanner = get_wifi_scanner() clients = scanner.clients + + # Filter by association status + associated = request.args.get('associated') + if associated == 'true': + clients = [c for c in clients if c.is_associated] + elif associated == 'false': + clients = [c for c in clients if not c.is_associated] + + # Filter by associated BSSID + bssid = request.args.get('bssid') + if bssid: + clients = [c for c in clients if c.associated_bssid == bssid.upper()] + + # Filter by minimum RSSI + min_rssi = request.args.get('min_rssi') + if min_rssi: + try: + min_rssi = int(min_rssi) + clients = [c for c in clients if c.rssi_current and c.rssi_current >= min_rssi] + except ValueError: + pass + return jsonify({ 'clients': [c.to_dict() for c in clients], 'total': len(clients),