mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Fix reload race in unifiprotect (#69485)
- The integration already has a reload listener installed once it is setup. We should not reload from the config flow since they compete
This commit is contained in:
parent
181142aae7
commit
02d245a31a
@ -116,9 +116,6 @@ class ProtectFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
self.hass.config_entries.async_update_entry(
|
self.hass.config_entries.async_update_entry(
|
||||||
entry, data={**entry.data, CONF_HOST: new_host}
|
entry, data={**entry.data, CONF_HOST: new_host}
|
||||||
)
|
)
|
||||||
self.hass.async_create_task(
|
|
||||||
self.hass.config_entries.async_reload(entry.entry_id)
|
|
||||||
)
|
|
||||||
return self.async_abort(reason="already_configured")
|
return self.async_abort(reason="already_configured")
|
||||||
if entry_host in (direct_connect_domain, source_ip) or (
|
if entry_host in (direct_connect_domain, source_ip) or (
|
||||||
entry_has_direct_connect
|
entry_has_direct_connect
|
||||||
|
@ -365,10 +365,7 @@ async def test_discovered_by_unifi_discovery_direct_connect_updated(
|
|||||||
)
|
)
|
||||||
mock_config.add_to_hass(hass)
|
mock_config.add_to_hass(hass)
|
||||||
|
|
||||||
with _patch_discovery(), patch(
|
with _patch_discovery():
|
||||||
"homeassistant.components.unifiprotect.async_setup_entry",
|
|
||||||
return_value=True,
|
|
||||||
) as mock_setup_entry:
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_INTEGRATION_DISCOVERY},
|
context={"source": config_entries.SOURCE_INTEGRATION_DISCOVERY},
|
||||||
@ -378,7 +375,6 @@ async def test_discovered_by_unifi_discovery_direct_connect_updated(
|
|||||||
|
|
||||||
assert result["type"] == RESULT_TYPE_ABORT
|
assert result["type"] == RESULT_TYPE_ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
|
||||||
assert mock_config.data[CONF_HOST] == DIRECT_CONNECT_DOMAIN
|
assert mock_config.data[CONF_HOST] == DIRECT_CONNECT_DOMAIN
|
||||||
|
|
||||||
|
|
||||||
@ -401,10 +397,7 @@ async def test_discovered_by_unifi_discovery_direct_connect_updated_but_not_usin
|
|||||||
)
|
)
|
||||||
mock_config.add_to_hass(hass)
|
mock_config.add_to_hass(hass)
|
||||||
|
|
||||||
with _patch_discovery(), patch(
|
with _patch_discovery():
|
||||||
"homeassistant.components.unifiprotect.async_setup_entry",
|
|
||||||
return_value=True,
|
|
||||||
) as mock_setup_entry:
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_INTEGRATION_DISCOVERY},
|
context={"source": config_entries.SOURCE_INTEGRATION_DISCOVERY},
|
||||||
@ -414,7 +407,6 @@ async def test_discovered_by_unifi_discovery_direct_connect_updated_but_not_usin
|
|||||||
|
|
||||||
assert result["type"] == RESULT_TYPE_ABORT
|
assert result["type"] == RESULT_TYPE_ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
|
||||||
assert mock_config.data[CONF_HOST] == "127.0.0.1"
|
assert mock_config.data[CONF_HOST] == "127.0.0.1"
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user