Skip to content

Commit 60f4d29

Browse files
MartinHjelmarefrenck
authored andcommitted
Add Z-Wave USB migration confirm step (home-assistant#149243)
1 parent 68b7d09 commit 60f4d29

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

homeassistant/components/zwave_js/config_flow.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,10 +495,23 @@ async def async_step_usb(self, discovery_info: UsbServiceInfo) -> ConfigFlowResu
495495

496496
self._usb_discovery = True
497497
if current_config_entries:
498-
return await self.async_step_intent_migrate()
498+
return await self.async_step_confirm_usb_migration()
499499

500500
return await self.async_step_installation_type()
501501

502+
async def async_step_confirm_usb_migration(
503+
self, user_input: dict[str, Any] | None = None
504+
) -> ConfigFlowResult:
505+
"""Confirm USB migration."""
506+
if user_input is not None:
507+
return await self.async_step_intent_migrate()
508+
return self.async_show_form(
509+
step_id="confirm_usb_migration",
510+
description_placeholders={
511+
"usb_title": self.context["title_placeholders"][CONF_NAME],
512+
},
513+
)
514+
502515
async def async_step_manual(
503516
self, user_input: dict[str, Any] | None = None
504517
) -> ConfigFlowResult:

homeassistant/components/zwave_js/strings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@
108108
"start_addon": {
109109
"title": "Configuring add-on"
110110
},
111+
"confirm_usb_migration": {
112+
"description": "You are about to migrate your Z-Wave network from the old adapter to the new adapter {usb_title}. This will take a backup of the network from the old adapter and restore the network to the new adapter.\n\nPress Submit to continue with the migration.",
113+
"title": "Migrate to a new adapter"
114+
},
111115
"zeroconf_confirm": {
112116
"description": "Do you want to add the Z-Wave Server with home ID {home_id} found at {url} to Home Assistant?",
113117
"title": "Discovered Z-Wave Server"

tests/components/zwave_js/test_config_flow.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,11 @@ async def mock_restore_nvm(data: bytes, options: dict[str, bool] | None = None):
932932

933933
assert mock_usb_serial_by_id.call_count == 2
934934

935+
assert result["type"] is FlowResultType.FORM
936+
assert result["step_id"] == "confirm_usb_migration"
937+
938+
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
939+
935940
assert result["type"] is FlowResultType.SHOW_PROGRESS
936941
assert result["step_id"] == "backup_nvm"
937942

@@ -1049,6 +1054,11 @@ async def mock_restore_nvm(data: bytes, options: dict[str, bool] | None = None):
10491054

10501055
assert mock_usb_serial_by_id.call_count == 2
10511056

1057+
assert result["type"] is FlowResultType.FORM
1058+
assert result["step_id"] == "confirm_usb_migration"
1059+
1060+
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
1061+
10521062
assert result["type"] is FlowResultType.SHOW_PROGRESS
10531063
assert result["step_id"] == "backup_nvm"
10541064

0 commit comments

Comments
 (0)