diff --git a/homeassistant/components/telegram/notify.py b/homeassistant/components/telegram/notify.py index adb947bcf6b..6b9cf43bf71 100644 --- a/homeassistant/components/telegram/notify.py +++ b/homeassistant/components/telegram/notify.py @@ -20,17 +20,17 @@ from homeassistant.components.telegram_bot import ( ATTR_MESSAGE_TAG, ATTR_MESSAGE_THREAD_ID, ATTR_PARSER, + DOMAIN as TELEGRAM_BOT_DOMAIN, ) from homeassistant.const import ATTR_LOCATION from homeassistant.core import HomeAssistant from homeassistant.helpers.reload import setup_reload_service from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType -from . import DOMAIN as TELEGRAM_DOMAIN, PLATFORMS +from . import DOMAIN, PLATFORMS _LOGGER = logging.getLogger(__name__) -DOMAIN = "telegram_bot" ATTR_KEYBOARD = "keyboard" ATTR_INLINE_KEYBOARD = "inline_keyboard" ATTR_PHOTO = "photo" @@ -52,7 +52,7 @@ def get_service( ) -> TelegramNotificationService: """Get the Telegram notification service.""" - setup_reload_service(hass, TELEGRAM_DOMAIN, PLATFORMS) + setup_reload_service(hass, DOMAIN, PLATFORMS) chat_id = config.get(CONF_CHAT_ID) return TelegramNotificationService(hass, chat_id) @@ -115,37 +115,45 @@ class TelegramNotificationService(BaseNotificationService): photos = photos if isinstance(photos, list) else [photos] for photo_data in photos: service_data.update(photo_data) - self.hass.services.call(DOMAIN, "send_photo", service_data=service_data) + self.hass.services.call( + TELEGRAM_BOT_DOMAIN, "send_photo", service_data=service_data + ) return None if data is not None and ATTR_VIDEO in data: videos = data.get(ATTR_VIDEO) videos = videos if isinstance(videos, list) else [videos] for video_data in videos: service_data.update(video_data) - self.hass.services.call(DOMAIN, "send_video", service_data=service_data) + self.hass.services.call( + TELEGRAM_BOT_DOMAIN, "send_video", service_data=service_data + ) return None if data is not None and ATTR_VOICE in data: voices = data.get(ATTR_VOICE) voices = voices if isinstance(voices, list) else [voices] for voice_data in voices: service_data.update(voice_data) - self.hass.services.call(DOMAIN, "send_voice", service_data=service_data) + self.hass.services.call( + TELEGRAM_BOT_DOMAIN, "send_voice", service_data=service_data + ) return None if data is not None and ATTR_LOCATION in data: service_data.update(data.get(ATTR_LOCATION)) return self.hass.services.call( - DOMAIN, "send_location", service_data=service_data + TELEGRAM_BOT_DOMAIN, "send_location", service_data=service_data ) if data is not None and ATTR_DOCUMENT in data: service_data.update(data.get(ATTR_DOCUMENT)) return self.hass.services.call( - DOMAIN, "send_document", service_data=service_data + TELEGRAM_BOT_DOMAIN, "send_document", service_data=service_data ) # Send message _LOGGER.debug( - "TELEGRAM NOTIFIER calling %s.send_message with %s", DOMAIN, service_data + "TELEGRAM NOTIFIER calling %s.send_message with %s", + TELEGRAM_BOT_DOMAIN, + service_data, ) return self.hass.services.call( - DOMAIN, "send_message", service_data=service_data + TELEGRAM_BOT_DOMAIN, "send_message", service_data=service_data )