1
0
mirror of https://github.com/home-assistant/core.git synced 2026-02-15 07:36:16 +00:00

Deprecate legacy Telegram notify service (#150720)

Co-authored-by: G Johansson <goran.johansson@shiftit.se>
Co-authored-by: Abílio Costa <abmantis@users.noreply.github.com>
Co-authored-by: abmantis <amfcalt@gmail.com>
This commit is contained in:
hanwg
2025-10-30 02:40:27 +08:00
committed by GitHub
parent 40995b6d32
commit 569dd2d6b7
3 changed files with 31 additions and 4 deletions

View File

@@ -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)

View File

@@ -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.",

View File

@@ -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