home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.05k stars 31.07k forks source link

Error sending messages from Telegram bot #122876

Open riopedre opened 4 months ago

riopedre commented 4 months ago

The problem

Some of the messages I send to Telegram using Telegram bot are missing in a random way. I was using notify service. Changed to telegram_bot.send_message service but it fails the same. I have updated to last core version with the same result.

What version of Home Assistant Core has the issue?

core-2024.7.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

telegram bot

Link to integration documentation on our website

https://www.home-assistant.io/integrations/telegram_bot

Diagnostics information

No response

Example YAML snippet

telegram_bot:
  - platform: polling
    api_key: !secret telegram_api_key
    allowed_chat_ids:
      - !secret telegram_chat_id_one
      - !secret telegram_chat_id_two

notify:
  - name: telegram_one
    platform: telegram
    chat_id: !secret telegram_chat_id_one
  - name: telegram_two
    platform: telegram                          
    chat_id: !secret telegram_chat_id_two

Anything in the logs that might be useful for us?

Registrador: homeassistant.components.telegram_bot
Fuente: components/telegram_bot/__init__.py:717
integración: Telegram bot (documentación, problemas)
Ocurrió por primera vez: 20:34:05 (2 ocurrencias)
Último inicio de sesión: 20:34:10

Error sending message: Timed out. Args: (Id_one, 'Subiendo la persiana izquierda de la terraza...'), kwargs: {'parse_mode': <ParseMode.MARKDOWN>, 'disable_web_page_preview': None, 'disable_notification': False, 'reply_to_message_id': None, 'reply_markup': None, 'read_timeout': 60, 'message_thread_id': None}
Error sending message: Timed out. Args: (Id_two, 'Subiendo la persiana izquierda de la terraza...'), kwargs: {'parse_mode': <ParseMode.MARKDOWN>, 'disable_web_page_preview': None, 'disable_notification': False, 'reply_to_message_id': None, 'reply_markup': None, 'read_timeout': None, 'message_thread_id': None}

Additional information

I'm using a script that send the same message to two different people with different chat_id according to the state of two helpers that enable the sending of the message. In one of the chats I've added 'timeout: 60'. I think that when a message fails, is in both chats but I'm not sure about that.

home-assistant[bot] commented 4 months ago

telegram_bot documentation telegram_bot source

riopedre commented 3 months ago

I have made a new telegram bot two days ago, and changed telegram api key to use new bot. Today I've lost one message. "Error sending message: Timed out" again

titovskiy commented 3 months ago

have same problem (ha 2024.8.1)

Error sending message: Timed out. Args: (XXXX, 'HA запущен'), kwargs: {'parse_mode': <ParseMode.MARKDOWN>, 'disable_web_page_preview': None, 'disable_notification': False, 'reply_to_message_id': None, 'reply_markup': None, 'read_timeout': None, 'message_thread_id': None}

paule1120 commented 3 months ago

Hello, same error . Sometimes after a restart it works better and sometimes nothing happens

`Logger: homeassistant.components.telegram_bot Quelle: components/telegram_bot/init.py:717 Integration: Telegram bot (Dokumentation, Probleme) Erstmals aufgetreten: 17. August 2024 um 21:08:50 (4 Vorkommnisse) Zuletzt protokolliert: 16:42:20

Error sending message: Timed out. Args: (TG id, 'Das Fenster im Bad ist seit 10min offen! 23.8°C / 72.4%'), kwargs: {'parse_mode': , 'disable_web_page_preview': None, 'disable_notification': False, 'reply_to_message_id': None, 'reply_markup': None, 'read_timeout': None, 'message_thread_id': None} Error sending message: Timed out. Args: (TG id7, 'Das Fenster im Bad ist seit 10min offen! 22.3°C / 76.4%'), kwargs: {'parse_mode': , 'disable_web_page_preview': None, 'disable_notification': False, 'reply_to_message_id': None, 'reply_markup': None, 'read_timeout': None, 'message_thread_id': None} Error sending message: Timed out. Args: (TG id, 'Das Fenster im Bad ist seit 10min offen! 22.6°C / 73.5%'), kwargs: {'parse_mode': , 'disable_web_page_preview': None, 'disable_notification': False, 'reply_to_message_id': None, 'reply_markup': None, 'read_timeout': None, 'message_thread_id': None} Error sending message: Timed out. Args: (TG id, 'Die Außentemperatur beträgt zur Zeit 19.0 °C / Garten: 18.4°C / Hof: 18.4 °C'), kwargs: {'parse_mode': , 'disable_web_page_preview': None, 'disable_notification': False, 'reply_to_message_id': None, 'reply_markup': None, 'read_timeout': None, 'message_thread_id': None}`

dadada3000 commented 3 months ago

Same thing Error sending message: Timed out.

sejtam commented 3 months ago

same here (with 2024.8.2) . one test message worked, after that nothing

2024-08-20 09:58:41.952 ERROR (MainThread) [homeassistant.components.telegram_bot] Error sending message: Timed out. Args: (-4....1, 'test2'), kwargs: {'parse_mode': <ParseMode.MARKDOWN>, 'disable_web_page_preview': None, 'disable_notification': False, 'reply_to_message_id': None, 'reply_markup': None, 'read_timeout': None, 'message_thread_id': None}

riopedre commented 3 months ago

Approximately 90% of my automations are in Node Red. Until now Telegram notifications were done by calling a Home Assistant script. Last Sunday, I changed these notifications to Node Red directly using nodes from the 'node-red-contrib-telegrambot' palette. Since that moment and after four days, I have not missed any Telegram notifications. I think this indicates that there is a problem with the Home Assistant Telegram_bot integration. Perhaps a library that this integration depends on has recently changed and this error is a side effect. Who knows

aquashrimps commented 3 months ago

the exact same error occurs when sending service messages. At the same time, no such error occurred before the update (2024.6.1 for sure). `homeassistant.components.telegram_bot Source: components/telegram_bot/init.py:717 Integration: Telegram bot (Documentation, problems)

Error sending message: Timed out. Args: (1087794605, '🌍 san xxxxxxxxxxxxxxx'), kwargs: {'parse_mode': , 'disable_web_page_preview': None, 'disable_notification': False, 'reply_to_message_id': None, 'reply_markup': None, 'read_timeout': None, 'message_thread_id': None}`

Core 2024.8.3 Supervisor 2024.08.0 Operating System 13.1

sosso-b commented 2 months ago

Hi, same for me , i never have this issue before but i cannot give the core version

My actual configuration Core 2024.9.3 Supervisor 2024.09.1 Operating System 13.1 Interface utilisateur 20240909.1

and i have 90% of the message who are ok and 10% time out , hope this will be solve in the next core update

sermayoral commented 1 month ago

II've tried with polling and webhooks, and the same thing happens to me, some messages are not sent due to timeout. It's very frustrating because this worked very well a few months ago. Do you know of any alternative without using Node-Red? Thank you very much.

riopedre commented 4 weeks ago

II've tried with polling and webhooks, and the same thing happens to me, some messages are not sent due to timeout. It's very frustrating because this worked very well a few months ago. Do you know of any alternative without using Node-Red? Thank you very much.

Sorry. I don't know any alternative of Telegram notifications without HA or NodeRed. With NodeRed, I don't have any problem. You can change to another notifications platform alternative like HA Companion aplication.

sosso-b commented 4 weeks ago

Hi , i want to share with you how i arrive to avoid to have this issue actually. To solve that I stop the extension Adguard Home. Since that i do not have anymore this time out. Look like something is not ok with both working together.

riopedre commented 3 weeks ago

Hi , i want to share with you how i arrive to avoid to have this issue actually. To solve that I stop the extension Adguard Home. Since that i do not have anymore this time out. Look like something is not ok with both working together.

I have Adguard Home installed. But i don't want to disable it. I have compared my HA logs to see when I've lost a Telegram message and compare with Adguard logs to see any coincidence, any DNS request denegated by an Adguard filter and I can see nothing. It would be nice if the rest of people that has the same problems with Telegram messages could tell us if they are using Adguard Home. Thanks

sosso-b commented 3 weeks ago

It's was not a pleasure for me to do it because I need it to but due to the fact no one was helping on this issue I was testing a lot think. An till now since and chance the DNS on my server and do not pass the traffic via Adguard I can tell that no more 1 time out with telegram. Then for me this was the issue. But in the past I have Adguard and telegram working great. I don't know what happens. But yes if someone can like you share information that would be great 😃

aquashrimps commented 3 weeks ago

the problem with Adguard is clearly indirect, because I don't have it, but there is a problem. Therefore, it is worth considering other possible options, rather than relying on only one Adguard...

sosso-b commented 3 weeks ago

Based on your information, I'm considering that something in the network configuration may be causing delays in sending and responding to Telegram requests, leading to this timeout error.

For me, it was Adguard, but for others, it could be any DNS filter.

Anyway, thank you for the information!