Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/telegram_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def async_setup(hass, config):
try:
receiver_service = yield from \
platform.async_setup_platform(hass, p_config)
if receiver_service is None:
if receiver_service is False:
_LOGGER.error(
"Failed to initialize Telegram bot %s", p_type)
return False
Expand Down
28 changes: 28 additions & 0 deletions homeassistant/components/telegram_bot/broadcast.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
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 asyncio
import logging

from homeassistant.components.telegram_bot import (
PLATFORM_SCHEMA as TELEGRAM_PLATFORM_SCHEMA)
from homeassistant.const import CONF_API_KEY

_LOGGER = logging.getLogger(__name__)

PLATFORM_SCHEMA = TELEGRAM_PLATFORM_SCHEMA


@asyncio.coroutine
def async_setup_platform(hass, config):
"""Set up the Telegram broadcast platform."""
# Check the API key works
import telegram
bot = telegram.Bot(config[CONF_API_KEY])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think one of that line is not async safe...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they are, but not the next, getting the bot username. Pushed a commit to fix

bot_config = yield from hass.async_add_job(bot.getMe)
_LOGGER.debug("Telegram broadcast platform setup with bot %s",
bot_config['username'])
return True