From 7bf53aaefb9e18c51b78b596e74290d8dd00025c Mon Sep 17 00:00:00 2001 From: Wentao Wu Date: Mon, 24 Mar 2025 09:15:53 +0000 Subject: [PATCH 1/4] fix(cloud): switch default cloud from SmartHome to Nethome Plus --- midealocal/cloud.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/midealocal/cloud.py b/midealocal/cloud.py index 872e53b7..d39c52a5 100644 --- a/midealocal/cloud.py +++ b/midealocal/cloud.py @@ -43,7 +43,6 @@ "api_url": "https://mp-prod.smartmidea.net/mas/v5/app/proxy?alias=", }, "SmartHome": { - "default": True, "class_name": "SmartHomeCloud", "app_id": "1010", "app_key": "ac21b9f9cbfe4ca5a88562ef25e2b768", @@ -60,6 +59,7 @@ "api_url": "https://mapp.appsmb.com", # codespell:ignore }, "NetHome Plus": { + "default": True, "class_name": "MideaAirCloud", "app_id": "1017", "app_key": "3742e9e5842d4ad59c2db887e12449f9", @@ -83,7 +83,7 @@ PRESET_ACCOUNT_DATA = [ 39182118275972017797890111985649342047468653967530949796945843010512, - 29406100301096535908214728322278519471982973450672552249652548883645, + 31845298206154645013606382739815191713578899113473062752925712789965, 39182118275972017797890111985649342050088014265865102175083010656997, ] From 4e2e3083e21f64486eadf06c34dd385551333433 Mon Sep 17 00:00:00 2001 From: Wentao Wu Date: Mon, 24 Mar 2025 09:27:24 +0000 Subject: [PATCH 2/4] chore(cloud): fix cloud test case --- tests/cloud_test.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/cloud_test.py b/tests/cloud_test.py index dbfae2a8..5841e56c 100644 --- a/tests/cloud_test.py +++ b/tests/cloud_test.py @@ -60,7 +60,7 @@ def test_get_midea_cloud(self) -> None: async def test_get_default_cloud(self) -> None: """Test get default cloud name.""" default_cloud = get_default_cloud() - assert default_cloud == "SmartHome" + assert default_cloud == "NetHome Plus" async def test_get_cloud_servers(self) -> None: """Test get cloud servers.""" @@ -70,9 +70,8 @@ async def test_get_cloud_servers(self) -> None: async def test_get_preset_account_cloud(self) -> None: """Test get preset cloud account.""" credentials = get_preset_account_cloud() - assert credentials["username"] == "c414e631394b8639@outlook.com" assert credentials["password"] == "a0d6e30c94b15" - assert credentials["cloud_name"] == "SmartHome" + assert credentials["cloud_name"] == "NetHome Plus" async def test_midea_cloud_unimplemented(self) -> None: """Test unimplemented MideaCloud methods.""" From 5497615278f320feea229dd71450152fede172bd Mon Sep 17 00:00:00 2001 From: Wentao Wu Date: Mon, 24 Mar 2025 10:16:17 +0000 Subject: [PATCH 3/4] fix(cloud): fix username and password --- midealocal/cloud.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/midealocal/cloud.py b/midealocal/cloud.py index d39c52a5..9678b5b3 100644 --- a/midealocal/cloud.py +++ b/midealocal/cloud.py @@ -83,7 +83,7 @@ PRESET_ACCOUNT_DATA = [ 39182118275972017797890111985649342047468653967530949796945843010512, - 31845298206154645013606382739815191713578899113473062752925712789965, + 39182118275980892824833804202177448991093361348247890162501600564413, 39182118275972017797890111985649342050088014265865102175083010656997, ] @@ -100,10 +100,10 @@ def get_preset_account_cloud() -> dict[str, str]: """Return preset account data for cloud login.""" username: str = bytes.fromhex( format((PRESET_ACCOUNT_DATA[0] ^ PRESET_ACCOUNT_DATA[1]), "X"), - ).decode("ASCII") + ).decode("utf-8", errors="ignore") password: str = bytes.fromhex( format((PRESET_ACCOUNT_DATA[0] ^ PRESET_ACCOUNT_DATA[2]), "X"), - ).decode("ASCII") + ).decode("utf-8", errors="ignore") return { "username": username, From ef1a63a1e6dcfcd4dc950b31d96540df535bd756 Mon Sep 17 00:00:00 2001 From: Wentao Wu Date: Mon, 24 Mar 2025 10:22:28 +0000 Subject: [PATCH 4/4] chore(cloud): fix cli test cloud testcase --- tests/cli_test.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/cli_test.py b/tests/cli_test.py index 986390a3..fa2cdbf3 100644 --- a/tests/cli_test.py +++ b/tests/cli_test.py @@ -13,7 +13,7 @@ MideaCLI, get_config_file_path, ) -from midealocal.cloud import SmartHomeCloud +from midealocal.cloud import MideaAirCloud, SmartHomeCloud from midealocal.const import ProtocolVersion from midealocal.device import AuthException, NoSupportedProtocol from midealocal.exceptions import SocketException @@ -56,9 +56,10 @@ async def test_get_cloud(self) -> None: assert cloud._password == self.namespace.password assert cloud._session == mock_session_instance + # test default cloud self.namespace.cloud_name = None cloud = await self.cli._get_cloud() - assert isinstance(cloud, SmartHomeCloud) + assert isinstance(cloud, MideaAirCloud) assert cloud._session == mock_session_instance async def test_get_keys(self) -> None: