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

Refactor fibaro connect #106875

Merged
merged 6 commits into from
Apr 22, 2024
Merged

Conversation

rappenze
Copy link
Contributor

@rappenze rappenze commented Jan 2, 2024

Proposed change

Remove duplicate and dead code in fibaro connect methods.

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

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

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.

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.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@rappenze rappenze marked this pull request as ready for review January 2, 2024 15:54
Copy link
Contributor

@HipsterBrown HipsterBrown left a comment

Choose a reason for hiding this comment

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

Nice consolidation of code 👍

Copy link

github-actions bot commented Mar 3, 2024

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.
If you are the author of this PR, please leave a comment if you want to keep it open. Also, please rebase your PR onto the latest dev branch to ensure that it's up to date with the latest changes.
Thank you for your contribution!

@github-actions github-actions bot added the stale label Mar 3, 2024
@github-actions github-actions bot removed the stale label Mar 4, 2024
@frenck frenck added the smash Indicator this PR is close to finish for merging or closing label Mar 14, 2024
@emontnemery
Copy link
Contributor

Please fix the merge conflict, then hit the "Ready for review" button 👍

@emontnemery emontnemery marked this pull request as draft April 17, 2024 13:44
@rappenze rappenze marked this pull request as ready for review April 17, 2024 18:08
"""Start the communication with the Fibaro controller."""

connected = self._client.connect()
self._client.connect()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't we need to check the return value? pyfibaro.FibaroClient.connect returns a bool indicating if we could log in or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If credentials are provided, the connect() method always returns True or raises an HTTPError if the credentials are invalid. False is only returned if no credentials are provided. As the fibaro integration in Home Assistant always requires credentials and provide it in the Fibaro client, the return value is always True and therefore to check it makes no sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, that makes sense! Please add a short comment in the code explaining that's why we don't need to check the return value 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a comment.

connected = self.connect()
if not connected:
raise FibaroConnectFailed("Connect status is false")
self.connect()
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question

Copy link
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @rappenze 👍

@emontnemery emontnemery merged commit de75f82 into home-assistant:dev Apr 22, 2024
24 checks passed
@rappenze rappenze deleted the refactor_fibaro_connect branch April 22, 2024 17:39
tr4nt0r pushed a commit to tr4nt0r/ha-core that referenced this pull request Apr 23, 2024
* Refactor fibaro connect

* Remove obsolete test

* Add comment about ignored return value
@github-actions github-actions bot locked and limited conversation to collaborators Apr 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
by-code-owner cla-signed code-quality integration: fibaro Quality Scale: No score small-pr PRs with less than 30 lines. smash Indicator this PR is close to finish for merging or closing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants