mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Prevent new discovery flows from being created when stopping (#88743)
This commit is contained in:
parent
6196607c5d
commit
ed8f538890
@ -44,7 +44,9 @@ def _async_init_flow(
|
|||||||
# as ones in progress as it may cause additional device probing
|
# as ones in progress as it may cause additional device probing
|
||||||
# which can overload devices since zeroconf/ssdp updates can happen
|
# which can overload devices since zeroconf/ssdp updates can happen
|
||||||
# multiple times in the same minute
|
# multiple times in the same minute
|
||||||
if hass.config_entries.flow.async_has_matching_flow(domain, context, data):
|
if hass.is_stopping or hass.config_entries.flow.async_has_matching_flow(
|
||||||
|
domain, context, data
|
||||||
|
):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return hass.config_entries.flow.async_init(domain, context=context, data=data)
|
return hass.config_entries.flow.async_init(domain, context=context, data=data)
|
||||||
|
@ -96,3 +96,20 @@ async def test_async_create_flow_checks_existing_flows_before_startup(
|
|||||||
data={"properties": {"id": "aa:bb:cc:dd:ee:ff"}},
|
data={"properties": {"id": "aa:bb:cc:dd:ee:ff"}},
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
async def test_async_create_flow_does_nothing_after_stop(
|
||||||
|
hass: HomeAssistant, mock_flow_init
|
||||||
|
) -> None:
|
||||||
|
"""Test we no longer create flows when hass is stopping."""
|
||||||
|
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
hass.state = CoreState.stopping
|
||||||
|
mock_flow_init.reset_mock()
|
||||||
|
discovery_flow.async_create_flow(
|
||||||
|
hass,
|
||||||
|
"hue",
|
||||||
|
{"source": config_entries.SOURCE_HOMEKIT},
|
||||||
|
{"properties": {"id": "aa:bb:cc:dd:ee:ff"}},
|
||||||
|
)
|
||||||
|
assert len(mock_flow_init.mock_calls) == 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user