Skip to content

Add timeout attribute for send files#31379

Merged
springstan merged 4 commits into
home-assistant:devfrom
Konsts:add-telegram-timeout-parametr
Feb 3, 2020
Merged

Add timeout attribute for send files#31379
springstan merged 4 commits into
home-assistant:devfrom
Konsts:add-telegram-timeout-parametr

Conversation

@Konsts
Copy link
Copy Markdown
Contributor

@Konsts Konsts commented Feb 1, 2020

Breaking change

Proposed change

Add timeout param to telegram_bot.send_file(send_video, send_photo, send_sticker, send_document) that help fixed issue with timeout error (with a large file size, poor internet connection, etc.)

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)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

# Example configuration.yaml
service: telegram_bot.send_video
      data_template:
        target:
         - !secret chatId
        file: "/config/video_captures/snapshotDoor.mp4"
        caption: "someone opened the door!"
        timeout: 1000

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
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

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

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

@homeassistant
Copy link
Copy Markdown
Contributor

Hi @Konsts,

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!

Comment thread homeassistant/components/telegram_bot/__init__.py Outdated
Remove attribute dublicate in BASE_SERVICE_SCHEMA
return attribute to BASE_SERVICE_SCHEMA and remove from SERVICE_SCHEMA_SEND_FILE
@springstan
Copy link
Copy Markdown
Member

Please add the timeout variable to send_message and send_location in services.yaml as well :)

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 2, 2020

Codecov Report

Merging #31379 into dev will increase coverage by 0.22%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev   #31379      +/-   ##
==========================================
+ Coverage   94.41%   94.63%   +0.22%     
==========================================
  Files         740      749       +9     
  Lines       53654    54185     +531     
==========================================
+ Hits        50655    51276     +621     
+ Misses       2999     2909      -90     
Impacted Files Coverage Δ
homeassistant/components/updater/binary_sensor.py 92.10% <0.00%> (-7.90%) ⬇️
homeassistant/components/unifi/config_flow.py 95.60% <0.00%> (-4.40%) ⬇️
homeassistant/components/unifi/controller.py 94.91% <0.00%> (-3.92%) ⬇️
homeassistant/components/hue/sensor.py 90.32% <0.00%> (-3.02%) ⬇️
homeassistant/components/unifi/switch.py 92.92% <0.00%> (-2.61%) ⬇️
script/__init__.py 96.55% <0.00%> (-1.55%) ⬇️
...meassistant/components/google_assistant/helpers.py 93.80% <0.00%> (-0.72%) ⬇️
homeassistant/components/deconz/sensor.py 96.12% <0.00%> (-0.71%) ⬇️
homeassistant/components/tplink/light.py 95.97% <0.00%> (-0.58%) ⬇️
homeassistant/components/alexa/handlers.py 94.51% <0.00%> (-0.52%) ⬇️
... and 85 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 03954be...5a6b261. Read the comment docs.

Add timeout parameter description for "send message" and "send location"
vol.Optional(ATTR_KEYBOARD): vol.All(cv.ensure_list, [cv.string]),
vol.Optional(ATTR_KEYBOARD_INLINE): cv.ensure_list,
vol.Optional(CONF_TIMEOUT): vol.Coerce(float),
vol.Optional(ATTR_TIMEOUT): cv.positive_int,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@MartinHjelmare does changing the expected data type of a service count as a breaking change?

Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare Feb 3, 2020

Choose a reason for hiding this comment

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

It could, but here I think we're backwards compatible. We're limiting it to positive numbers though. But a negative timeout sounds weird so I think that's ok.

@MartinHjelmare
Copy link
Copy Markdown
Member

So nothing really changed here except the service description additions?

@springstan
Copy link
Copy Markdown
Member

So nothing really changed here except the service description additions?

Not entirely, since the timeout param was added to all telegram_bot.send_file(send_video, send_photo, send_sticker, send_document) services.

@MartinHjelmare
Copy link
Copy Markdown
Member

I don't see that change. Where is it?

@springstan
Copy link
Copy Markdown
Member

Oh yeah you are right, it was only replaced. So yes you could say that only the service descriptions were added.

@springstan springstan merged commit 114d48e into home-assistant:dev Feb 3, 2020
@Konsts Konsts deleted the add-telegram-timeout-parametr branch February 3, 2020 20:29
@lock lock Bot locked and limited conversation to collaborators Feb 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telegram bot: timeouts when sending video files >10mb

4 participants