Fix OpenWrt Wi-Fi client parsing
This commit is contained in:
@@ -141,8 +141,9 @@ def _parse_hostapd_clients(raw: str, ifname: str) -> list[str]:
|
|||||||
if not isinstance(meta, dict):
|
if not isinstance(meta, dict):
|
||||||
continue
|
continue
|
||||||
signal = meta.get("signal")
|
signal = meta.get("signal")
|
||||||
rx = _format_rate((meta.get("rx") or {}).get("rate"))
|
rate = meta.get("rate") or {}
|
||||||
tx = _format_rate((meta.get("tx") or {}).get("rate"))
|
rx = _format_rate((rate or {}).get("rx"))
|
||||||
|
tx = _format_rate((rate or {}).get("tx"))
|
||||||
sig = f"{signal}dBm" if isinstance(signal, (int, float)) else "?"
|
sig = f"{signal}dBm" if isinstance(signal, (int, float)) else "?"
|
||||||
clients.append(f"{ifname} {mac} {sig} rx:{rx} tx:{tx}")
|
clients.append(f"{ifname} {mac} {sig} rx:{rx} tx:{tx}")
|
||||||
return clients
|
return clients
|
||||||
@@ -266,7 +267,7 @@ async def get_openwrt_status(cfg: dict[str, Any]) -> str:
|
|||||||
"-c",
|
"-c",
|
||||||
f"ubus call hostapd.{ifname} get_clients 2>/dev/null || echo '{{}}'",
|
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:
|
if rc2 == 124:
|
||||||
return f"⚠️ OpenWrt SSH error (wifi clients {ifname}): timeout"
|
return f"⚠️ OpenWrt SSH error (wifi clients {ifname}): timeout"
|
||||||
if rc2 == 0 and out2.strip():
|
if rc2 == 0 and out2.strip():
|
||||||
|
|||||||
Reference in New Issue
Block a user