mirror of
https://github.com/home-assistant/core.git
synced 2026-09-25 07:51:46 -05:00
Deprecate passing a target to homeassistant.reload_config_entry (#181142)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
co-authored by
Martin Hjelmare
parent
a98e9c25bb
commit
8d48785e4f
@@ -343,6 +343,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa:
|
||||
reload_entries: set[str] = set()
|
||||
if ATTR_ENTRY_ID in call.data:
|
||||
reload_entries.add(call.data[ATTR_ENTRY_ID])
|
||||
if TargetSelection(call.data).has_any_target:
|
||||
_LOGGER.warning(
|
||||
"Reloading a config entry by target is deprecated and will stop "
|
||||
"working in Home Assistant 2027.4, please specify the config entry "
|
||||
"to reload in the 'entry_id' parameter instead"
|
||||
)
|
||||
reload_entries.update(await async_extract_config_entry_ids(call))
|
||||
if not reload_entries:
|
||||
raise ValueError("There were no matching config entries to reload")
|
||||
|
||||
@@ -49,10 +49,11 @@ update_entity:
|
||||
|
||||
reload_custom_templates:
|
||||
reload_config_entry:
|
||||
target:
|
||||
# Target is intentionally hidden from the UI to steer users towards selecting
|
||||
# the config entry to reload. It is still accepted by the service schema.
|
||||
fields:
|
||||
entry_id:
|
||||
required: false
|
||||
required: true
|
||||
selector:
|
||||
config_entry:
|
||||
|
||||
|
||||
@@ -262,10 +262,10 @@
|
||||
"name": "Reload all Home Assistant configuration"
|
||||
},
|
||||
"reload_config_entry": {
|
||||
"description": "Reloads any explicitly provided config entry ID and any config entries referenced by entities or devices in the target. If both are provided, the union of those config entries is reloaded.",
|
||||
"description": "Reloads the config entry of the provided config entry ID.",
|
||||
"fields": {
|
||||
"entry_id": {
|
||||
"description": "Optional configuration entry ID to reload.",
|
||||
"description": "The configuration entry to reload.",
|
||||
"name": "Config entry ID"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -368,7 +368,9 @@ async def test_not_allowing_recursion(
|
||||
|
||||
|
||||
async def test_reload_config_entry_by_entity_id(
|
||||
hass: HomeAssistant, entity_registry: er.EntityRegistry
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test being able to reload a config entry by entity_id."""
|
||||
await async_setup_component(hass, DOMAIN, {})
|
||||
@@ -398,6 +400,11 @@ async def test_reload_config_entry_by_entity_id(
|
||||
entry1.entry_id,
|
||||
entry2.entry_id,
|
||||
}
|
||||
assert (
|
||||
"Reloading a config entry by target is deprecated and will stop working in "
|
||||
"Home Assistant 2027.4, please specify the config entry to reload in the "
|
||||
"'entry_id' parameter instead"
|
||||
) in caplog.text
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
await hass.services.async_call(
|
||||
@@ -408,7 +415,9 @@ async def test_reload_config_entry_by_entity_id(
|
||||
)
|
||||
|
||||
|
||||
async def test_reload_config_entry_by_entry_id(hass: HomeAssistant) -> None:
|
||||
async def test_reload_config_entry_by_entry_id(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test being able to reload a config entry by config entry id."""
|
||||
await async_setup_component(hass, DOMAIN, {})
|
||||
|
||||
@@ -425,6 +434,7 @@ async def test_reload_config_entry_by_entry_id(hass: HomeAssistant) -> None:
|
||||
|
||||
assert len(mock_reload.mock_calls) == 1
|
||||
assert mock_reload.mock_calls[0][1][0] == "8955375327824e14ba89e4b29cc3ec9a"
|
||||
assert "Reloading a config entry by target is deprecated" not in caplog.text
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
Reference in New Issue
Block a user