diff --git a/homeassistant/components/duckdns/issue.py b/homeassistant/components/duckdns/issue.py index f2124f97fa0..34a23fdbc63 100644 --- a/homeassistant/components/duckdns/issue.py +++ b/homeassistant/components/duckdns/issue.py @@ -38,3 +38,18 @@ def deprecate_yaml_issue(hass: HomeAssistant, *, import_success: bool) -> None: "url": "/config/integrations/dashboard/add?domain=duckdns" }, ) + + +def action_called_without_config_entry(hass: HomeAssistant) -> None: + """Deprecate the use of action without config entry.""" + + async_create_issue( + hass, + DOMAIN, + "deprecated_call_without_config_entry", + breaks_in_ha_version="2026.9.0", + is_fixable=False, + issue_domain=DOMAIN, + severity=IssueSeverity.WARNING, + translation_key="deprecated_call_without_config_entry", + ) diff --git a/homeassistant/components/duckdns/services.py b/homeassistant/components/duckdns/services.py index ff2368a1467..b6a0e5174bf 100644 --- a/homeassistant/components/duckdns/services.py +++ b/homeassistant/components/duckdns/services.py @@ -15,6 +15,7 @@ from homeassistant.helpers.selector import ConfigEntrySelector from .const import ATTR_CONFIG_ENTRY, ATTR_TXT, DOMAIN, SERVICE_SET_TXT from .coordinator import DuckDnsConfigEntry from .helpers import update_duckdns +from .issue import action_called_without_config_entry SERVICE_TXT_SCHEMA = vol.Schema( { @@ -42,6 +43,7 @@ def get_config_entry( """Return config entry or raise if not found or not loaded.""" if entry_id is None: + action_called_without_config_entry(hass) if len(entries := hass.config_entries.async_entries(DOMAIN)) != 1: raise ServiceValidationError( translation_domain=DOMAIN, diff --git a/homeassistant/components/duckdns/strings.json b/homeassistant/components/duckdns/strings.json index fdd3db2ad36..87262c913e3 100644 --- a/homeassistant/components/duckdns/strings.json +++ b/homeassistant/components/duckdns/strings.json @@ -46,6 +46,10 @@ } }, "issues": { + "deprecated_call_without_config_entry": { + "description": "Calling the `duckdns.set_txt` action without specifying a config entry is deprecated.\n\nThe `config_entry_id` field will be required in a future release.\n\nPlease update your automations and scripts to include the `config_entry_id` parameter.", + "title": "Detected deprecated use of action without config entry" + }, "deprecated_yaml_import_issue_error": { "description": "Configuring Duck DNS using YAML is being removed but there was an error when trying to import the YAML configuration.\n\nEnsure the YAML configuration is correct and restart Home Assistant to try again or remove the Duck DNS YAML configuration from your `configuration.yaml` file and continue to [set up the integration]({url}) manually.", "title": "The Duck DNS YAML configuration import failed" diff --git a/tests/components/duckdns/test_init.py b/tests/components/duckdns/test_init.py index 11e7dfbb9cf..8821b292d16 100644 --- a/tests/components/duckdns/test_init.py +++ b/tests/components/duckdns/test_init.py @@ -19,6 +19,7 @@ from homeassistant.config_entries import ConfigEntryState from homeassistant.const import CONF_ACCESS_TOKEN, CONF_DOMAIN from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError, ServiceValidationError +from homeassistant.helpers import issue_registry as ir from homeassistant.util.dt import utcnow from .conftest import TEST_SUBDOMAIN, TEST_TOKEN @@ -118,7 +119,9 @@ async def test_setup_backoff( @pytest.mark.usefixtures("setup_duckdns") async def test_service_set_txt( - hass: HomeAssistant, aioclient_mock: AiohttpClientMocker + hass: HomeAssistant, + aioclient_mock: AiohttpClientMocker, + issue_registry: ir.IssueRegistry, ) -> None: """Test set txt service call.""" # Empty the fixture mock requests @@ -140,6 +143,11 @@ async def test_service_set_txt( ) assert aioclient_mock.call_count == 1 + assert issue_registry.async_get_issue( + domain=DOMAIN, + issue_id="deprecated_call_without_config_entry", + ) + @pytest.mark.usefixtures("setup_duckdns") async def test_service_clear_txt(