mirror of
https://github.com/home-assistant/core.git
synced 2025-07-31 09:17:10 +00:00
Fix create flow logic for single config entry integrations (#129807)
* Fix create flow logic for single config entry integrations * Adjust MQTT test
This commit is contained in:
parent
9349292464
commit
6e93777f54
@ -1264,10 +1264,16 @@ class ConfigEntriesFlowManager(
|
|||||||
|
|
||||||
# Avoid starting a config flow on an integration that only supports
|
# Avoid starting a config flow on an integration that only supports
|
||||||
# a single config entry, but which already has an entry
|
# a single config entry, but which already has an entry
|
||||||
|
source = context["source"]
|
||||||
if (
|
if (
|
||||||
context.get("source")
|
source not in {SOURCE_IGNORE, SOURCE_REAUTH, SOURCE_RECONFIGURE}
|
||||||
not in {SOURCE_IGNORE, SOURCE_REAUTH, SOURCE_RECONFIGURE}
|
and (
|
||||||
and self.config_entries.async_has_entries(handler, include_ignore=False)
|
self.config_entries.async_has_entries(handler, include_ignore=False)
|
||||||
|
or (
|
||||||
|
self.config_entries.async_has_entries(handler, include_ignore=True)
|
||||||
|
and source != SOURCE_USER
|
||||||
|
)
|
||||||
|
)
|
||||||
and await _support_single_config_entry_only(self.hass, handler)
|
and await _support_single_config_entry_only(self.hass, handler)
|
||||||
):
|
):
|
||||||
return ConfigFlowResult(
|
return ConfigFlowResult(
|
||||||
|
@ -444,7 +444,7 @@ async def test_hassio_ignored(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
assert result
|
assert result
|
||||||
assert result.get("type") is FlowResultType.ABORT
|
assert result.get("type") is FlowResultType.ABORT
|
||||||
assert result.get("reason") == "already_configured"
|
assert result.get("reason") == "single_instance_allowed"
|
||||||
|
|
||||||
|
|
||||||
async def test_hassio_confirm(
|
async def test_hassio_confirm(
|
||||||
|
@ -5627,6 +5627,14 @@ async def test_starting_config_flow_on_single_config_entry(
|
|||||||
None,
|
None,
|
||||||
{"type": data_entry_flow.FlowResultType.ABORT, "reason": "not_implemented"},
|
{"type": data_entry_flow.FlowResultType.ABORT, "reason": "not_implemented"},
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
{"source": config_entries.SOURCE_ZEROCONF},
|
||||||
|
None,
|
||||||
|
{
|
||||||
|
"type": data_entry_flow.FlowResultType.ABORT,
|
||||||
|
"reason": "single_instance_allowed",
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_starting_config_flow_on_single_config_entry_2(
|
async def test_starting_config_flow_on_single_config_entry_2(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user