Repository: home-assistant/core
File: homeassistant/components/lovelace/__init__.py (Python)

Code before:
    translations = await async_get_translations(
        hass, hass.config.language, "dashboard", {onboarding.DOMAIN}
    )
    title = translations.get(
        "component.onboarding.dashboard.overview.title", "Overview"
    )

    # Create dashboard entry
    try:
        await dashboards_collection.async_create_item(
            {
                CONF_ALLOW_SINGLE_WORD: True,
                CONF_ICON: DEFAULT_ICON,
                CONF_TITLE: title,
                CONF_URL_PATH: DOMAIN,
            }
        )
    except (HomeAssistantError, vol.Invalid):
        _LOGGER.exception("Failed to create dashboard entry during migration")
        return

    # Save data to new location
    await new_store.async_save(old_data)

    # Remove old file
    await old_store.async_remove()

    _LOGGER.info("Successfully migrated default lovelace config to dashboard entry")

    # Set default panel to lovelace if not already configured
    system_store = await frontend.async_system_store(hass)
    if system_store.data.get("default_panel") is None:
        await system_store.async_set_item("default_panel", DOMAIN)
        _LOGGER.info("Set default panel to 'lovelace' during migration")


# Deprecated - Remove in 2026.8
@callback
def _async_create_yaml_mode_repair(hass: HomeAssistant) -> None:
    """Create repair issue for YAML mode migration."""
    ir.async_create_issue(
        hass,
        DOMAIN,
        "yaml_mode_deprecated",
        breaks_in_ha_version="2026.8.0",
        is_fixable=False,
        severity=ir.IssueSeverity.WARNING,
        translation_key="yaml_mode_deprecated",
        translation_placeholders={"config_file": LOVELACE_CONFIG_FILE},
    )


Review comment (suggestion):
```suggestion
    await new_store.async_save(old_data)
    await old_store.async_remove()
```
nit: some of these comments are very very redundant and make the code longer to read :smile: 

Code after:
            }
        )
    except (HomeAssistantError, vol.Invalid):
        _LOGGER.exception("Failed to create dashboard entry during migration")
        return

    # 4. Handle storage files
    new_store = Store[dict[str, Any]](
        hass,
        dashboard.CONFIG_STORAGE_VERSION,
        dashboard.CONFIG_STORAGE_KEY.format(DOMAIN),
    )
    if await new_store.async_load() is None:
        await new_store.async_save(old_data)
        await old_store.async_remove()
    else:
        # This should not happen because "lovelace" was a forbidden dashboard
        # url_path before this migration existed. Rename old file as backup
        # to avoid data loss just in case.
        with suppress(FileNotFoundError):
            await hass.async_add_executor_job(
                os.rename,
                old_store.path,
                old_store.path + "_old",
            )

    _LOGGER.info("Successfully migrated default lovelace config to dashboard entry")

    # 5. Set default panel to lovelace if not already configured
    system_store = await frontend.async_system_store(hass)
    core_data = system_store.data.get("core")
    if core_data is None or core_data.get("default_panel") is None:
        await system_store.async_set_item(
            "core", {**(core_data or {}), "default_panel": DOMAIN}
        )
        _LOGGER.info("Set default panel to 'lovelace' during migration")


# Deprecated - Remove in 2026.8
@callback
def _async_create_yaml_mode_repair(hass: HomeAssistant) -> None:
    """Create repair issue for YAML mode migration."""
    ir.async_create_issue(
        hass,
        DOMAIN,
        "yaml_mode_deprecated",
        breaks_in_ha_version="2026.8.0",
        is_fixable=False,
        severity=ir.IssueSeverity.WARNING,
        translation_key="yaml_mode_deprecated",
        translation_placeholders={"config_file": LOVELACE_CONFIG_FILE},