-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
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 Config Flow to Obihai #88627
Add Config Flow to Obihai #88627
Conversation
Hey there @dshokouhi, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
This great! Please also consider adding yourself to the codeowners for this integration as I have not done any updates to this in a very long time 😬 |
Ugh, bit by pre-commit. Running it offline now, another commit coming momentarily... |
c3f2619
to
1c92605
Compare
I don't know what the heck is going on. These tests are passing for me offline. |
@dshokouhi, looks like I got the pre-commit working. Added myself as code owner. Let me know if you think anything else needs done! |
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.
Please split into smaller pr
- one for code owners
- one for reboot service
- one for ConfigFlow (without dhcp)
- one follow up for dhcp
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
eb6f859
to
0620082
Compare
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.
Also please ensure that you have 100% test coverage on config flow.
@epenet, I believe I have resolved (or otherwise addressed) all your concerns. When this gets submitted I'll submit a few other PRs. The other config_flow changes might take a bit since they don't have tests... Let me know if it's looking good. |
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
8763c3f
to
5e72f24
Compare
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
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 👍
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.
Please address the comments in a new PR. Thanks!
async def async_step_import(self, config: dict[str, Any]) -> FlowResult: | ||
"""Handle a flow initialized by importing a config.""" | ||
self._async_abort_entries_match({CONF_HOST: config[CONF_HOST]}) | ||
return self.async_create_entry( |
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.
We should test the connection to the device with the config before creating the config entry, as we do in the user step. Abort if it doesn't work.
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.
Would you have objections to just using LOGGER to drop a warning in system log if YAML import failed? I suppose we could create an "issue", but that seems overkill IMHO.
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.
Strike that, I'm just going to use async_abort and hand it cannot_connect.
"manual_migration", | ||
breaks_in_ha_version="2023.6.0", | ||
is_fixable=False, | ||
severity=issue_registry.IssueSeverity.ERROR, |
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.
Please use warning severity.
@@ -148,6 +157,10 @@ def icon(self): | |||
|
|||
def update(self) -> None: | |||
"""Update the sensor.""" | |||
if not self._pyobihai.check_account(): |
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.
What does False
mean here? If we can't connect we should set the available
property to False
in the entity. If credentials are bad we should start a reauth flow.
https://developers.home-assistant.io/docs/config_entries_config_flow_handler#reauthentication
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.
The available
property will return False
if self._state is None
which is what we've done here. I'll take a look at the re-auth feedback, though I think that should be a PR in-and-of-itself as it would require new classes and tests.
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.
Setting the native value to None
means that the state is unknown. This is different than state unavailable. It would be better not to couple these things to avoid confusion when reading the code.
}, | ||
"issues": { | ||
"manual_migration": { | ||
"title": "Manual migration required for Obihai", |
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.
What manual migration is required?
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.
Can you be more specific about what's confusing here? This is C+P from other components that require migration from YAML. This is just a title. The description is... more descriptive of the process. Would you like the title to describe how to migrate?
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.
The title is incorrect. There is no manual migration required (it has already migrated). It should state the YAML configuration is deprecated and should be removed.
Breaking change
N/A
Proposed change
Adds config_flow to the Obihai integration, deprecates YAML configuration.
Type of change
Additional information
Checklist
black --fast 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: