8000 Fix send telegram notification to multiple chats by saippuakauppias · Pull Request #144922 · home-assistant/core · GitHub
[go: up one dir, main page]

Skip to content

Fix send telegram notification to multiple chats #144922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

saippuakauppias
Copy link
8000

Proposed change

This PR fixes an issue with the Telegram Bot integration when multiple bots are configured. Previously, when multiple telegram_bot entries were set up in configuration.yaml, messages were always sent through the last initialized bot, regardless of the specified target chat_id.

The fix maintains a list of all notification services and selects the appropriate one based on the target chat ID when sending messages. This ensures messages are routed through the correct bot.

Type of change

  • Bugfix (non-breaking change which fixes an issue)

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

To help with the load of incoming pull requests:

Copy link
@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

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

Hi @saippuakauppias

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@saippuakauppias saippuakauppias marked this pull request as ready for review May 14, 2025 20:19
@home-assistant home-assistant bot dismissed their stale review May 14, 2025 20:19

Stale

@hanwg
Copy link
Contributor
hanwg commented May 22, 2025

what happens if both chat bots have the same chat ids?

@MartinHjelmare

This comment was marked as outdated.

@MartinHjelmare MartinHjelmare marked this pull request as draft May 22, 2025 13:57
@saippuakauppias
Copy link
Author
saippuakauppias commented May 23, 2025

what happens if both chat bots have the same chat ids?

@hanwg, The message will go out in the first one. There is a test for this: test_multiple_bots_with_overlapping_chat_ids

@saippuakauppias

This comment was marked as outdated.

@saippuakauppias saippuakauppias marked this pull request as ready for review May 23, 2025 19:56
@MartinHjelmare MartinHjelmare marked this pull request as draft May 23, 2025 21:42
@MartinHjelmare
Copy link
Member

It has never worked to configure more than one platform so this isn't a critical fix.

@MartinHjelmare
Copy link
Member

I'll close here now.

@github-actions github-actions bot locked and limited conversation to collaborators May 24, 2025
@MartinHjelmare MartinHjelmare reopened this Jun 2, 2025
@home-assistant home-assistant unlocked this conversation Jun 2, 2025
@MartinHjelmare
Copy link
Member

@saippuakauppias The config flow PR for the telegram bot integration has been merged. You're welcome to adapt this branch to work with config entries.

We can use the chat ID to look up the config entry by iterating the config entries for the telegram bot domain and their subentries. Each config subentry corresponds to one chat ID.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

If you define multiple telegram_bots messages are sent to the wrong chat
3 participants
0