Skip to content
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

Add host field to add_torrent service #28653

Merged
merged 4 commits into from Nov 26, 2019

Conversation

@engrbm87
Copy link
Contributor

engrbm87 commented Nov 9, 2019

Breaking Change:

In order to support multiple Transmission instances the add_torrent service requires two parameters now:

  • Name: The name of the entry specified during setup
  • Torrent: The torrent url (or file) to download

Description:

This is a follow up PR to #28136. It adds the following:

  • Specify name in add_torrent service to handle multiple configured instances using same service name.
  • make the entity unsubscribe from update dispatcher when disabled.
  • cleanup stale code from PR #28136

Pull request with documentation for home-assistant.io (if applicable): home-assistant/home-assistant.io#11291

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist

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. Update and include derived files by running python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.
@probot-home-assistant

This comment has been minimized.

Copy link

probot-home-assistant bot commented Nov 9, 2019

Hey there @JPHutchins, mind taking a look at this pull request as its been labeled with a integration (transmission) you are listed as a codeowner for? Thanks!

@project-bot project-bot bot moved this from Needs review to By Code Owner in Dev Nov 9, 2019

self.hass.services.async_register(
DOMAIN, self.service_name, add_torrent, schema=SERVICE_ADD_TORRENT_SCHEMA

This comment has been minimized.

Copy link
@balloob

balloob Nov 25, 2019

Member

why are we doing this breaking change ? And is specifying host easier than specifying name in the service data ?

This comment has been minimized.

Copy link
@engrbm87

engrbm87 Nov 26, 2019

Author Contributor

Hi @balloob , the reason for this change is because previously I wrote the code to create a separate service for each new transmission entry. This doesn't work well with services.yaml as it won't show the example data if the service name is different from the default add_torrent.
Initially i proposed PR #28177 to support dynamic service names. But it was suggested to keep it as one service and add another parameter to specify which entry should be used.
We can use either host or name as both should be unique for each entry. Which do you receommend

This comment has been minimized.

Copy link
@balloob

balloob Nov 26, 2019

Member

Well, I would expect name to be easier to remember.

async def will_remove_from_hass(self):
"""Unsubscribe from update dispatcher."""
if self.unsub_update:
self.unsub_update()

This comment has been minimized.

Copy link
@balloob

balloob Nov 25, 2019

Member

Also set to None ?

This comment has been minimized.

Copy link
@engrbm87

engrbm87 Nov 26, 2019

Author Contributor

If that is required i will update it.

@balloob

This comment has been minimized.

Copy link
Member

balloob commented Nov 26, 2019

Don't forget to fill in the breaking change paragraph in your PR description.

@engrbm87 engrbm87 mentioned this pull request Nov 26, 2019
2 of 2 tasks complete
tm_client = self.hass.data[DOMAIN][entry.entry_id]
break
if tm_client is None:
_LOGGER.error("Transmission instance is not found")

This comment has been minimized.

Copy link
@balloob

balloob Nov 26, 2019

Member

Add a return if it's None so that you can drop the else:.

Copy link
Member

balloob left a comment

Great! Ok to merge when last comment addressed.

Do you need to update servics.yaml too ?

Dev automation moved this from By Code Owner to Reviewer approved Nov 26, 2019
@balloob

This comment has been minimized.

Copy link
Member

balloob commented Nov 26, 2019

Please update services.yaml too.

@engrbm87

This comment has been minimized.

Copy link
Contributor Author

engrbm87 commented Nov 26, 2019

Please update services.yaml too.

Already done.

@balloob balloob merged commit a596083 into home-assistant:dev Nov 26, 2019
11 checks passed
11 checks passed
CI #20191126.17 succeeded
Details
CI (FullCheck Mypy) FullCheck Mypy succeeded
Details
CI (FullCheck Pylint) FullCheck Pylint succeeded
Details
CI (Overview CheckFormat) Overview CheckFormat succeeded
Details
CI (Overview Lint) Overview Lint succeeded
Details
CI (Overview Validate) Overview Validate succeeded
Details
CI (Tests PyTest Python36) Tests PyTest Python36 succeeded
Details
CI (Tests PyTest Python37) Tests PyTest Python37 succeeded
Details
cla-bot Everyone involved has signed the CLA
codecov/patch No report found to compare against
Details
codecov/project 94.49% (target 90%)
Details
Dev automation moved this from Reviewer approved to Done Nov 26, 2019
@lock lock bot locked and limited conversation to collaborators Nov 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Dev
  
Done
3 participants
You can’t perform that action at this time.