Skip to content

fix(cloud): switch default cloud from SmartHome to Nethome Plus #360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions midealocal/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -83,7 +83,7 @@

PRESET_ACCOUNT_DATA = [
39182118275972017797890111985649342047468653967530949796945843010512,
29406100301096535908214728322278519471982973450672552249652548883645,
39182118275980892824833804202177448991093361348247890162501600564413,
39182118275972017797890111985649342050088014265865102175083010656997,
]

Expand All @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions tests/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions tests/cloud_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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."""
Expand Down