fix: try the shade with the strongest signal first for the key

This commit is contained in:
Richard Mann
2026-04-11 17:25:33 +10:00
parent 0efca4ff52
commit 8a6a17b767

View File

@@ -111,7 +111,10 @@ async def _fetch_key_from_hub(
if not shades:
raise ValueError("No shades found on the hub")
ble_names = [s.get("bleName", "") for s in shades if s.get("bleName")]
# Sort by signal strength (strongest first) — a stronger signal means the
# hub is more likely to have an active BLE connection to that shade.
shades.sort(key=lambda s: s.get("signalStrength", -100), reverse=True)
ble_names = [s["bleName"] for s in shades if s.get("bleName")]
if not ble_names:
raise ValueError("No BLE-capable shades found on the hub")