-
-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
Refactor fibaro connect #106875
Conversation
There was a problem hiding this 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 👍
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. |
Please fix the merge conflict, then hit the "Ready for review" button 👍 |
"""Start the communication with the Fibaro controller.""" | ||
|
||
connected = self._client.connect() | ||
self._client.connect() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 👍
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @rappenze 👍
* Refactor fibaro connect * Remove obsolete test * Add comment about ignored return value
Proposed change
Remove duplicate and dead code in fibaro connect methods.
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: