2017-06-27 05:22:33 +00:00
|
|
|
"""
|
|
|
|
Telegram bot implementation to send messages only.
|
|
|
|
|
|
|
|
For more details about this platform, please refer to the documentation at
|
|
|
|
https://home-assistant.io/components/telegram_bot.broadcast/
|
|
|
|
"""
|
|
|
|
import logging
|
|
|
|
|
|
|
|
from homeassistant.components.telegram_bot import (
|
2018-03-07 11:44:07 +00:00
|
|
|
initialize_bot,
|
2017-06-27 05:22:33 +00:00
|
|
|
PLATFORM_SCHEMA as TELEGRAM_PLATFORM_SCHEMA)
|
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
PLATFORM_SCHEMA = TELEGRAM_PLATFORM_SCHEMA
|
|
|
|
|
|
|
|
|
2018-10-01 06:56:50 +00:00
|
|
|
async def async_setup_platform(hass, config):
|
2017-06-27 05:22:33 +00:00
|
|
|
"""Set up the Telegram broadcast platform."""
|
|
|
|
# Check the API key works
|
2018-03-07 11:44:07 +00:00
|
|
|
|
|
|
|
bot = initialize_bot(config)
|
|
|
|
|
2018-10-01 06:56:50 +00:00
|
|
|
bot_config = await hass.async_add_job(bot.getMe)
|
2017-06-27 05:22:33 +00:00
|
|
|
_LOGGER.debug("Telegram broadcast platform setup with bot %s",
|
|
|
|
bot_config['username'])
|
|
|
|
return True
|