-
-
Notifications
You must be signed in to change notification settings - Fork 37.1k
Add migration to migrate 'homewizard_energy' to 'homewizard' #65594
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,21 @@ def __init__(self) -> None: | |
| """Initialize the HomeWizard config flow.""" | ||
| self.config: dict[str, str | int] = {} | ||
|
|
||
| async def async_step_import(self, import_config: dict) -> FlowResult: | ||
| """Handle a flow initiated by older `homewizard_energy` component.""" | ||
| _LOGGER.debug("config_flow async_step_import") | ||
|
|
||
| self.hass.components.persistent_notification.async_create( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we make this a persistent notification or a log? We general log these
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also fine! Just took over the same behaviour from this migration: #59698
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think a persistent notification is better, easy to miss a log.
MartinHjelmare marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ( | ||
| "The custom integration of HomeWizard Energy has been migrated to core. " | ||
| "You can safely remove the custom integration from the custom_integrations folder." | ||
| ), | ||
| "HomeWizard Energy", | ||
| f"homewizard_energy_to_{DOMAIN}", | ||
| ) | ||
|
|
||
| return await self.async_step_user({CONF_IP_ADDRESS: import_config["host"]}) | ||
|
|
||
| async def async_step_user( | ||
| self, user_input: dict[str, Any] | None = None | ||
| ) -> FlowResult: | ||
|
|
@@ -59,12 +74,17 @@ async def async_step_user( | |
| } | ||
| ) | ||
|
|
||
| data: dict[str, str] = {CONF_IP_ADDRESS: user_input[CONF_IP_ADDRESS]} | ||
|
|
||
| if self.source == config_entries.SOURCE_IMPORT: | ||
| old_config_entry_id = self.context["old_config_entry_id"] | ||
| assert self.hass.config_entries.async_get_entry(old_config_entry_id) | ||
| data["old_config_entry_id"] = old_config_entry_id | ||
|
|
||
| # Add entry | ||
| return self.async_create_entry( | ||
| title=f"{device_info[CONF_PRODUCT_NAME]} ({device_info[CONF_SERIAL]})", | ||
| data={ | ||
| CONF_IP_ADDRESS: user_input[CONF_IP_ADDRESS], | ||
| }, | ||
| data=data, | ||
| ) | ||
|
|
||
| async def async_step_zeroconf( | ||
|
|
||
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 triggers this import step? I'm not seeing it?
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 custom integration when it is updated, see https://github.com/DCSBL/ha-homewizard-energy/blob/2067090f20ce74a9f8c133e3dcccd40a79ca524d/custom_components/homewizard_energy/__init__.py
DCSBL/ha-homewizard-energy#79