mirror of
https://github.com/home-assistant/core.git
synced 2026-08-07 05:46:41 +01:00
Rename Midea LAN to midea (#177125)
This commit is contained in:
Generated
+2
-2
@@ -1134,8 +1134,8 @@ CLAUDE.md @home-assistant/core
|
||||
/tests/components/metoffice/ @MrHarcombe @avee87
|
||||
/homeassistant/components/microbees/ @microBeesTech
|
||||
/tests/components/microbees/ @microBeesTech
|
||||
/homeassistant/components/midea_lan/ @chemelli74 @rokam @wuwentao
|
||||
/tests/components/midea_lan/ @chemelli74 @rokam @wuwentao
|
||||
/homeassistant/components/midea/ @chemelli74 @rokam @wuwentao
|
||||
/tests/components/midea/ @chemelli74 @rokam @wuwentao
|
||||
/homeassistant/components/miele/ @astrandb
|
||||
/tests/components/miele/ @astrandb
|
||||
/homeassistant/components/mikrotik/ @engrbm87 @chemelli74
|
||||
|
||||
+5
-5
@@ -1,4 +1,4 @@
|
||||
"""The Midea LAN integration."""
|
||||
"""The Midea integration."""
|
||||
|
||||
from midealocal.const import ProtocolVersion
|
||||
from midealocal.devices import device_selector
|
||||
@@ -18,13 +18,13 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryError, ConfigEntryNotReady
|
||||
|
||||
from .const import CONF_KEY, CONF_SUBTYPE
|
||||
from .entity import MideaLanConfigEntry
|
||||
from .entity import MideaConfigEntry
|
||||
|
||||
_PLATFORMS: list[Platform] = [Platform.CLIMATE]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: MideaLanConfigEntry) -> bool:
|
||||
"""Set up Midea LAN from a config entry."""
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: MideaConfigEntry) -> bool:
|
||||
"""Set up Midea from a config entry."""
|
||||
|
||||
data = entry.data
|
||||
device_id: int = data[CONF_DEVICE_ID]
|
||||
@@ -71,6 +71,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: MideaLanConfigEntry) ->
|
||||
return True
|
||||
|
||||
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: MideaLanConfigEntry) -> bool:
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: MideaConfigEntry) -> bool:
|
||||
"""Unload a config entry."""
|
||||
return await hass.config_entries.async_unload_platforms(entry, _PLATFORMS)
|
||||
+2
-2
@@ -45,7 +45,7 @@ from homeassistant.exceptions import ServiceValidationError
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
|
||||
from .const import DOMAIN, FanSpeed
|
||||
from .entity import MideaEntity, MideaLanConfigEntry
|
||||
from .entity import MideaConfigEntry, MideaEntity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -124,7 +124,7 @@ _SWING_STATE_MAP: dict[tuple[bool, bool], str] = {
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
config_entry: MideaLanConfigEntry,
|
||||
config_entry: MideaConfigEntry,
|
||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up climate entries."""
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
"""Config flow for Midea LAN."""
|
||||
"""Config flow for Midea."""
|
||||
|
||||
from operator import itemgetter
|
||||
from typing import Any, override
|
||||
@@ -47,7 +47,7 @@ def _connect_and_close(dm: MideaDevice) -> bool:
|
||||
dm.close_socket()
|
||||
|
||||
|
||||
class MideaLanConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
class MideaConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Define current integration setup steps.
|
||||
|
||||
Use ConfigFlow handle to support config entries
|
||||
@@ -58,7 +58,7 @@ class MideaLanConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
MINOR_VERSION = 1
|
||||
|
||||
def __init__(self) -> None:
|
||||
"""MideaLanConfigFlow class."""
|
||||
"""MideaConfigFlow class."""
|
||||
self.available_device: dict = {}
|
||||
self.devices: dict = {}
|
||||
self.found_device: dict[str, Any] = {}
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
"""Constants for the Midea LAN integration."""
|
||||
"""Constants for the Midea integration."""
|
||||
|
||||
from enum import IntEnum
|
||||
import logging
|
||||
|
||||
_LOGGER = logging.getLogger(__package__)
|
||||
|
||||
DOMAIN = "midea_lan"
|
||||
DOMAIN = "midea"
|
||||
|
||||
|
||||
CONF_KEY = "key"
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
"""Base entity for Midea Lan."""
|
||||
"""Base entity for Midea."""
|
||||
|
||||
import logging
|
||||
from typing import Any, override
|
||||
@@ -14,7 +14,7 @@ from .device_catalog import MIDEA_DEVICE_NAMES
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
type MideaLanConfigEntry = ConfigEntry[MideaDevice]
|
||||
type MideaConfigEntry = ConfigEntry[MideaDevice]
|
||||
|
||||
|
||||
class MideaEntity(Entity):
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"domain": "midea_lan",
|
||||
"name": "Midea LAN",
|
||||
"domain": "midea",
|
||||
"name": "Midea",
|
||||
"codeowners": ["@chemelli74", "@rokam", "@wuwentao"],
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/midea_lan",
|
||||
"documentation": "https://www.home-assistant.io/integrations/midea",
|
||||
"integration_type": "device",
|
||||
"iot_class": "local_polling",
|
||||
"loggers": ["midealocal"],
|
||||
+1
-1
@@ -93,7 +93,7 @@
|
||||
"manually": "Configure manually",
|
||||
"search": "Search automatically"
|
||||
},
|
||||
"title": "Set up Midea LAN"
|
||||
"title": "Set up Midea"
|
||||
}
|
||||
}
|
||||
},
|
||||
Generated
+1
-1
@@ -472,7 +472,7 @@ FLOWS = {
|
||||
"meteoclimatic",
|
||||
"metoffice",
|
||||
"microbees",
|
||||
"midea_lan",
|
||||
"midea",
|
||||
"miele",
|
||||
"mikrotik",
|
||||
"mill",
|
||||
|
||||
@@ -4341,8 +4341,8 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"midea_lan": {
|
||||
"name": "Midea LAN",
|
||||
"midea": {
|
||||
"name": "Midea",
|
||||
"integration_type": "device",
|
||||
"config_flow": true,
|
||||
"iot_class": "local_polling"
|
||||
|
||||
Generated
+1
-1
@@ -1588,7 +1588,7 @@ micloud==0.5
|
||||
# homeassistant.components.microbees
|
||||
microBeesPy==0.3.5
|
||||
|
||||
# homeassistant.components.midea_lan
|
||||
# homeassistant.components.midea
|
||||
midea-local==6.10.0
|
||||
|
||||
# homeassistant.components.mill
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Tests for the Midea LAN integration."""
|
||||
"""Tests for the Midea integration."""
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
@@ -12,11 +12,11 @@ from tests.common import MockConfigEntry
|
||||
async def setup_integration(
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, device: DummyDevice
|
||||
) -> None:
|
||||
"""Set up a Midea LAN config entry backed by a fake device."""
|
||||
"""Set up a Midea config entry backed by a fake device."""
|
||||
config_entry.add_to_hass(hass)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.midea_lan.device_selector",
|
||||
"homeassistant.components.midea.device_selector",
|
||||
return_value=device,
|
||||
):
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Fixtures for Midea LAN tests."""
|
||||
"""Fixtures for Midea tests."""
|
||||
|
||||
from collections.abc import Callable, Generator
|
||||
from typing import Any
|
||||
@@ -7,7 +7,7 @@ from unittest.mock import AsyncMock, patch
|
||||
from midealocal.const import DeviceType
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.midea_lan.const import CONF_KEY, CONF_SUBTYPE, DOMAIN
|
||||
from homeassistant.components.midea.const import CONF_KEY, CONF_SUBTYPE, DOMAIN
|
||||
from homeassistant.const import CONF_NAME, CONF_TOKEN, CONF_TYPE
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
@@ -144,7 +144,7 @@ def entity_entries(
|
||||
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||
"""Prevent loading the integration during config flow tests."""
|
||||
with patch(
|
||||
"homeassistant.components.midea_lan.async_setup_entry",
|
||||
"homeassistant.components.midea.async_setup_entry",
|
||||
return_value=True,
|
||||
) as mock_entry:
|
||||
yield mock_entry
|
||||
@@ -1,9 +1,9 @@
|
||||
"""Constants for Midea LAN tests."""
|
||||
"""Constants for Midea tests."""
|
||||
|
||||
from midealocal.const import ProtocolVersion
|
||||
|
||||
from homeassistant.components.midea_lan.const import CONF_KEY, CONF_SUBTYPE
|
||||
from homeassistant.components.midea_lan.device_catalog import MIDEA_DEVICE_NAMES
|
||||
from homeassistant.components.midea.const import CONF_KEY, CONF_SUBTYPE
|
||||
from homeassistant.components.midea.device_catalog import MIDEA_DEVICE_NAMES
|
||||
from homeassistant.const import (
|
||||
CONF_DEVICE_ID,
|
||||
CONF_IP_ADDRESS,
|
||||
+6
-6
@@ -61,7 +61,7 @@
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': None,
|
||||
'platform': 'midea_lan',
|
||||
'platform': 'midea',
|
||||
'previous_unique_id': None,
|
||||
'suggested_object_id': None,
|
||||
'supported_features': <ClimateEntityFeature: 441>,
|
||||
@@ -161,7 +161,7 @@
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Zone 1 thermostat',
|
||||
'platform': 'midea_lan',
|
||||
'platform': 'midea',
|
||||
'previous_unique_id': None,
|
||||
'suggested_object_id': None,
|
||||
'supported_features': <ClimateEntityFeature: 385>,
|
||||
@@ -233,7 +233,7 @@
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Zone 2 thermostat',
|
||||
'platform': 'midea_lan',
|
||||
'platform': 'midea',
|
||||
'previous_unique_id': None,
|
||||
'suggested_object_id': None,
|
||||
'supported_features': <ClimateEntityFeature: 385>,
|
||||
@@ -322,7 +322,7 @@
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': None,
|
||||
'platform': 'midea_lan',
|
||||
'platform': 'midea',
|
||||
'previous_unique_id': None,
|
||||
'suggested_object_id': None,
|
||||
'supported_features': <ClimateEntityFeature: 441>,
|
||||
@@ -414,7 +414,7 @@
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': None,
|
||||
'platform': 'midea_lan',
|
||||
'platform': 'midea',
|
||||
'previous_unique_id': None,
|
||||
'suggested_object_id': None,
|
||||
'supported_features': <ClimateEntityFeature: 385>,
|
||||
@@ -495,7 +495,7 @@
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': None,
|
||||
'platform': 'midea_lan',
|
||||
'platform': 'midea',
|
||||
'previous_unique_id': None,
|
||||
'suggested_object_id': None,
|
||||
'supported_features': <ClimateEntityFeature: 401>,
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Tests for midea_lan climate.py."""
|
||||
"""Tests for midea climate.py."""
|
||||
|
||||
from collections.abc import Callable
|
||||
from typing import Any
|
||||
@@ -43,7 +43,7 @@ from homeassistant.components.climate import (
|
||||
SWING_VERTICAL,
|
||||
HVACMode,
|
||||
)
|
||||
from homeassistant.components.midea_lan.climate import FAN_FULL_SPEED, FAN_SILENT
|
||||
from homeassistant.components.midea.climate import FAN_FULL_SPEED, FAN_SILENT
|
||||
from homeassistant.const import ATTR_ENTITY_ID
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ServiceValidationError
|
||||
+87
-87
@@ -1,23 +1,23 @@
|
||||
"""Tests for the Midea LAN config flow."""
|
||||
"""Tests for the Midea config flow."""
|
||||
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
from midealocal.const import DeviceType, ProtocolVersion
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.midea_lan.config_flow import (
|
||||
from homeassistant.components.midea.config_flow import (
|
||||
DEFAULT_CLOUD,
|
||||
LOGIN_MODE_ACCOUNT,
|
||||
LOGIN_MODE_PRESET,
|
||||
)
|
||||
from homeassistant.components.midea_lan.const import (
|
||||
from homeassistant.components.midea.const import (
|
||||
CONF_ACCOUNT,
|
||||
CONF_KEY,
|
||||
CONF_SERVER,
|
||||
CONF_SUBTYPE,
|
||||
DOMAIN,
|
||||
)
|
||||
from homeassistant.components.midea_lan.device_catalog import MIDEA_DEVICE_NAMES
|
||||
from homeassistant.components.midea.device_catalog import MIDEA_DEVICE_NAMES
|
||||
from homeassistant.config_entries import SOURCE_USER
|
||||
from homeassistant.const import (
|
||||
CONF_DEVICE,
|
||||
@@ -65,11 +65,11 @@ async def test_manual_flow_success(hass: HomeAssistant) -> None:
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.discover",
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
return_value=DISCOVERY_RESULT,
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaDevice",
|
||||
"homeassistant.components.midea.config_flow.MideaDevice",
|
||||
) as mock_midea_device,
|
||||
):
|
||||
mock_device = MagicMock()
|
||||
@@ -124,11 +124,11 @@ async def test_manual_flow_duplicate_unique_id(hass: HomeAssistant) -> None:
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.discover",
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
return_value=DISCOVERY_RESULT,
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaDevice",
|
||||
"homeassistant.components.midea.config_flow.MideaDevice",
|
||||
) as mock_midea_device,
|
||||
):
|
||||
mock_device = MagicMock()
|
||||
@@ -313,23 +313,23 @@ async def test_manual_step_errors(
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.discover",
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
return_value=discover_result,
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaDevice",
|
||||
"homeassistant.components.midea.config_flow.MideaDevice",
|
||||
return_value=dm,
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.async_get_clientsession",
|
||||
"homeassistant.components.midea.config_flow.async_get_clientsession",
|
||||
return_value=object(),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.get_midea_cloud",
|
||||
"homeassistant.components.midea.config_flow.get_midea_cloud",
|
||||
return_value=cloud,
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaCloud.get_default_keys",
|
||||
"homeassistant.components.midea.config_flow.MideaCloud.get_default_keys",
|
||||
AsyncMock(return_value=default_keys_return),
|
||||
),
|
||||
):
|
||||
@@ -409,14 +409,14 @@ async def test_manual_step_retries_discovery_after_mismatch(
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.discover",
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
side_effect=[
|
||||
{TEST_DEVICE_ID + 1: {**BASE_DATA, CONF_TYPE: TEST_TYPE}},
|
||||
DISCOVERY_RESULT,
|
||||
],
|
||||
) as mock_discover,
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaDevice",
|
||||
"homeassistant.components.midea.config_flow.MideaDevice",
|
||||
return_value=dm,
|
||||
),
|
||||
):
|
||||
@@ -461,7 +461,7 @@ async def test_search_flow_no_new_devices_found(hass: HomeAssistant) -> None:
|
||||
assert result["step_id"] == "search"
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.midea_lan.config_flow.discover",
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
return_value=DISCOVERY_RESULT,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -491,7 +491,7 @@ async def test_auto_flow_cloud_device_info_overrides_name_and_subtype(
|
||||
user_input={"next_step_id": "search"},
|
||||
)
|
||||
with patch(
|
||||
"homeassistant.components.midea_lan.config_flow.discover",
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
return_value=mock_devices,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -520,19 +520,19 @@ async def test_auto_flow_cloud_device_info_overrides_name_and_subtype(
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.async_get_clientsession",
|
||||
"homeassistant.components.midea.config_flow.async_get_clientsession",
|
||||
return_value=object(),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.get_midea_cloud",
|
||||
"homeassistant.components.midea.config_flow.get_midea_cloud",
|
||||
return_value=cloud,
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaCloud.get_default_keys",
|
||||
"homeassistant.components.midea.config_flow.MideaCloud.get_default_keys",
|
||||
AsyncMock(return_value={}),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaDevice",
|
||||
"homeassistant.components.midea.config_flow.MideaDevice",
|
||||
return_value=dm,
|
||||
),
|
||||
):
|
||||
@@ -565,7 +565,7 @@ async def test_auto_flow_v3_preset_phase1_cloud_keys_success(
|
||||
user_input={"next_step_id": "search"},
|
||||
)
|
||||
with patch(
|
||||
"homeassistant.components.midea_lan.config_flow.discover",
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
return_value=mock_devices,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -592,19 +592,19 @@ async def test_auto_flow_v3_preset_phase1_cloud_keys_success(
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.async_get_clientsession",
|
||||
"homeassistant.components.midea.config_flow.async_get_clientsession",
|
||||
return_value=object(),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.get_midea_cloud",
|
||||
"homeassistant.components.midea.config_flow.get_midea_cloud",
|
||||
return_value=cloud,
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaCloud.get_default_keys",
|
||||
"homeassistant.components.midea.config_flow.MideaCloud.get_default_keys",
|
||||
AsyncMock(return_value={}),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaDevice",
|
||||
"homeassistant.components.midea.config_flow.MideaDevice",
|
||||
return_value=dm,
|
||||
),
|
||||
):
|
||||
@@ -636,7 +636,7 @@ async def test_auto_flow_v3_preset_phase1_default_key_success(
|
||||
user_input={"next_step_id": "search"},
|
||||
)
|
||||
with patch(
|
||||
"homeassistant.components.midea_lan.config_flow.discover",
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
return_value=mock_devices,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -661,19 +661,19 @@ async def test_auto_flow_v3_preset_phase1_default_key_success(
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.async_get_clientsession",
|
||||
"homeassistant.components.midea.config_flow.async_get_clientsession",
|
||||
return_value=object(),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.get_midea_cloud",
|
||||
"homeassistant.components.midea.config_flow.get_midea_cloud",
|
||||
return_value=cloud,
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaCloud.get_default_keys",
|
||||
"homeassistant.components.midea.config_flow.MideaCloud.get_default_keys",
|
||||
AsyncMock(return_value={"builtin": {"token": TEST_TOKEN, "key": TEST_KEY}}),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaDevice",
|
||||
"homeassistant.components.midea.config_flow.MideaDevice",
|
||||
return_value=dm,
|
||||
),
|
||||
):
|
||||
@@ -703,7 +703,7 @@ async def test_auto_flow_v3_token_retrieval_exhausted(hass: HomeAssistant) -> No
|
||||
user_input={"next_step_id": "search"},
|
||||
)
|
||||
with patch(
|
||||
"homeassistant.components.midea_lan.config_flow.discover",
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
return_value=mock_devices,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -736,19 +736,19 @@ async def test_auto_flow_v3_token_retrieval_exhausted(hass: HomeAssistant) -> No
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.async_get_clientsession",
|
||||
"homeassistant.components.midea.config_flow.async_get_clientsession",
|
||||
return_value=object(),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.get_midea_cloud",
|
||||
"homeassistant.components.midea.config_flow.get_midea_cloud",
|
||||
return_value=cloud,
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaCloud.get_default_keys",
|
||||
"homeassistant.components.midea.config_flow.MideaCloud.get_default_keys",
|
||||
AsyncMock(return_value={"builtin": {"token": TEST_TOKEN, "key": TEST_KEY}}),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaDevice",
|
||||
"homeassistant.components.midea.config_flow.MideaDevice",
|
||||
return_value=dm,
|
||||
),
|
||||
):
|
||||
@@ -778,7 +778,7 @@ async def test_auto_flow_v3_phase2_login_failed(hass: HomeAssistant) -> None:
|
||||
user_input={"next_step_id": "search"},
|
||||
)
|
||||
with patch(
|
||||
"homeassistant.components.midea_lan.config_flow.discover",
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
return_value=mock_devices,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -800,15 +800,15 @@ async def test_auto_flow_v3_phase2_login_failed(hass: HomeAssistant) -> None:
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.async_get_clientsession",
|
||||
"homeassistant.components.midea.config_flow.async_get_clientsession",
|
||||
return_value=object(),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.get_midea_cloud",
|
||||
"homeassistant.components.midea.config_flow.get_midea_cloud",
|
||||
return_value=cloud,
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaCloud.get_default_keys",
|
||||
"homeassistant.components.midea.config_flow.MideaCloud.get_default_keys",
|
||||
AsyncMock(return_value={}),
|
||||
),
|
||||
):
|
||||
@@ -838,7 +838,7 @@ async def test_auto_flow_v3_phase2_no_keys_available(hass: HomeAssistant) -> Non
|
||||
user_input={"next_step_id": "search"},
|
||||
)
|
||||
with patch(
|
||||
"homeassistant.components.midea_lan.config_flow.discover",
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
return_value=mock_devices,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -860,15 +860,15 @@ async def test_auto_flow_v3_phase2_no_keys_available(hass: HomeAssistant) -> Non
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.async_get_clientsession",
|
||||
"homeassistant.components.midea.config_flow.async_get_clientsession",
|
||||
return_value=object(),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.get_midea_cloud",
|
||||
"homeassistant.components.midea.config_flow.get_midea_cloud",
|
||||
return_value=cloud,
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaCloud.get_default_keys",
|
||||
"homeassistant.components.midea.config_flow.MideaCloud.get_default_keys",
|
||||
AsyncMock(return_value={}),
|
||||
),
|
||||
):
|
||||
@@ -907,7 +907,7 @@ async def test_auto_flow_v3_phase2_success_after_phase1_failure(
|
||||
user_input={"next_step_id": "search"},
|
||||
)
|
||||
with patch(
|
||||
"homeassistant.components.midea_lan.config_flow.discover",
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
return_value=mock_devices,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -937,19 +937,19 @@ async def test_auto_flow_v3_phase2_success_after_phase1_failure(
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.async_get_clientsession",
|
||||
"homeassistant.components.midea.config_flow.async_get_clientsession",
|
||||
return_value=object(),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.get_midea_cloud",
|
||||
"homeassistant.components.midea.config_flow.get_midea_cloud",
|
||||
return_value=cloud,
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaCloud.get_default_keys",
|
||||
"homeassistant.components.midea.config_flow.MideaCloud.get_default_keys",
|
||||
AsyncMock(return_value={}),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaDevice",
|
||||
"homeassistant.components.midea.config_flow.MideaDevice",
|
||||
return_value=dm,
|
||||
),
|
||||
):
|
||||
@@ -989,7 +989,7 @@ async def test_auto_flow_recovers_after_preset_login_error(
|
||||
user_input={"next_step_id": "search"},
|
||||
)
|
||||
with patch(
|
||||
"homeassistant.components.midea_lan.config_flow.discover",
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
return_value=mock_devices,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -1011,15 +1011,15 @@ async def test_auto_flow_recovers_after_preset_login_error(
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.async_get_clientsession",
|
||||
"homeassistant.components.midea.config_flow.async_get_clientsession",
|
||||
return_value=object(),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.get_midea_cloud",
|
||||
"homeassistant.components.midea.config_flow.get_midea_cloud",
|
||||
return_value=cloud,
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaCloud.get_default_keys",
|
||||
"homeassistant.components.midea.config_flow.MideaCloud.get_default_keys",
|
||||
AsyncMock(return_value={}),
|
||||
),
|
||||
):
|
||||
@@ -1075,15 +1075,15 @@ async def test_auto_flow_v1_v2_success_when_cloud_down(
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.discover",
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
return_value=mock_devices,
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaDevice",
|
||||
"homeassistant.components.midea.config_flow.MideaDevice",
|
||||
return_value=dm,
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.async_get_clientsession",
|
||||
"homeassistant.components.midea.config_flow.async_get_clientsession",
|
||||
side_effect=AssertionError("cloud must not be used"),
|
||||
),
|
||||
):
|
||||
@@ -1123,7 +1123,7 @@ async def test_login_credentials_step_renders_with_cloud_servers(
|
||||
assert result["step_id"] == "search"
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.midea_lan.config_flow.discover",
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
return_value=DISCOVERY_RESULT,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -1141,7 +1141,7 @@ async def test_login_credentials_step_renders_with_cloud_servers(
|
||||
assert result["step_id"] == "auth_method"
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaCloud.get_cloud_servers",
|
||||
"homeassistant.components.midea.config_flow.MideaCloud.get_cloud_servers",
|
||||
AsyncMock(return_value={1: "CN", 2: DEFAULT_CLOUD}),
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -1172,7 +1172,7 @@ async def test_login_credentials_step_login_failed_sets_error(
|
||||
assert result["step_id"] == "search"
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.midea_lan.config_flow.discover",
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
return_value=DISCOVERY_RESULT,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -1201,15 +1201,15 @@ async def test_login_credentials_step_login_failed_sets_error(
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaCloud.get_cloud_servers",
|
||||
"homeassistant.components.midea.config_flow.MideaCloud.get_cloud_servers",
|
||||
AsyncMock(return_value={1: DEFAULT_CLOUD}),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.async_get_clientsession",
|
||||
"homeassistant.components.midea.config_flow.async_get_clientsession",
|
||||
return_value=object(),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.get_midea_cloud",
|
||||
"homeassistant.components.midea.config_flow.get_midea_cloud",
|
||||
return_value=cloud,
|
||||
),
|
||||
):
|
||||
@@ -1259,7 +1259,7 @@ async def test_login_credentials_step_recovers_after_failed_login(
|
||||
assert result["step_id"] == "search"
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.midea_lan.config_flow.discover",
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
return_value=discovered_device,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -1295,19 +1295,19 @@ async def test_login_credentials_step_recovers_after_failed_login(
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.async_get_clientsession",
|
||||
"homeassistant.components.midea.config_flow.async_get_clientsession",
|
||||
return_value=object(),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.get_midea_cloud",
|
||||
"homeassistant.components.midea.config_flow.get_midea_cloud",
|
||||
return_value=cloud,
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaCloud.get_default_keys",
|
||||
"homeassistant.components.midea.config_flow.MideaCloud.get_default_keys",
|
||||
AsyncMock(return_value={}),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaDevice",
|
||||
"homeassistant.components.midea.config_flow.MideaDevice",
|
||||
return_value=dm,
|
||||
),
|
||||
):
|
||||
@@ -1371,7 +1371,7 @@ async def test_list_step_shows_discovery_table(
|
||||
flow_id = result["flow_id"]
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.midea_lan.config_flow.discover",
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
return_value=all_devices,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -1394,7 +1394,7 @@ async def test_list_step_submit_returns_to_user_menu(hass: HomeAssistant) -> Non
|
||||
flow_id = result["flow_id"]
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.midea_lan.config_flow.discover",
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
return_value={},
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -1458,23 +1458,23 @@ async def test_manual_step_v3_missing_token_key_sets_retrieved_values(
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.discover",
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
return_value={TEST_DEVICE_ID: device},
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.async_get_clientsession",
|
||||
"homeassistant.components.midea.config_flow.async_get_clientsession",
|
||||
return_value=object(),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.get_midea_cloud",
|
||||
"homeassistant.components.midea.config_flow.get_midea_cloud",
|
||||
return_value=cloud,
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaCloud.get_default_keys",
|
||||
"homeassistant.components.midea.config_flow.MideaCloud.get_default_keys",
|
||||
AsyncMock(return_value={}),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaDevice",
|
||||
"homeassistant.components.midea.config_flow.MideaDevice",
|
||||
) as mock_midea_device,
|
||||
):
|
||||
mock_midea_device.return_value = dm
|
||||
@@ -1510,11 +1510,11 @@ async def test_manually_flow_success(hass: HomeAssistant) -> None:
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.discover",
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
return_value=DISCOVERY_RESULT,
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaDevice",
|
||||
"homeassistant.components.midea.config_flow.MideaDevice",
|
||||
) as mock_midea_device,
|
||||
):
|
||||
mock_device = MagicMock()
|
||||
@@ -1563,7 +1563,7 @@ async def test_login_credentials_step_falls_back_to_default_cloud(
|
||||
assert result["step_id"] == "search"
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.midea_lan.config_flow.discover",
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
return_value=DISCOVERY_RESULT,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -1581,7 +1581,7 @@ async def test_login_credentials_step_falls_back_to_default_cloud(
|
||||
assert result["step_id"] == "auth_method"
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaCloud.get_cloud_servers",
|
||||
"homeassistant.components.midea.config_flow.MideaCloud.get_cloud_servers",
|
||||
AsyncMock(return_value={}),
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -1615,7 +1615,7 @@ async def test_login_credentials_step_success_resumes_auto_flow(
|
||||
TEST_DEVICE_ID: {**BASE_DATA, CONF_TYPE: TEST_TYPE},
|
||||
}
|
||||
with patch(
|
||||
"homeassistant.components.midea_lan.config_flow.discover",
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
return_value=discovered_device,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -1651,19 +1651,19 @@ async def test_login_credentials_step_success_resumes_auto_flow(
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.async_get_clientsession",
|
||||
"homeassistant.components.midea.config_flow.async_get_clientsession",
|
||||
return_value=object(),
|
||||
) as mock_session,
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.get_midea_cloud",
|
||||
"homeassistant.components.midea.config_flow.get_midea_cloud",
|
||||
return_value=cloud,
|
||||
) as mock_get_midea_cloud,
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaCloud.get_default_keys",
|
||||
"homeassistant.components.midea.config_flow.MideaCloud.get_default_keys",
|
||||
AsyncMock(return_value={}),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.MideaDevice",
|
||||
"homeassistant.components.midea.config_flow.MideaDevice",
|
||||
return_value=dm,
|
||||
),
|
||||
):
|
||||
@@ -1702,7 +1702,7 @@ async def test_auth_method_account_mode_redirects_to_login_credentials(
|
||||
assert result["step_id"] == "search"
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.midea_lan.config_flow.discover",
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
return_value=DISCOVERY_RESULT,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -1745,7 +1745,7 @@ async def test_auth_method_preset_login_failed(hass: HomeAssistant) -> None:
|
||||
assert result["step_id"] == "search"
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.midea_lan.config_flow.discover",
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
return_value=DISCOVERY_RESULT,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -1767,11 +1767,11 @@ async def test_auth_method_preset_login_failed(hass: HomeAssistant) -> None:
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.async_get_clientsession",
|
||||
"homeassistant.components.midea.config_flow.async_get_clientsession",
|
||||
return_value=object(),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.config_flow.get_midea_cloud",
|
||||
"homeassistant.components.midea.config_flow.get_midea_cloud",
|
||||
return_value=cloud,
|
||||
),
|
||||
):
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Tests for midea_lan entity behavior via loaded platforms."""
|
||||
"""Tests for midea entity behavior via loaded platforms."""
|
||||
|
||||
from collections.abc import Callable
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"""Tests for midea_lan __init__.py."""
|
||||
"""Tests for midea __init__.py."""
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from midealocal.const import DeviceType, ProtocolVersion
|
||||
|
||||
from homeassistant.components.midea_lan.const import CONF_KEY, CONF_SUBTYPE, DOMAIN
|
||||
from homeassistant.components.midea.const import CONF_KEY, CONF_SUBTYPE, DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import (
|
||||
CONF_DEVICE_ID,
|
||||
@@ -39,7 +39,7 @@ _ENTRY_DATA = {
|
||||
|
||||
|
||||
async def test_async_setup(hass: HomeAssistant) -> None:
|
||||
"""Test the midea_lan domain can be set up without any config entries."""
|
||||
"""Test the midea domain can be set up without any config entries."""
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ async def test_unload_entry(hass: HomeAssistant) -> None:
|
||||
entry.add_to_hass(hass)
|
||||
device = DummyDevice(DeviceType.AC)
|
||||
with patch(
|
||||
"homeassistant.components.midea_lan.device_selector",
|
||||
"homeassistant.components.midea.device_selector",
|
||||
return_value=device,
|
||||
):
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
@@ -65,7 +65,7 @@ async def test_async_setup_entry_paths(hass: HomeAssistant) -> None:
|
||||
entry = MockConfigEntry(domain=DOMAIN, data=_ENTRY_DATA)
|
||||
entry.add_to_hass(hass)
|
||||
with patch(
|
||||
"homeassistant.components.midea_lan.device_selector",
|
||||
"homeassistant.components.midea.device_selector",
|
||||
return_value=DummyDevice(DeviceType.AC),
|
||||
):
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
@@ -77,7 +77,7 @@ async def test_async_setup_entry_paths(hass: HomeAssistant) -> None:
|
||||
)
|
||||
entry2.add_to_hass(hass)
|
||||
with patch(
|
||||
"homeassistant.components.midea_lan.device_selector",
|
||||
"homeassistant.components.midea.device_selector",
|
||||
return_value=None,
|
||||
):
|
||||
await hass.config_entries.async_setup(entry2.entry_id)
|
||||
@@ -99,7 +99,7 @@ async def test_setup_entry_not_ready_on_connect_failure(
|
||||
device = DummyDevice(DeviceType.AC)
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.midea_lan.device_selector",
|
||||
"homeassistant.components.midea.device_selector",
|
||||
return_value=device,
|
||||
),
|
||||
patch.object(device, "connect", return_value=False),
|
||||
Reference in New Issue
Block a user