From a029bbfa7a56e5f0eaf44a77ee859ae7a9fb021b Mon Sep 17 00:00:00 2001 From: benya Date: Sun, 8 Feb 2026 03:12:33 +0300 Subject: [PATCH] Fix OpenWrt Wi-Fi client parsing --- services/openwrt.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/services/openwrt.py b/services/openwrt.py index 40ffee4..32b6f96 100644 --- a/services/openwrt.py +++ b/services/openwrt.py @@ -141,8 +141,9 @@ def _parse_hostapd_clients(raw: str, ifname: str) -> list[str]: if not isinstance(meta, dict): continue signal = meta.get("signal") - rx = _format_rate((meta.get("rx") or {}).get("rate")) - tx = _format_rate((meta.get("tx") or {}).get("rate")) + rate = meta.get("rate") or {} + rx = _format_rate((rate or {}).get("rx")) + tx = _format_rate((rate or {}).get("tx")) sig = f"{signal}dBm" if isinstance(signal, (int, float)) else "?" clients.append(f"{ifname} {mac} {sig} rx:{rx} tx:{tx}") return clients @@ -266,7 +267,7 @@ async def get_openwrt_status(cfg: dict[str, Any]) -> str: "-c", f"ubus call hostapd.{ifname} get_clients 2>/dev/null || echo '{{}}'", ] - rc2, out2 = await run_cmd(cmd_clients, timeout=timeout_sec + 15) + rc2, out2 = await run_cmd_full(cmd_clients, timeout=timeout_sec + 15) if rc2 == 124: return f"⚠️ OpenWrt SSH error (wifi clients {ifname}): timeout" if rc2 == 0 and out2.strip():