From 45c443c3131340b5c56a53d3331ea382bfc04782 Mon Sep 17 00:00:00 2001 From: The MinFengLin Date: Mon, 18 Dec 2023 12:19:16 +0800 Subject: [PATCH 1/3] Fix operating mode for RD03 model - Change xqnetwork/mode to xqnetwork/get_netmode Note: Old devices only check Xiaomi AIoT Router AX3600 --- README.md | 2 +- custom_components/miwifi/luci.py | 6 +++--- custom_components/miwifi/self_check.py | 2 +- custom_components/miwifi/updater.py | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 72ad086..3e86260 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Many more Xiaomi and Redmi routers supported by MiWiFi - `xqsystem/login` - Authorization; - `xqsystem/init_info` - Basic information about the router; - `misystem/status` - Basic information about the router. Diagnostic data, memory, temperature, etc; -- `xqnetwork/mode` - Operating mode. Repeater, Access Point, Mesh, etc. +- `xqnetwork/get_netmode` - Operating mode. Repeater, Access Point, Mesh, etc. ##### Additional - `misystem/topo_graph` - Topography, auto discovery does not work without it; diff --git a/custom_components/miwifi/luci.py b/custom_components/miwifi/luci.py index 8de7070..abc84eb 100644 --- a/custom_components/miwifi/luci.py +++ b/custom_components/miwifi/luci.py @@ -226,13 +226,13 @@ async def new_status(self) -> dict: return await self.get("misystem/newstatus") - async def mode(self) -> dict: - """xqnetwork/mode method. + async def netmode(self) -> dict: + """xqnetwork/get_netmode method. :return dict: dict with api data. """ - return await self.get("xqnetwork/mode") + return await self.get("xqnetwork/get_netmode") async def wifi_ap_signal(self) -> dict: """xqnetwork/wifiap_signal method. diff --git a/custom_components/miwifi/self_check.py b/custom_components/miwifi/self_check.py index 6bcddd5..9202cea 100644 --- a/custom_components/miwifi/self_check.py +++ b/custom_components/miwifi/self_check.py @@ -18,7 +18,7 @@ ("xqsystem/login", "🟢"), ("xqsystem/init_info", "🟢"), ("misystem/status", "status"), - ("xqnetwork/mode", "mode"), + ("xqnetwork/get_netmode", "netmode"), ("xqsystem/vpn_status", "vpn_status"), ("misystem/topo_graph", "topo_graph"), ("xqsystem/check_rom_update", "rom_update"), diff --git a/custom_components/miwifi/updater.py b/custom_components/miwifi/updater.py index 0c25cc6..3e7788d 100644 --- a/custom_components/miwifi/updater.py +++ b/custom_components/miwifi/updater.py @@ -594,11 +594,11 @@ async def _async_prepare_mode(self, data: dict) -> None: if data.get(ATTR_SENSOR_MODE, Mode.DEFAULT) == Mode.MESH: return - response: dict = await self.luci.mode() + response: dict = await self.luci.netmode() - if "mode" in response: + if "netmode" in response: with contextlib.suppress(ValueError): - data[ATTR_SENSOR_MODE] = Mode(int(response["mode"])) + data[ATTR_SENSOR_MODE] = Mode(int(response["netmode"])) return From 6abfa47e93f2ee229bbdba81869050aeeb5c8f62 Mon Sep 17 00:00:00 2001 From: MinfengLin Date: Mon, 18 Dec 2023 14:24:20 +0800 Subject: [PATCH 2/3] Add new device RD03 --- custom_components/miwifi/enum.py | 1 + 1 file changed, 1 insertion(+) diff --git a/custom_components/miwifi/enum.py b/custom_components/miwifi/enum.py index 5c36888..d404cb8 100644 --- a/custom_components/miwifi/enum.py +++ b/custom_components/miwifi/enum.py @@ -254,3 +254,4 @@ def __str__(self) -> str: RB08 = "rb08" # 2022.07.04 R4AV2 = "r4av2" # 2022 CB0401 = "cb0401" # 2022 + RD03 = "rd03" # 2023.12.18 From 024abbba3e204a94e5d0c7604c2fabffbb810cde Mon Sep 17 00:00:00 2001 From: MinfengLin Date: Mon, 18 Dec 2023 15:54:06 +0800 Subject: [PATCH 3/3] Change mesh value --- custom_components/miwifi/enum.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/custom_components/miwifi/enum.py b/custom_components/miwifi/enum.py index d404cb8..bd791a1 100644 --- a/custom_components/miwifi/enum.py +++ b/custom_components/miwifi/enum.py @@ -43,7 +43,8 @@ def __str__(self) -> str: DEFAULT = 0, "default" REPEATER = 1, "repeater" ACCESS_POINT = 2, "access_point" - MESH = 9, "mesh" + """ netmode:3 """ + MESH = 3, "mesh" class Connection(IntEnum):