core: If you define multiple telegram_bots messages are sent to the wrong chat

The problem

I defined two telegram bots in configuration.yaml

telegram_bot:
  - platform: broadcast
    api_key: "49...."
    allowed_chat_ids:
      - -30...   
  - platform: broadcast
    api_key: "53...."
    allowed_chat_ids:
      - 23...   

and the corresponding notifiers

notify:
  - platform: telegram
    name: "citofono"
    chat_id: -30...
  - platform: telegram
    name: "furgo"
    chat_id: 23...

There is no warning or error message in the log indicating that the configuration is wrong, but if I try to send a message using the first notifier the messages are sent to the wrong chat , in fact I see this warning in the log: WARNING (MainThread) [homeassistant.components.telegram_bot] Disallowed targets: [-30...], using default: 23...

What version of Home Assistant Core has the issue?

core-2025.1.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

telegram_bot

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet


Anything in the logs that might be useful for us?


Additional information

I’m not sure if the bug is in the the telegram integration that should find a telegram_bot based on the chat_id or it should be done by the telegram_bot integration.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 1
  • Comments: 18 (4 by maintainers)

Most upvoted comments

Well, then at least it should give a warning that the configuration is wrong and in any case it shouldn’t send a message to the wrong chat.

So TPTB think that sending a message to a random recipient instead of the correct one is not a bug? Nice 💩 . Not to mention that there is no warning/error message telling you HA is ignoring your configuration. Meanwhile I modified the configuration to use just one bot and gave it access to all the chats 😒

Unfortunately, the fix has not been accepted, although it completely fixes the issue mentioned. It was not accepted simply because they thought it was not a bug.

You can copy all the files from the branch with the fix to your /homeassistant/custom_components/telegram_bot and restart HA, but this integration will no longer be updated.