diff --git a/homeassistant/components/ring/__init__.py b/homeassistant/components/ring/__init__.py index 5470d997fab6c5..79d90c87f0e9e5 100644 --- a/homeassistant/components/ring/__init__.py +++ b/homeassistant/components/ring/__init__.py @@ -11,6 +11,7 @@ from homeassistant.const import APPLICATION_NAME, CONF_TOKEN, __version__ from homeassistant.core import HomeAssistant, ServiceCall from homeassistant.helpers import device_registry as dr +from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue from .const import ( DOMAIN, @@ -62,6 +63,23 @@ def token_updater(token): async def async_refresh_all(_: ServiceCall) -> None: """Refresh all ring data.""" + _LOGGER.warning( + "Detected use of service 'ring.update'. " + "This is deprecated and will stop working in Home Assistant 2024.10. " + "Use 'homeassistant.update_entity' instead which updates all ring entities", + ) + async_create_issue( + hass, + DOMAIN, + "deprecated_service_ring_update", + breaks_in_ha_version="2024.10.0", + is_fixable=True, + is_persistent=False, + issue_domain=DOMAIN, + severity=IssueSeverity.WARNING, + translation_key="deprecated_service_ring_update", + ) + for info in hass.data[DOMAIN].values(): await info[RING_DEVICES_COORDINATOR].async_refresh() await info[RING_NOTIFICATIONS_COORDINATOR].async_refresh() diff --git a/homeassistant/components/ring/strings.json b/homeassistant/components/ring/strings.json index 688e3141beb502..ee7dbc000f5a3c 100644 --- a/homeassistant/components/ring/strings.json +++ b/homeassistant/components/ring/strings.json @@ -78,5 +78,18 @@ "name": "Update", "description": "Updates the data we have for all your ring devices." } + }, + "issues": { + "deprecated_service_ring_update": { + "title": "Detected use of deprecated service `ring.update`", + "fix_flow": { + "step": { + "confirm": { + "title": "[%key:component::ring::issues::deprecated_service_ring_update::title%]", + "description": "Use `homeassistant.update_entity` instead which will update all ring entities.\n\nPlease replace calls to this service and adjust your automations and scripts and select **submit** to close this issue." + } + } + } + } } } diff --git a/tests/components/ring/test_init.py b/tests/components/ring/test_init.py index 64fca9eac2f5cb..ba5dd03ba9c59c 100644 --- a/tests/components/ring/test_init.py +++ b/tests/components/ring/test_init.py @@ -11,6 +11,7 @@ from homeassistant.components.ring import DOMAIN from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntryState from homeassistant.core import HomeAssistant +from homeassistant.helpers.issue_registry import IssueRegistry from homeassistant.setup import async_setup_component from homeassistant.util import dt as dt_util @@ -238,3 +239,30 @@ async def test_error_on_device_update( record.message for record in caplog.records if record.levelname == "ERROR" ] assert mock_config_entry.entry_id in hass.data[DOMAIN] + + +async def test_issue_deprecated_service_ring_update( + hass: HomeAssistant, + issue_registry: IssueRegistry, + caplog: pytest.LogCaptureFixture, + requests_mock: requests_mock.Mocker, + mock_config_entry: MockConfigEntry, +) -> None: + """Test the issue is raised on deprecated service ring.update.""" + mock_config_entry.add_to_hass(hass) + await hass.config_entries.async_setup(mock_config_entry.entry_id) + await hass.async_block_till_done() + + _ = await hass.services.async_call(DOMAIN, "update", {}, blocking=True) + + issue = issue_registry.async_get_issue("ring", "deprecated_service_ring_update") + assert issue + assert issue.issue_domain == "ring" + assert issue.issue_id == "deprecated_service_ring_update" + assert issue.translation_key == "deprecated_service_ring_update" + + assert ( + "Detected use of service 'ring.update'. " + "This is deprecated and will stop working in Home Assistant 2024.10. " + "Use 'homeassistant.update_entity' instead which updates all ring entities" + ) in caplog.text