Working Automation with Telegram Errors

Well, the meat of the errors is here:

Error sending message: Invalid server response

and here:

Error sending file: Timed out.

I found the second error in the source file. Are you getting a debug message “Last message ID: …” before any these errors?

or “Update last message: …”

I will set to debug and re-run automations

It’s probably not worth it. I debugged down all the way to the errors and their meaning and both point to connection issues. Both errors inherit from NetworkError.

To what/where?

To the telegram bot I’m guessing. I have no idea what this device is. If its internal to your network, then you are having network issues. If its external from your network, then it’s having trouble sending or receiving a ‘confirmation’ from the send.

I just looked it up, its a cloud based service. So most likely, your network isn’t routing the telegram bot responses back to HA properly. This may be caused by your router/network configuration.

I see, am I supposed to have responses back to HASS from the Bot, even though I’m only sending messages?

Standard protocal when sending messages is to do the following:

send message.
wait for reply that message was sent.
Do something based on that reply.

you are getting errors based on the ‘do something based on that reply’. The errors you are getting lead me to believe that you are not actually getting a reply. TimeOuts are typically errors associated with a waiting period, if we don’t get a reply in that waiting period, error out.

Could it be a configuration issue on my part, or maybe some config vaiables to the Bot.?

I just followed the docs to setup.

I mean, the only thing I noticed was chat id’s were pretty important. Are you specifying that?

Yes, otherwise, would I even receive the messages?

configuration.yaml:
telegram_bot:
- platform: polling
api_key: !secret telegram_api_key
allowed_chat_ids:
- !secret telegram_chat_id
parse_mode: html

notify:
- platform: telegram
chat_id: !secret telegram_chat_id
name: Telegram

The other thing you could do is ignore the errors because you are getting the messsages:

logger:
  default: debug
  logs:
    homeassistant.components.telegram_bot: critical

This should suppress everything but python errors for telegram_bot.

I was hopping to resolve it rather than ignore it, but that works.

2018-04-17 12:15:23 DEBUG (Thread-16) [homeassistant.components.notify.telegram] TELEGRAM NOTIFIER calling telegram_bot.send_message with {'target': 390135429, 'message': 'HASSBIAN SERVER HAS STARTED'}
2018-04-17 12:15:24 DEBUG (MainThread) [homeassistant.components.telegram_bot] New telegram message send_message: {'target': [390135429], 'message': 'HASSBIAN SERVER HAS STARTED'}
2018-04-17 12:15:24 DEBUG (Thread-16) [homeassistant.components.telegram_bot] Send message in chat ID 390135429 with params: {'reply_to_message_id': None, 'reply_markup': None, 'timeout': None, 'parse_mode': 'HTML', 'disable_notification': False, 'disable_web_page_preview': None}
2018-04-17 12:15:25 DEBUG (Thread-16) [homeassistant.components.telegram_bot] Last message ID: {390135429: 11784} (from chat_id 390135429)
2018-04-17 12:15:43 DEBUG (Thread-18) [homeassistant.components.notify.telegram] TELEGRAM NOTIFIER calling telegram_bot.send_message with {'target': 390135429, 'message': 'Pi3 CPU temperature is currently 127.7°!'}
2018-04-17 12:15:43 DEBUG (MainThread) [homeassistant.components.telegram_bot] New telegram message send_message: {'target': [390135429], 'message': 'Pi3 CPU temperature is currently 127.7°!'}
2018-04-17 12:15:43 DEBUG (Thread-2) [homeassistant.components.telegram_bot] Send message in chat ID 390135429 with params: {'reply_to_message_id': None, 'reply_markup': None, 'timeout': None, 'parse_mode': 'HTML', 'disable_notification': False, 'disable_web_page_preview': None}
2018-04-17 12:15:43 DEBUG (Thread-2) [homeassistant.components.telegram_bot] Last message ID: {390135429: 11785} (from chat_id 390135429)
2018-04-17 12:22:11 DEBUG (MainThread) [homeassistant.components.telegram_bot] New telegram message send_photo: {'file': '/home/homeassistant/.homeassistant/cameraimages/frontdoor.jpg', 'title': 'Front Door Alert!', 'target': [390135429], 'message': 'Someone is at the front door.'}
2018-04-17 12:22:11 DEBUG (Thread-15) [homeassistant.components.telegram_bot] Send file to chat ID 390135429. Caption: None.
2018-04-17 12:22:13 DEBUG (Thread-15) [homeassistant.components.telegram_bot] Last message ID: {390135429: 11786} (from chat_id 390135429)
2018-04-17 12:50:19 DEBUG (Thread-20) [homeassistant.components.notify.telegram] TELEGRAM NOTIFIER calling telegram_bot.send_message with {'target': 390135429, 'message': 'Bruce has arrived home.'}
2018-04-17 12:50:19 DEBUG (MainThread) [homeassistant.components.telegram_bot] New telegram message send_message: {'target': [390135429], 'message': 'Bruce has arrived home.'}
2018-04-17 12:50:19 DEBUG (Thread-19) [homeassistant.components.telegram_bot] Send message in chat ID 390135429 with params: {'reply_to_message_id': None, 'reply_markup': None, 'timeout': None, 'parse_mode': 'HTML', 'disable_notification': False, 'disable_web_page_preview': None}
2018-04-17 12:50:24 ERROR (Thread-19) [homeassistant.components.telegram_bot] Error sending message: Timed out. Args: (390135429, 'Bruce has arrived home.'), kwargs: {'reply_to_message_id': None, 'reply_markup': None, 'timeout': None, 'parse_mode': 'HTML', 'disable_notification': False, 'disable_web_page_preview': None}

Hi,

I have suddenly the same problem.
My automations have worked always but today I start having this errors:

ERROR (SyncWorker_7) [homeassistant.components.telegram_bot] Error sending file: Invalid server response. Args: (383126596, <_io.BufferedReader name='/home/homeassistant/.homeassistant/snapshot/montage_cam03_cam05/montage_cam03_cam05.jpg'>), kwargs: {'caption': '', 'parse_mode': 'HTML', 'disable_notification': False, 'disable_web_page_preview': None, 'reply_to_message_id': None, 'reply_markup': None, 'timeout': None}
ERROR (SyncWorker_9) [homeassistant.components.telegram_bot] Error sending message: Timed out. Args: (383126596, 'Test bericht 11:17\nTest bericht'), kwargs: {'parse_mode': 'HTML', 'disable_notification': False, 'disable_web_page_preview': None, 'reply_to_message_id': None, 'reply_markup': None, 'timeout': None}

Nothing changed…

Erik

Same here. Worked yesterday.

ERROR (SyncWorker_5) [homeassistant.components.telegram_bot] Error sending file: Invalid server response. Args: (12387915, <_io.BufferedReader name=‘/config/screenshots/webcamachter.jpg’>), kwargs: {‘caption’: None, ‘parse_mode’: ‘Markdown’, ‘disable_notification’: False, ‘disable_web_page_preview’: None, ‘reply_to_message_id’: None, ‘reply_markup’: None, ‘timeout’: None}

I get this too. All of a sudden. Before that can use normally. Now cannot get any message from HA send to telegram.

Error sending message: Timed out. Args: (538149656, “Janet:\nGood Evening.”), kwargs: {‘parse_mode’: ‘Markdown’, ‘disable_notification’: False, ‘disable_web_page_preview’: None, ‘reply_to_message_id’: None, ‘reply_markup’: None, ‘timeout’: None}
5:13 PM components/telegram_bot/init.py (ERROR)

I think telegram is having problems atm, maybe something to do with Russia trying to ban it or whatever, but all my conversations say “updating”.

Telegram Twitter said:

Repairs are ongoing after a massive power outage in the Amsterdam region that affected many services. Telegram users in Europe, MENA, Russia and the CIS are currently unable to connect. We apologize and will update you on the progress

1 Like

Back working here.