From f1baef071b479db3d9259f064a86f1a5af93a097 Mon Sep 17 00:00:00 2001 From: Mactar Gueye Date: Thu, 5 Jun 2025 12:12:31 -0700 Subject: [PATCH 1/2] Enhance discover_limelights to optionally return device names and added get_ip_by_name function to lib --- limelightlib-python/limelight.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/limelightlib-python/limelight.py b/limelightlib-python/limelight.py index 84dc41a..f37c55a 100644 --- a/limelightlib-python/limelight.py +++ b/limelightlib-python/limelight.py @@ -50,9 +50,28 @@ def listen_for_responses(port,timeout=1): pass return discovered_devices -def discover_limelights(broadcast_port=5809, listen_port=5809, timeout=2, debug=False): +def discover_limelights(broadcast_port=5809, listen_port=5809, timeout=2, debug=False, return_names=False): broadcast_on_all_interfaces("LLPhoneHome",broadcast_port,debug) - return listen_for_responses(listen_port,timeout) + ips = listen_for_responses(listen_port, timeout) + + results = [] + for ip in ips: + name = None + if return_names: + try: + ll = Limelight(ip) + name = ll.get_name() + except Exception as e: + if debug: + print(f"Failed to get name for {ip}: {e}") + results.append({"ip": ip, "name": name}) + return results + +def get_ip_by_name(discovered, name): + for entry in discovered: + if entry["name"] == name: + return entry["ip"] + return None class Limelight: def __init__(self, address): From 0a16f3b310005023c7b904c5f95e86b85b706c42 Mon Sep 17 00:00:00 2001 From: Mactar Gueye Date: Thu, 5 Jun 2025 12:28:44 -0700 Subject: [PATCH 2/2] Add get_name_by_ip function to retrieve device names by IP address --- limelightlib-python/limelight.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/limelightlib-python/limelight.py b/limelightlib-python/limelight.py index f37c55a..a661269 100644 --- a/limelightlib-python/limelight.py +++ b/limelightlib-python/limelight.py @@ -73,6 +73,12 @@ def get_ip_by_name(discovered, name): return entry["ip"] return None +def get_name_by_ip(discovered, ip_address): + for entry in discovered: + if entry["ip"] == ip_address: + return entry["name"] + return None + class Limelight: def __init__(self, address): self.base_url = f"http://{address}:5807"