mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Avoid logging a warning when replacing an ignored config entry (#142114)
Replacing an ignored config entry with one from the user flow should not generate a warning. We should only warn if we are replacing a usable config entry. Followup to adjust the warning added in #130567 cc @epenet
This commit is contained in:
parent
dfa180ba64
commit
0b61b62334
@ -1612,7 +1612,11 @@ class ConfigEntriesFlowManager(
|
|||||||
result["handler"], flow.unique_id
|
result["handler"], flow.unique_id
|
||||||
)
|
)
|
||||||
|
|
||||||
if existing_entry is not None and flow.handler != "mobile_app":
|
if (
|
||||||
|
existing_entry is not None
|
||||||
|
and flow.handler != "mobile_app"
|
||||||
|
and existing_entry.source != SOURCE_IGNORE
|
||||||
|
):
|
||||||
# This causes the old entry to be removed and replaced, when the flow
|
# This causes the old entry to be removed and replaced, when the flow
|
||||||
# should instead be aborted.
|
# should instead be aborted.
|
||||||
# In case of manual flows, integrations should implement options, reauth,
|
# In case of manual flows, integrations should implement options, reauth,
|
||||||
|
@ -8797,15 +8797,17 @@ async def test_add_description_placeholder_automatically_not_overwrites(
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("domain", "expected_log"),
|
("domain", "source", "expected_log"),
|
||||||
[
|
[
|
||||||
("some_integration", True),
|
("some_integration", config_entries.SOURCE_USER, True),
|
||||||
("mobile_app", False),
|
("some_integration", config_entries.SOURCE_IGNORE, False),
|
||||||
|
("mobile_app", config_entries.SOURCE_USER, False),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_create_entry_existing_unique_id(
|
async def test_create_entry_existing_unique_id(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
domain: str,
|
domain: str,
|
||||||
|
source: str,
|
||||||
expected_log: bool,
|
expected_log: bool,
|
||||||
caplog: pytest.LogCaptureFixture,
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -8816,6 +8818,7 @@ async def test_create_entry_existing_unique_id(
|
|||||||
entry_id="01J915Q6T9F6G5V0QJX6HBC94T",
|
entry_id="01J915Q6T9F6G5V0QJX6HBC94T",
|
||||||
data={"host": "any", "port": 123},
|
data={"host": "any", "port": 123},
|
||||||
unique_id="mock-unique-id",
|
unique_id="mock-unique-id",
|
||||||
|
source=source,
|
||||||
)
|
)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user