Skip to content

Commit 569dd2d

Browse files
hanwggjohansson-STabmantis
authored
Deprecate legacy Telegram notify service (#150720)
Co-authored-by: G Johansson <[email protected]> Co-authored-by: Abílio Costa <[email protected]> Co-authored-by: abmantis <[email protected]>
1 parent 40995b6 commit 569dd2d

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

homeassistant/components/telegram/notify.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
)
2525
from homeassistant.const import ATTR_LOCATION
2626
from homeassistant.core import HomeAssistant
27-
from homeassistant.helpers.reload import setup_reload_service
27+
from homeassistant.helpers import issue_registry as ir
28+
from homeassistant.helpers.reload import async_setup_reload_service
2829
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
2930

3031
from . import DOMAIN, PLATFORMS
@@ -45,14 +46,25 @@
4546
)
4647

4748

48-
def get_service(
49+
async def async_get_service(
4950
hass: HomeAssistant,
5051
config: ConfigType,
5152
discovery_info: DiscoveryInfoType | None = None,
5253
) -> TelegramNotificationService:
5354
"""Get the Telegram notification service."""
5455

55-
setup_reload_service(hass, DOMAIN, PLATFORMS)
56+
ir.async_create_issue(
57+
hass,
58+
DOMAIN,
59+
"migrate_notify",
60+
breaks_in_ha_version="2026.5.0",
61+
is_fixable=False,
62+
translation_key="migrate_notify",
63+
severity=ir.IssueSeverity.WARNING,
64+
learn_more_url="https://www.home-assistant.io/integrations/telegram_bot#notifiers",
65+
)
66+
67+
await async_setup_reload_service(hass, DOMAIN, PLATFORMS)
5668
chat_id = config.get(CONF_CHAT_ID)
5769
return TelegramNotificationService(hass, chat_id)
5870

homeassistant/components/telegram/strings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{
2+
"issues": {
3+
"migrate_notify": {
4+
"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.",
5+
"title": "Migration of Telegram notify service"
6+
}
7+
},
28
"services": {
39
"reload": {
410
"description": "Reloads telegram notify services.",

tests/components/telegram/test_notify.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77
from homeassistant.components.telegram import DOMAIN
88
from homeassistant.const import SERVICE_RELOAD
99
from homeassistant.core import HomeAssistant
10+
from homeassistant.helpers import issue_registry as ir
1011
from homeassistant.setup import async_setup_component
1112

1213
from tests.common import get_fixture_path
1314

1415

15-
async def test_reload_notify(hass: HomeAssistant) -> None:
16+
async def test_reload_notify(
17+
hass: HomeAssistant, issue_registry: ir.IssueRegistry
18+
) -> None:
1619
"""Verify we can reload the notify service."""
1720

1821
with patch("homeassistant.components.telegram_bot.async_setup", return_value=True):
@@ -45,3 +48,9 @@ async def test_reload_notify(hass: HomeAssistant) -> None:
4548

4649
assert not hass.services.has_service(notify.DOMAIN, DOMAIN)
4750
assert hass.services.has_service(notify.DOMAIN, "telegram_reloaded")
51+
52+
assert issue_registry.async_get_issue(
53+
domain=DOMAIN,
54+
issue_id="migrate_notify",
55+
)
56+
assert len(issue_registry.issues) == 1

0 commit comments

Comments
 (0)