Skip to content

Add download file service to Telegram bot integration#154625

Merged
MartinHjelmare merged 59 commits intohome-assistant:devfrom
aviadlevy:download_file
Dec 22, 2025
Merged

Add download file service to Telegram bot integration#154625
MartinHjelmare merged 59 commits intohome-assistant:devfrom
aviadlevy:download_file

Conversation

@aviadlevy
Copy link
Copy Markdown
Contributor

@aviadlevy aviadlevy commented Oct 16, 2025

Breaking change

Nope

Proposed change

Adding download file service to Telegram bot integration. The new service will get file_id and optional directory path and file name variables and will download the file from telegram to that location

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • I understand the code I am submitting and can explain how it works.
  • 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.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

To help with the load of incoming pull requests:

@home-assistant
Copy link
Copy Markdown
Contributor

Hey there @hanwg, mind taking a look at this pull request as it has been labeled with an integration (telegram_bot) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of telegram_bot can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign telegram_bot Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@aviadlevy
Copy link
Copy Markdown
Contributor Author

Hi @hanwg, this is the 2nd part continuing this.
I wanted to first get feedback over the new schema before starting to write the documentation - I wanted first to be sure about the naming conventions and the default values

@hanwg
Copy link
Copy Markdown
Contributor

hanwg commented Oct 17, 2025

I'm not sure but I think the /config/www/ folder serves content without authentication.

Perhaps a default could be /config/telegram_bot/?
Using the domain as folder name might make it easier to identify the integration that created the folder/files.

@hanwg
Copy link
Copy Markdown
Contributor

hanwg commented Oct 17, 2025

I know it's works in progress, but in case you missed it, I'm getting an error when running the telegram_bot.download_file action in developer tools:

File "/workspaces/core/homeassistant/components/telegram_bot/__init__.py", line 489, in async_send_telegram_message
    return await notify_service.download_file(context=service.context, **kwargs)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: TelegramNotificationService.download_file() got an unexpected keyword argument 'config_entry_id'

@luca-angemi
Copy link
Copy Markdown
Contributor

I'm not sure but I think the /config/www/ folder serves content without authentication.

Perhaps a default could be /config/telegram_bot/? Using the domain as folder name might make it easier to identify the integration that created the folder/files.

Other integrations that download media files (like camera shapshots and recordings) such as Reolink or Nest for example use their own folder in the media browser.

@aviadlevy aviadlevy marked this pull request as ready for review October 17, 2025 13:14
@frenck frenck requested a review from Copilot October 18, 2025 21:55
@aviadlevy aviadlevy marked this pull request as ready for review December 16, 2025 10:59
Comment thread tests/components/telegram_bot/test_telegram_bot.py Outdated
Comment thread tests/components/telegram_bot/test_telegram_bot.py Outdated
Comment thread homeassistant/components/telegram_bot/strings.json Outdated
Comment thread homeassistant/components/telegram_bot/__init__.py
@MartinHjelmare MartinHjelmare marked this pull request as draft December 16, 2025 22:23
@aviadlevy aviadlevy marked this pull request as ready for review December 17, 2025 07:22
Comment thread tests/components/telegram_bot/test_telegram_bot.py
@MartinHjelmare MartinHjelmare marked this pull request as draft December 17, 2025 20:23
@aviadlevy aviadlevy marked this pull request as ready for review December 17, 2025 20:47
Comment thread homeassistant/components/telegram_bot/bot.py
Comment thread homeassistant/components/telegram_bot/bot.py Outdated
Comment thread homeassistant/components/telegram_bot/bot.py
@MartinHjelmare MartinHjelmare marked this pull request as draft December 18, 2025 06:49
@aviadlevy aviadlevy marked this pull request as ready for review December 18, 2025 14:11
Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Thanks!

@MartinHjelmare MartinHjelmare merged commit 016d492 into home-assistant:dev Dec 22, 2025
36 checks passed
Comment thread homeassistant/components/telegram_bot/bot.py
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants