mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Prepare ring update service for deprecation (#108781)
* Prepare ring update service for deprecation * Update service removal release number
This commit is contained in:
parent
f8d1232598
commit
48cb09a4a8
@ -11,6 +11,7 @@ from homeassistant.config_entries import ConfigEntry
|
||||
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 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
||||
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()
|
||||
|
@ -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."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import homeassistant.components.ring as ring
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user