diff --git a/homeassistant/components/homeassistant/strings.json b/homeassistant/components/homeassistant/strings.json index 5cdd47d8be4..09b2f17c947 100644 --- a/homeassistant/components/homeassistant/strings.json +++ b/homeassistant/components/homeassistant/strings.json @@ -56,10 +56,6 @@ "config_entry_reauth": { "title": "[%key:common::config_flow::title::reauth%]", "description": "Reauthentication is needed" - }, - "template_function_relative_time_deprecated": { - "title": "The {relative_time} template function is deprecated", - "description": "The {relative_time} template function is deprecated in Home Assistant. Please use the {time_since} or {time_until} template functions instead." } }, "system_health": { diff --git a/homeassistant/helpers/template.py b/homeassistant/helpers/template.py index 335d6842548..ea45ac4e74a 100644 --- a/homeassistant/helpers/template.py +++ b/homeassistant/helpers/template.py @@ -59,7 +59,6 @@ from homeassistant.const import ( UnitOfLength, ) from homeassistant.core import ( - DOMAIN as HA_DOMAIN, Context, HomeAssistant, State, @@ -2480,30 +2479,11 @@ def relative_time(hass: HomeAssistant, value: Any) -> Any: Make sure date is not in the future, or else it will return None. If the input are not a datetime object the input will be returned unmodified. + + Note: This template function is deprecated in favor of `time_until`, but is still + supported so as not to break old templates. """ - def warn_relative_time_deprecated() -> None: - ir = issue_registry.async_get(hass) - issue_id = "template_function_relative_time_deprecated" - if ir.async_get_issue(HA_DOMAIN, issue_id): - return - issue_registry.async_create_issue( - hass, - HA_DOMAIN, - issue_id, - breaks_in_ha_version="2024.11.0", - is_fixable=False, - severity=issue_registry.IssueSeverity.WARNING, - translation_key=issue_id, - translation_placeholders={ - "relative_time": "relative_time()", - "time_since": "time_since()", - "time_until": "time_until()", - }, - ) - _LOGGER.warning("Template function 'relative_time' is deprecated") - - warn_relative_time_deprecated() if (render_info := _render_info.get()) is not None: render_info.has_time = True diff --git a/tests/helpers/test_template.py b/tests/helpers/test_template.py index d134570d119..a241f6b7234 100644 --- a/tests/helpers/test_template.py +++ b/tests/helpers/test_template.py @@ -31,7 +31,7 @@ from homeassistant.const import ( UnitOfTemperature, UnitOfVolume, ) -from homeassistant.core import DOMAIN as HA_DOMAIN, HomeAssistant +from homeassistant.core import HomeAssistant from homeassistant.exceptions import TemplateError from homeassistant.helpers import ( area_registry as ar, @@ -2240,7 +2240,6 @@ def test_relative_time(mock_is_safe, hass: HomeAssistant) -> None: """Test relative_time method.""" hass.config.set_time_zone("UTC") now = datetime.strptime("2000-01-01 10:00:00 +00:00", "%Y-%m-%d %H:%M:%S %z") - issue_registry = ir.async_get(hass) relative_time_template = ( '{{relative_time(strptime("2000-01-01 09:00:00", "%Y-%m-%d %H:%M:%S"))}}' ) @@ -2250,9 +2249,6 @@ def test_relative_time(mock_is_safe, hass: HomeAssistant) -> None: hass, ).async_render() assert result == "1 hour" - assert issue_registry.async_get_issue( - HA_DOMAIN, "template_function_relative_time_deprecated" - ) result = template.Template( ( "{{"