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

Convert qbittorrent to config flow #45618

Closed

Conversation

geoffreylagaisse
Copy link
Contributor

@geoffreylagaisse geoffreylagaisse commented Jan 27, 2021

Proposed change

Upgrade the qbittorrent component to flow, and used the internal async processes of hass.

Fixes #48158

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

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

To help with the load of incoming pull requests:

geoffreylagaisse and others added 2 commits January 27, 2021 21:10
* update the qbittorrent api integration

* Added flow

* Added unittests

* Removed the state attribute as suggested

* Add Valid Credentials Test

* Update tests/components/qbittorrent/test_config_flow.py

Added the suggestions of ktnrg45

Co-authored-by: ktnrg45 <38207570+ktnrg45@users.noreply.github.com>

* typo's

* Fix Flake error

* Added flow

* Added unittests

* Removed the state attribute as suggested

* Add Valid Credentials Test

* Update tests/components/qbittorrent/test_config_flow.py

Added the suggestions of ktnrg45

Co-authored-by: ktnrg45 <38207570+ktnrg45@users.noreply.github.com>

* typo's

* Fix Flake error

* Added flow

* Added unittests

* Removed the state attribute as suggested

* Add Valid Credentials Test

* Update tests/components/qbittorrent/test_config_flow.py

Added the suggestions of ktnrg45

Co-authored-by: ktnrg45 <38207570+ktnrg45@users.noreply.github.com>

* typo's

* Fix Flake error

* Added flow

* Removed the state attribute as suggested

Co-authored-by: ktnrg45 <38207570+ktnrg45@users.noreply.github.com>
@project-bot project-bot bot added this to Needs review in Dev Jan 27, 2021
@project-bot project-bot bot moved this from Needs review to By Code Owner in Dev Jan 27, 2021
@cgarwood cgarwood changed the title Addqbittorentflow Convert qbittorrent to config flow Jan 27, 2021
@geoffreylagaisse geoffreylagaisse mentioned this pull request Jan 27, 2021
21 tasks
@geoffreylagaisse
Copy link
Contributor Author

sorry all for the inconvenience

@geoffreylagaisse geoffreylagaisse marked this pull request as ready for review January 27, 2021 21:18
homeassistant/components/qbittorrent/client.py Outdated Show resolved Hide resolved
homeassistant/components/qbittorrent/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/qbittorrent/translations/en.json Outdated Show resolved Hide resolved
.coveragerc Outdated Show resolved Hide resolved
Copy link
Contributor

@joncar joncar left a comment

Choose a reason for hiding this comment

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

Looking very good. Just a few cleanups I recommend.

homeassistant/components/qbittorrent/sensor.py Outdated Show resolved Hide resolved
Dev automation moved this from By Code Owner to Review in progress Feb 1, 2021
Copy link
Contributor

@joncar joncar left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@geoffreylagaisse
Copy link
Contributor Author

geoffreylagaisse commented Feb 17, 2021

fixed merge conflicts for when this branch gets merged into the upstream branch

@github-actions
Copy link

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@github-actions github-actions bot added the stale label Mar 20, 2021
@geoffreylagaisse
Copy link
Contributor Author

Should not be marked stale, still relevant.

@github-actions github-actions bot removed the stale label Mar 20, 2021
@geoffreylagaisse
Copy link
Contributor Author

geoffreylagaisse commented Aug 17, 2021

Merged recent qbittorrent changes in this branch, PR is now open since 7 months ...
Please does someone wants to review this ...

@geoffreylagaisse
Copy link
Contributor Author

@frenck or @MartinHjelmare Do you guys want to take a look at this PR, please?

@geoffreylagaisse
Copy link
Contributor Author

@cgarwood Maybe you want to take a look my PR?

@si458
Copy link
Contributor

si458 commented Nov 29, 2021

@MartinHjelmare please can you look at this,
its been open for months and it would fix the connection lost issues and replace the yaml with ui too

@frenck frenck self-requested a review November 29, 2021 15:10
Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

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

Hi there @geoffreylagaisse 👋

I've added some initial review comments to get the review process going / rolling.

I would recommend you to git rebase this PR onto the latest dev branch before continuing development on this PR.


async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the Qbittorrent component."""
hass.data.setdefault(DOMAIN, {})
Copy link
Member

Choose a reason for hiding this comment

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

This isn't used here, and should move to async_setup_entry

from .client import create_client
from .const import DATA_KEY_CLIENT, DATA_KEY_NAME, DOMAIN

PLATFORMS = ["sensor"]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
PLATFORMS = ["sensor"]
PLATFORMS = [Platform.SENSOR]

Comment on lines +58 to +59
_LOGGER.error("Connection failed")
raise ConfigEntryNotReady from err
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
_LOGGER.error("Connection failed")
raise ConfigEntryNotReady from err
raise ConfigEntryNotReady("Connection failed") from err


hass.data[DOMAIN][entry.data[CONF_URL]] = {
DATA_KEY_CLIENT: client,
DATA_KEY_NAME: name,
Copy link
Member

Choose a reason for hiding this comment

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

name seems to be a fixed value of "Qbittorrent", why would we need to add this to hass data?

Comment on lines +65 to +69
for platform in PLATFORMS:
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, platform)
)

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
for platform in PLATFORMS:
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, platform)
)
hass.config_entries.async_setup_platforms(entry, PLATFORMS)

return
if self._attr_available:
_LOGGER.error("Connection lost")
self._attr_available = False
except self._exception:
_LOGGER.error("Invalid authentication")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
_LOGGER.error("Invalid authentication")
_LOGGER.warning("Invalid authentication")

"config": {
"step": {
"user": {
"title": "qBitTorrent",
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't need to be translated.

Suggested change
"title": "qBitTorrent",


return self.async_abort(reason=errors["base"])

async def async_step_import_confirm(self, user_input=None):
Copy link
Member

Choose a reason for hiding this comment

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

Don't use a confirmation step; instead, just import that data and migrate the user.

Comment on lines +12 to +16
},
"import_confirm": {
"title": "Import qbittorret sensor",
"description": "A {id} sensor has been discovered in configuration.yaml. This flow will allow you to import it into a config entry."
}
Copy link
Member

Choose a reason for hiding this comment

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

This should not be needed and thus can be removed

Suggested change
},
"import_confirm": {
"title": "Import qbittorret sensor",
"description": "A {id} sensor has been discovered in configuration.yaml. This flow will allow you to import it into a config entry."
}
}

},
"abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
"config_cannot_be_imported": "Config from configuration.yaml can not be imported"
Copy link
Member

Choose a reason for hiding this comment

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

I cannot find usages of this key?

@frenck frenck added the config-flow This integration migrates to the UI by adding a config flow label Mar 24, 2022
@frenck
Copy link
Member

frenck commented Jun 23, 2022

This PR seems to have gone stale. Will go ahead and close it for now. Feel free to pick it up / re-open it when ready to work on it again. Thanks for willing to contribute 👍

../Frenck

@frenck frenck closed this Jun 23, 2022
Dev automation moved this from Review in progress to Cancelled Jun 23, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jun 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Dev
  
Cancelled
Development

Successfully merging this pull request may close these issues.

qBittorrent Does Not Refresh After Connection Failure
7 participants