-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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 Smarty #127540
base: dev
Are you sure you want to change the base?
Add config flow to Smarty #127540
Conversation
Hey there @z0mbieprocess, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com>
Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com>
@marcodutto can you maybe test this PR? |
async def async_unload_entry(hass: HomeAssistant, entry: SmartyConfigEntry) -> bool: | ||
"""Unload a config entry.""" | ||
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) |
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 think you forget to cancel the periodic call to poll_device_update
. Do we need to do anything else to shut down the client?
self, import_config: dict[str, Any] | ||
) -> ConfigFlowResult: | ||
"""Handle a flow initialized by import.""" | ||
self._async_abort_entries_match({CONF_HOST: import_config[CONF_HOST]}) |
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.
Is this check needed, an import flow is only started if there are no existing config entries?
return self.async_create_entry( | ||
title=user_input[CONF_HOST], data=user_input | ||
) |
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.
Does the API not provide any source for a unique ID?
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.
Nope, it's just a modbus device
try: | ||
if smarty.update(): | ||
return None | ||
except Exception: # noqa: BLE001 |
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.
Is there nothing more narrow to catch?
Also, I think we should log here.
"issues": { | ||
"deprecated_yaml_import_issue_unknown": { | ||
"title": "YAML import failed with unknown error", | ||
"description": "Configuring {integration_title} using YAML is being removed but there was an unknown error while importing your existing configuration.\nSetup will not proceed.\n\nVerify that your {integration_title} is operating correctly and restart Home Assistant to attempt the import again.\n\nAlternatively, you may remove the `{domain}` configuration from your configuration.yaml entirely, restart Home Assistant, and add the {integration_title} integration manually." |
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.
There doesn't seem to be anything specific for the Smarty integration here. Please use the translations from the homeassistant
integration instead.
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.
But this is the translation where we explain that we could not import it
|
||
|
||
async def setup_integration(hass: HomeAssistant, config_entry: MockConfigEntry) -> None: | ||
"""Fixture for setting up the component.""" |
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.
This is not a fixture
|
||
@pytest.fixture | ||
def mock_setup_entry() -> Generator[AsyncMock]: | ||
"""Override async_setup_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.
Please improve the docstring
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
As discussed on Discord, this PR either needs to have test coverage of modified code, or be tested with Smarty devices (doing both would of course be the best option). |
I'm on a business trip right now, I'll be testing this in two days with my Smarty device. |
Breaking change
Configuring Smarty via YAML is deprecated, your configuration has been imported. Please configure Smarty via the UI.
Proposed change
Add config flow to Smarty
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
.To help with the load of incoming pull requests: