feat: Log new devices with '(new)' suffix

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2025-12-30 23:58:59 +00:00
parent 6ec536a964
commit 61eb680695

View File

@@ -13,6 +13,8 @@ BLUEZ_SERVICE = 'org.bluez'
ADAPTER_IFACE = 'org.bluez.Adapter1' ADAPTER_IFACE = 'org.bluez.Adapter1'
DEVICE_IFACE = 'org.bluez.Device1' DEVICE_IFACE = 'org.bluez.Device1'
seen_devices = set()
async def get_adapter(bus): async def get_adapter(bus):
"""Gets the first Bluetooth adapter found.""" """Gets the first Bluetooth adapter found."""
introspection = await bus.introspect(BLUEZ_SERVICE, '/') introspection = await bus.introspect(BLUEZ_SERVICE, '/')
@@ -33,7 +35,12 @@ def on_interfaces_added(path, interfaces):
address = device_properties.get('Address') address = device_properties.get('Address')
alias = device_properties.get('Alias') alias = device_properties.get('Alias')
if address and alias and alias.value: if address and alias and alias.value:
logging.info(f"Found: {alias.value} ({address.value})") addr_str = address.value
if addr_str not in seen_devices:
seen_devices.add(addr_str)
logging.info(f"Found: {alias.value} ({addr_str}) (new)")
else:
logging.info(f"Found: {alias.value} ({addr_str})")
async def main(): async def main():
"""Main function to run the scanner.""" """Main function to run the scanner."""