diff --git a/homeassistant/components/zwave_js/config_flow.py b/homeassistant/components/zwave_js/config_flow.py index eefb673f1c7..2d9bc0fa1cd 100644 --- a/homeassistant/components/zwave_js/config_flow.py +++ b/homeassistant/components/zwave_js/config_flow.py @@ -1133,7 +1133,15 @@ class ZWaveJSConfigFlow(ConfigFlow, domain=DOMAIN): self, user_input: dict[str, Any] | None = None ) -> ConfigFlowResult: """Restore failed.""" - return self.async_abort(reason="restore_failed") + if user_input is not None: + return await self.async_step_restore_nvm() + + return self.async_show_form( + step_id="restore_failed", + description_placeholders={ + "file_path": str(self.backup_filepath), + }, + ) async def async_step_migration_done( self, user_input: dict[str, Any] | None = None diff --git a/homeassistant/components/zwave_js/strings.json b/homeassistant/components/zwave_js/strings.json index 9c704e675a3..53615e84691 100644 --- a/homeassistant/components/zwave_js/strings.json +++ b/homeassistant/components/zwave_js/strings.json @@ -21,7 +21,6 @@ "not_zwave_js_addon": "Discovered add-on is not the official Z-Wave add-on.", "reconfigure_successful": "[%key:common::config_flow::abort::reconfigure_successful%]", "reset_failed": "Failed to reset controller.", - "restore_failed": "Failed to restore network.", "usb_ports_failed": "Failed to get USB devices." }, "error": { @@ -118,6 +117,11 @@ "title": "Unplug your old controller", "description": "Backup saved to \"{file_path}\"\n\nYour old controller has been reset. If the hardware is no longer needed, you can now unplug it.\n\nPlease make sure your new controller is plugged in before continuing." }, + "restore_failed": { + "title": "Restoring unsuccessful", + "description": "Your Z-Wave network could not be restored to the new controller. This means that your Z-Wave devices are not connected to Home Assistant.\n\nThe backup is saved to ”{file_path}”", + "submit": "Try again" + }, "choose_serial_port": { "data": { "usb_path": "[%key:common::config_flow::data::usb_path%]" diff --git a/tests/components/zwave_js/test_config_flow.py b/tests/components/zwave_js/test_config_flow.py index a4c80fb4df9..8256e10e697 100644 --- a/tests/components/zwave_js/test_config_flow.py +++ b/tests/components/zwave_js/test_config_flow.py @@ -3914,8 +3914,27 @@ async def test_reconfigure_migrate_restore_failure( result = await hass.config_entries.flow.async_configure(result["flow_id"]) - assert result["type"] == FlowResultType.ABORT - assert result["reason"] == "restore_failed" + assert result["type"] == FlowResultType.FORM + assert result["step_id"] == "restore_failed" + assert result["description_placeholders"]["file_path"] + + result = await hass.config_entries.flow.async_configure(result["flow_id"], {}) + + assert result["type"] == FlowResultType.SHOW_PROGRESS + assert result["step_id"] == "restore_nvm" + + await hass.async_block_till_done() + + assert client.driver.controller.async_restore_nvm.call_count == 2 + + result = await hass.config_entries.flow.async_configure(result["flow_id"]) + + assert result["type"] == FlowResultType.FORM + assert result["step_id"] == "restore_failed" + + hass.config_entries.flow.async_abort(result["flow_id"]) + + assert len(hass.config_entries.flow.async_progress()) == 0 async def test_get_driver_failure(hass: HomeAssistant, integration, client) -> None: