fix: filter scanner BT MACs during BLE Radar import
- Skip devices whose address matches a registered peer's bt_mac - Prevents scanners from appearing as regular devices - Shows count of filtered scanners in import stats Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -62,6 +62,18 @@ def import_ble_radar_db(
|
||||
if verbose:
|
||||
print(f"Importing from: {ble_radar_path}")
|
||||
|
||||
# Get scanner BT MACs to filter out (don't import scanners as devices)
|
||||
scanner_bt_macs = set()
|
||||
peers = rf_mapper_db.get_peers()
|
||||
for peer in peers:
|
||||
if peer.get("bt_mac"):
|
||||
scanner_bt_macs.add(peer["bt_mac"].upper())
|
||||
|
||||
if verbose and scanner_bt_macs:
|
||||
print(f"Filtering {len(scanner_bt_macs)} scanner BT MAC(s)")
|
||||
|
||||
stats["scanners_filtered"] = 0
|
||||
|
||||
# Get location data for device-location mapping
|
||||
ble_cursor.execute("SELECT time, lat, lng FROM location ORDER BY time")
|
||||
locations = {row["time"]: (row["lat"], row["lng"]) for row in ble_cursor.fetchall()}
|
||||
@@ -85,6 +97,14 @@ def import_ble_radar_db(
|
||||
for row in ble_cursor.fetchall():
|
||||
try:
|
||||
address = row["address"]
|
||||
|
||||
# Skip scanner devices (don't import scanners as regular devices)
|
||||
if address.upper() in scanner_bt_macs:
|
||||
stats["scanners_filtered"] += 1
|
||||
if verbose:
|
||||
print(f"Skipping scanner: {address}")
|
||||
continue
|
||||
|
||||
name = row["custom_name"] or row["name"] or ""
|
||||
manufacturer = row["manufacturer_name"] or ""
|
||||
rssi = row["last_seen_rssi"] or -70
|
||||
@@ -147,6 +167,8 @@ def import_ble_radar_db(
|
||||
print(f" Devices updated: {stats['devices_updated']}")
|
||||
print(f" RSSI records: {stats['rssi_records']}")
|
||||
print(f" Locations used: {stats['locations_used']}")
|
||||
if stats.get("scanners_filtered"):
|
||||
print(f" Scanners skipped: {stats['scanners_filtered']}")
|
||||
if stats["errors"]:
|
||||
print(f" Errors: {stats['errors']}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user