diff --git a/homeassistant/components/telegram/notify.py b/homeassistant/components/telegram/notify.py index 6b9cf43bf71..eff5d3b5635 100644 --- a/homeassistant/components/telegram/notify.py +++ b/homeassistant/components/telegram/notify.py @@ -24,7 +24,8 @@ from homeassistant.components.telegram_bot import ( ) from homeassistant.const import ATTR_LOCATION from homeassistant.core import HomeAssistant -from homeassistant.helpers.reload import setup_reload_service +from homeassistant.helpers import issue_registry as ir +from homeassistant.helpers.reload import async_setup_reload_service from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from . import DOMAIN, PLATFORMS @@ -45,14 +46,25 @@ PLATFORM_SCHEMA = NOTIFY_PLATFORM_SCHEMA.extend( ) -def get_service( +async def async_get_service( hass: HomeAssistant, config: ConfigType, discovery_info: DiscoveryInfoType | None = None, ) -> TelegramNotificationService: """Get the Telegram notification service.""" - setup_reload_service(hass, DOMAIN, PLATFORMS) + ir.async_create_issue( + hass, + DOMAIN, + "migrate_notify", + breaks_in_ha_version="2026.5.0", + is_fixable=False, + translation_key="migrate_notify", + severity=ir.IssueSeverity.WARNING, + learn_more_url="https://www.home-assistant.io/integrations/telegram_bot#notifiers", + ) + + await async_setup_reload_service(hass, DOMAIN, PLATFORMS) chat_id = config.get(CONF_CHAT_ID) return TelegramNotificationService(hass, chat_id) diff --git a/homeassistant/components/telegram/strings.json b/homeassistant/components/telegram/strings.json index 054fc10e2a5..db697256b88 100644 --- a/homeassistant/components/telegram/strings.json +++ b/homeassistant/components/telegram/strings.json @@ -1,4 +1,10 @@ { + "issues": { + "migrate_notify": { + "description": "The Telegram `notify` service has been migrated. A new `notify` entity per chat ID is available now.\n\nUpdate all affected automations to use the new `notify.send_message` action exposed by these new entities and then restart Home Assistant.", + "title": "Migration of Telegram notify service" + } + }, "services": { "reload": { "description": "Reloads telegram notify services.", diff --git a/tests/components/telegram/test_notify.py b/tests/components/telegram/test_notify.py index e1daf4da074..67cfdd8b76a 100644 --- a/tests/components/telegram/test_notify.py +++ b/tests/components/telegram/test_notify.py @@ -7,12 +7,15 @@ from homeassistant.components import notify from homeassistant.components.telegram import DOMAIN from homeassistant.const import SERVICE_RELOAD from homeassistant.core import HomeAssistant +from homeassistant.helpers import issue_registry as ir from homeassistant.setup import async_setup_component from tests.common import get_fixture_path -async def test_reload_notify(hass: HomeAssistant) -> None: +async def test_reload_notify( + hass: HomeAssistant, issue_registry: ir.IssueRegistry +) -> None: """Verify we can reload the notify service.""" with patch("homeassistant.components.telegram_bot.async_setup", return_value=True): @@ -45,3 +48,9 @@ async def test_reload_notify(hass: HomeAssistant) -> None: assert not hass.services.has_service(notify.DOMAIN, DOMAIN) assert hass.services.has_service(notify.DOMAIN, "telegram_reloaded") + + assert issue_registry.async_get_issue( + domain=DOMAIN, + issue_id="migrate_notify", + ) + assert len(issue_registry.issues) == 1