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

Code before:
            _LOGGER.warning("Failed to %s panel %s from storage", change_type, url_path)

    # Process YAML dashboards
    for url_path, dashboard_conf in hass.data[LOVELACE_DATA].yaml_dashboards.items():
        # For now always mode=yaml
        lovelace_config = dashboard.LovelaceYAML(hass, url_path, dashboard_conf)
        hass.data[LOVELACE_DATA].dashboards[url_path] = lovelace_config

        try:
            _register_panel(hass, url_path, MODE_YAML, dashboard_conf, False)
        except ValueError:
            _LOGGER.warning("Panel url path %s is not unique", url_path)

    # Process storage dashboards
    dashboards_collection = dashboard.DashboardsCollection(hass)

    dashboards_collection.async_add_listener(storage_dashboard_changed)
    await dashboards_collection.async_load()

    # Migrate default lovelace panel to dashboard entry (storage mode only)
    if mode == MODE_STORAGE:
        await _async_migrate_default_config(hass, dashboards_collection)
    # Register default lovelace panel if no panel exists yet
    # (new installation without YAML mode and no migrated dashboard)

    if (
        frontend.DATA_PANELS not in hass.data
        or DOMAIN not in hass.data[frontend.DATA_PANELS]
    ):
        frontend.async_register_built_in_panel(
            hass,
            DOMAIN,
            config={"mode": MODE_STORAGE},
        )

    dashboard.DashboardsCollectionWebSocket(
        dashboards_collection,
        "lovelace/dashboards",
        "dashboard",
        STORAGE_DASHBOARD_CREATE_FIELDS,
        STORAGE_DASHBOARD_UPDATE_FIELDS,
    ).async_setup(hass)

    def create_map_dashboard() -> None:
        """Create a map dashboard."""
        hass.async_create_task(_create_map_dashboard(hass, dashboards_collection))

    if not onboarding.async_is_onboarded(hass):
        onboarding.async_add_listener(hass, create_map_dashboard)

    return True

Review comment (suggestion):
```suggestion

    # Register default lovelace panel if no panel exists yet
    # (new installation without YAML mode and no migrated dashboard)
    if (
```

Code after:
    for url_path, dashboard_conf in hass.data[LOVELACE_DATA].yaml_dashboards.items():
        # For now always mode=yaml
        lovelace_config = dashboard.LovelaceYAML(hass, url_path, dashboard_conf)
        hass.data[LOVELACE_DATA].dashboards[url_path] = lovelace_config

        try:
            _register_panel(hass, url_path, MODE_YAML, dashboard_conf, False)
        except ValueError:
            _LOGGER.warning("Panel url path %s is not unique", url_path)

    # Process storage dashboards
    dashboards_collection = dashboard.DashboardsCollection(hass)

    dashboards_collection.async_add_listener(storage_dashboard_changed)
    await dashboards_collection.async_load()

    # Migrate default lovelace panel to dashboard entry (storage mode only)
    if mode == MODE_STORAGE:
        await _async_migrate_default_config(hass, dashboards_collection)

    # Ensure lovelace panel is always registered for backwards compatibility
    _async_ensure_default_panel(hass)

    dashboard.DashboardsCollectionWebSocket(
        dashboards_collection,
        "lovelace/dashboards",
        "dashboard",
        STORAGE_DASHBOARD_CREATE_FIELDS,
        STORAGE_DASHBOARD_UPDATE_FIELDS,
    ).async_setup(hass)

    def create_map_dashboard() -> None:
        """Create a map dashboard."""
        hass.async_create_task(_create_map_dashboard(hass, dashboards_collection))

    if not onboarding.async_is_onboarded(hass):
        onboarding.async_add_listener(hass, create_map_dashboard)

    return True


async def create_yaml_resource_col(
    hass: HomeAssistant, yaml_resources: list[ConfigType] | None
) -> resources.ResourceYAMLCollection:
    """Create yaml resources collection."""
    if yaml_resources is None:
        default_config = dashboard.LovelaceYAML(hass, None, None)
        try:
            ll_conf = await default_config.async_load(False)
        except HomeAssistantError:
            pass