diff --git a/homeassistant/components/telegram_bot/__init__.py b/homeassistant/components/telegram_bot/__init__.py index cb22487ba63..7a9d0c18e92 100644 --- a/homeassistant/components/telegram_bot/__init__.py +++ b/homeassistant/components/telegram_bot/__init__.py @@ -354,26 +354,32 @@ async def async_setup(hass, config): _LOGGER.debug("New telegram message %s: %s", msgtype, kwargs) if msgtype == SERVICE_SEND_MESSAGE: - await hass.async_add_job(partial(notify_service.send_message, **kwargs)) + await hass.async_add_executor_job( + partial(notify_service.send_message, **kwargs) + ) elif msgtype in [ SERVICE_SEND_PHOTO, SERVICE_SEND_STICKER, SERVICE_SEND_VIDEO, SERVICE_SEND_DOCUMENT, ]: - await hass.async_add_job( + await hass.async_add_executor_job( partial(notify_service.send_file, msgtype, **kwargs) ) elif msgtype == SERVICE_SEND_LOCATION: - await hass.async_add_job(partial(notify_service.send_location, **kwargs)) + await hass.async_add_executor_job( + partial(notify_service.send_location, **kwargs) + ) elif msgtype == SERVICE_ANSWER_CALLBACK_QUERY: - await hass.async_add_job( + await hass.async_add_executor_job( partial(notify_service.answer_callback_query, **kwargs) ) elif msgtype == SERVICE_DELETE_MESSAGE: - await hass.async_add_job(partial(notify_service.delete_message, **kwargs)) + await hass.async_add_executor_job( + partial(notify_service.delete_message, **kwargs) + ) else: - await hass.async_add_job( + await hass.async_add_executor_job( partial(notify_service.edit_message, msgtype, **kwargs) ) diff --git a/homeassistant/components/telegram_bot/broadcast.py b/homeassistant/components/telegram_bot/broadcast.py index 2330c9b4097..dd0d4cd1f31 100644 --- a/homeassistant/components/telegram_bot/broadcast.py +++ b/homeassistant/components/telegram_bot/broadcast.py @@ -10,7 +10,7 @@ async def async_setup_platform(hass, config): """Set up the Telegram broadcast platform.""" bot = initialize_bot(config) - bot_config = await hass.async_add_job(bot.getMe) + bot_config = await hass.async_add_executor_job(bot.getMe) _LOGGER.debug( "Telegram broadcast platform setup with bot %s", bot_config["username"] ) diff --git a/homeassistant/components/telegram_bot/webhooks.py b/homeassistant/components/telegram_bot/webhooks.py index 4d5f41066e2..f772e2411e5 100644 --- a/homeassistant/components/telegram_bot/webhooks.py +++ b/homeassistant/components/telegram_bot/webhooks.py @@ -32,7 +32,7 @@ async def async_setup_platform(hass, config): bot = initialize_bot(config) - current_status = await hass.async_add_job(bot.getWebhookInfo) + current_status = await hass.async_add_executor_job(bot.getWebhookInfo) base_url = config.get( CONF_URL, get_url(hass, require_ssl=True, allow_internal=False) ) @@ -64,7 +64,7 @@ async def async_setup_platform(hass, config): _LOGGER.warning("Timeout trying to set webhook (retry #%d)", retry_num) if current_status and current_status["url"] != handler_url: - result = await hass.async_add_job(_try_to_set_webhook) + result = await hass.async_add_executor_job(_try_to_set_webhook) if result: _LOGGER.info("Set new telegram webhook %s", handler_url) else: