From 62fcd200d6b42a6fc8f90c05f330ddc8ad9a8716 Mon Sep 17 00:00:00 2001 From: Simone Chemelli Date: Tue, 8 Oct 2024 08:06:19 +0200 Subject: [PATCH] fix: rename MSmartHome cloud (#348) --- .github/ISSUE_TEMPLATE/2-issue_en.yml | 2 +- custom_components/midea_ac_lan/config_flow.py | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/2-issue_en.yml b/.github/ISSUE_TEMPLATE/2-issue_en.yml index 1d01714..3e5b90a 100644 --- a/.github/ISSUE_TEMPLATE/2-issue_en.yml +++ b/.github/ISSUE_TEMPLATE/2-issue_en.yml @@ -32,7 +32,7 @@ body: required: true attributes: label: Working mobile app - placeholder: MSmartHome + placeholder: SmartHome description: Which mobile app is used to successfully control the device - type: textarea validations: diff --git a/custom_components/midea_ac_lan/config_flow.py b/custom_components/midea_ac_lan/config_flow.py index d697423..afe9f91 100644 --- a/custom_components/midea_ac_lan/config_flow.py +++ b/custom_components/midea_ac_lan/config_flow.py @@ -49,6 +49,7 @@ from homeassistant.util.json import load_json from midealocal.cloud import ( PRESET_ACCOUNT_DATA, + SUPPORTED_CLOUDS, MideaCloud, get_midea_cloud, ) @@ -88,6 +89,9 @@ "cache": "Remove login cache", } +# Select SmartHome from the list of supported cloud +SMARTHOME: str = list(SUPPORTED_CLOUDS)[1] + STORAGE_PATH = f".storage/{DOMAIN}" SKIP_LOGIN = "Skip Login (input any user/password)" @@ -127,7 +131,7 @@ def __init__(self) -> None: self.preset_password: str = bytes.fromhex( format((PRESET_ACCOUNT_DATA[0] ^ PRESET_ACCOUNT_DATA[2]), "X"), ).decode("ASCII") - self.preset_cloud_name: str = "MSmartHome" + self.preset_cloud_name: str = SMARTHOME def _save_device_config(self, data: dict[str, Any]) -> None: """Save device config to json file with device id.""" @@ -279,11 +283,11 @@ async def async_step_login( self.hass.data[DOMAIN] = {} # check skip login option if user_input[CONF_SERVER] == next(iter(default_keys)): - # use preset account and MSmartHome cloud + # use preset account and SMARTHOME cloud _LOGGER.debug("skip login matched, cloud_servers: %s", cloud_servers) - # get MSmartHome key from dict + # get SMARTHOME key from dict key = next( - key for key, value in cloud_servers.items() if value == "MSmartHome" + key for key, value in cloud_servers.items() if value == SMARTHOME ) cloud_server = cloud_servers[key] account = bytes.fromhex( @@ -473,7 +477,7 @@ async def _check_key_from_cloud( appliance_id: int, default_key: bool = True, ) -> dict[str, Any]: - """Use perset MSmartHome account to get v3 device token and key. + """Use perset SMARTHOME account to get v3 device token and key. Returns -------