Fix OpenWrt Wi-Fi client parsing

This commit is contained in:
2026-02-08 03:12:33 +03:00
parent ad8a6bff69
commit a029bbfa7a

View File

@@ -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():