Skip to content

Commit

Permalink
chore(cloud)!: rename MSmartHome (midea-lan#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
chemelli74 authored Oct 3, 2024
1 parent dc75a99 commit 20c796e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"type": "pickString",
"options": [
"美的美居",
"MSmartHome",
"SmartHome",
"Midea Air",
"NetHome Plus",
"Ariston Clima"
Expand Down
8 changes: 4 additions & 4 deletions midealocal/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
).decode(),
"api_url": "https://mp-prod.smartmidea.net/mas/v5/app/proxy?alias=",
},
"MSmartHome": {
"SmartHome": {
"default": True,
"class_name": "MSmartHomeCloud",
"class_name": "SmartHomeCloud",
"app_id": "1010",
"app_key": "ac21b9f9cbfe4ca5a88562ef25e2b768",
"iot_key": bytes.fromhex(format(7882822598523843940, "x")).decode(),
Expand Down Expand Up @@ -540,7 +540,7 @@ async def download_lua(
return str(fnm) if fnm else None


class MSmartHomeCloud(MideaCloud):
class SmartHomeCloud(MideaCloud):
"""MSmart Home Cloud."""

def __init__(
Expand Down Expand Up @@ -650,7 +650,7 @@ async def login(self) -> bool:
response["randomData"],
)
return True
_LOGGER.warning("MSmartHome Cloud login failed for device %s", self._device_id)
_LOGGER.warning("SmartHome Cloud login failed for device %s", self._device_id)
return False

async def list_appliances(
Expand Down
8 changes: 4 additions & 4 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 MSmartHomeCloud
from midealocal.cloud import SmartHomeCloud
from midealocal.const import ProtocolVersion
from midealocal.device import AuthException, NoSupportedProtocol
from midealocal.exceptions import SocketException
Expand All @@ -26,7 +26,7 @@ def setUp(self) -> None:
"""Create namespace for testing."""
self.cli = MideaCLI()
self.namespace = Namespace(
cloud_name="MSmartHome",
cloud_name="SmartHome",
username="user",
password="pass",
host="192.168.0.1",
Expand All @@ -50,14 +50,14 @@ async def test_get_cloud(self) -> None:
):
cloud = await self.cli._get_cloud()

assert isinstance(cloud, MSmartHomeCloud)
assert isinstance(cloud, SmartHomeCloud)
assert cloud._account == self.namespace.username
assert cloud._password == self.namespace.password
assert cloud._session == mock_session_instance

self.namespace.cloud_name = None
cloud = await self.cli._get_cloud()
assert isinstance(cloud, MSmartHomeCloud)
assert isinstance(cloud, SmartHomeCloud)
assert cloud._session == mock_session_instance

async def test_get_keys(self) -> None:
Expand Down
22 changes: 11 additions & 11 deletions tests/cloud_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
MeijuCloud,
MideaAirCloud,
MideaCloud,
MSmartHomeCloud,
SmartHomeCloud,
get_default_cloud,
get_midea_cloud,
get_preset_account_cloud,
Expand Down Expand Up @@ -42,8 +42,8 @@ def test_get_midea_cloud(self) -> None:
session = AsyncMock()
assert isinstance(get_midea_cloud("美的美居", session, "", ""), MeijuCloud)
assert isinstance(
get_midea_cloud("MSmartHome", session, "", ""),
MSmartHomeCloud,
get_midea_cloud("SmartHome", session, "", ""),
SmartHomeCloud,
)
assert isinstance(get_midea_cloud("Midea Air", session, "", ""), MideaAirCloud)
assert isinstance(
Expand All @@ -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 == "MSmartHome"
assert default_cloud == "SmartHome"

async def test_get_cloud_servers(self) -> None:
"""Test get cloud servers."""
Expand All @@ -72,7 +72,7 @@ async def test_get_preset_account_cloud(self) -> None:
credentials = get_preset_account_cloud()
assert credentials["username"] == "[email protected]"
assert credentials["password"] == "a0d6e30c94b15"
assert credentials["cloud_name"] == "MSmartHome"
assert credentials["cloud_name"] == "SmartHome"

async def test_midea_cloud_unimplemented(self) -> None:
"""Test unimplemented MideaCloud methods."""
Expand Down Expand Up @@ -380,7 +380,7 @@ async def test_msmartcloud_login_success(self) -> None:
)
session.request = AsyncMock(return_value=response)
cloud = get_midea_cloud(
"MSmartHome",
"SmartHome",
session=session,
account="account",
password="password",
Expand All @@ -397,7 +397,7 @@ async def test_msmartcloud_login_invalid_user(self) -> None:
)
session.request = AsyncMock(return_value=response)
cloud = get_midea_cloud(
"MSmartHome",
"SmartHome",
session=session,
account="account",
password="password",
Expand All @@ -409,7 +409,7 @@ async def test_msmartcloud_list_home(self) -> None:
"""Test MSmartCloud list_home."""
session = Mock()
cloud = get_midea_cloud(
"MSmartHome",
"SmartHome",
session=session,
account="account",
password="password",
Expand All @@ -434,7 +434,7 @@ async def test_msmartcloud_list_appliances(self) -> None:
)
session.request = AsyncMock(return_value=response)
cloud = get_midea_cloud(
"MSmartHome",
"SmartHome",
session=session,
account="account",
password="password",
Expand Down Expand Up @@ -485,7 +485,7 @@ async def test_msmartcloud_get_device_info(self) -> None:
)
session.request = AsyncMock(return_value=response)
cloud = get_midea_cloud(
"MSmartHome",
"SmartHome",
session=session,
account="account",
password="password",
Expand Down Expand Up @@ -525,7 +525,7 @@ async def test_msmartcloud_download_lua(self) -> None:
res.text = AsyncMock(return_value="4ABE0FE395F3AD3B6BC4D223F1ADFA7C")
session.get = AsyncMock(return_value=res)
cloud = get_midea_cloud(
"MSmartHome",
"SmartHome",
session=session,
account="account",
password="password",
Expand Down

0 comments on commit 20c796e

Please sign in to comment.