mirror of
https://github.com/home-assistant/core.git
synced 2026-09-14 12:39:58 +01:00
Use discovery result in Midea for reconfigure flow (#181167)
This commit is contained in:
@@ -730,14 +730,16 @@ class MideaConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
list(self.supports.keys()), ip_address=user_input[CONF_IP_ADDRESS]
|
||||
),
|
||||
)
|
||||
entry_device_id = entry.data[CONF_DEVICE_ID]
|
||||
device = devices.get(entry_device_id)
|
||||
if len(devices) == 0:
|
||||
error = "invalid_device_ip"
|
||||
elif entry.data[CONF_DEVICE_ID] not in devices:
|
||||
elif device is None:
|
||||
error = "invalid_device_id_for_ip"
|
||||
else:
|
||||
return self.async_update_reload_and_abort(
|
||||
entry,
|
||||
data_updates={CONF_IP_ADDRESS: user_input[CONF_IP_ADDRESS]},
|
||||
data_updates={CONF_IP_ADDRESS: device.get(CONF_IP_ADDRESS)},
|
||||
)
|
||||
return self.async_show_form(
|
||||
step_id="reconfigure",
|
||||
|
||||
@@ -2044,11 +2044,12 @@ async def _assert_reconfigure_success(
|
||||
"""Assert reconfigure success."""
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reconfigure"
|
||||
|
||||
discovery_result = DISCOVERY_RESULT
|
||||
discovery_result[TEST_DEVICE_ID][CONF_IP_ADDRESS] = "8.8.8.8"
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.midea.config_flow.discover",
|
||||
return_value=DISCOVERY_RESULT,
|
||||
return_value=discovery_result,
|
||||
) as mock_discovery,
|
||||
patch(
|
||||
"homeassistant.components.midea.config_flow.device_selector",
|
||||
|
||||
Reference in New Issue
Block a user