{"record":{"id":"472e2b075636e10a","repo":"home-assistant/core","slug":"err-472e2b","errorCode":null,"errorMessage":"{err}","messagePattern":"\\{err\\}","errorType":"exception","errorClass":"ConfigEntryNotReady","httpStatus":null,"severity":"error","filePath":"homeassistant/components/aemet/__init__.py","lineNumber":44,"sourceCode":"    latitude = entry.data[CONF_LATITUDE]\n    longitude = entry.data[CONF_LONGITUDE]\n    update_features: int = UpdateFeature.FORECAST\n    if entry.options.get(CONF_RADAR_UPDATES, False):\n        update_features |= UpdateFeature.RADAR\n    if entry.options.get(CONF_STATION_UPDATES, True):\n        update_features |= UpdateFeature.STATION\n\n    options = ConnectionOptions(api_key, update_features)\n    aemet = AEMET(aiohttp_client.async_get_clientsession(hass), options)\n    aemet.set_api_data_dir(hass.config.path(STORAGE_DIR, f\"{DOMAIN}-{entry.unique_id}\"))\n\n    try:\n        await aemet.select_coordinates(latitude, longitude)\n    except TownNotFound as err:\n        _LOGGER.error(err)\n        return False\n    except AemetError as err:\n        raise ConfigEntryNotReady(err) from err\n\n    weather_coordinator = WeatherUpdateCoordinator(hass, entry, aemet)\n    await weather_coordinator.async_config_entry_first_refresh()\n\n    entry.runtime_data = AemetData(name=name, coordinator=weather_coordinator)\n\n    await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)\n\n    entry.async_on_unload(entry.add_update_listener(async_update_options))\n\n    return True\n\n\nasync def async_update_options(hass: HomeAssistant, entry: ConfigEntry) -> None:\n    \"\"\"Update options.\"\"\"\n    await hass.config_entries.async_reload(entry.entry_id)\n\n","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/aemet/__init__.py#L26-L62","documentation":"ConfigEntryNotReady raised during aemet async_setup_entry when aemet.select_coordinates(latitude, longitude) fails with AemetError — meaning the AEMET Open Data library could not resolve the configured coordinates to a station or fetch station data. ConfigEntryNotReady makes Home Assistant retry setup with a backoff instead of failing permanently. (TownNotFound is handled separately: it logs and returns False, failing setup outright.)","triggerScenarios":"Setting up or reloading the AEMET integration entry when the AEMET Open Data API is unreachable, returns errors, rate-limits the API key, or the library cannot complete station selection for the given lat/long.","commonSituations":"AEMET Open Data outage or maintenance window, expired/invalid API key (API keys must be requested from AEMET and renew periodically), network egress restrictions, or transient HTTP failures during first setup.","solutions":["Wait — ConfigEntryNotReady retries automatically; if the AEMET outage is transient, the entry will come up on its own.","Validate the AEMET API key by calling the AEMET Open Data endpoint directly with it (401/403 means the key expired — request a new one from opendata.aemet.es).","Check Home Assistant's outbound access to opendata.aemet.es (proxy, DNS, firewall).","If TownNotFound was logged instead, re-run the config flow and pick valid coordinates/municipality within Spain (AEMET only covers Spain).","Reload the integration entry once the underlying cause is fixed."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"async def aemet_api_key_valid(session, api_key: str) -> bool:\n    \"\"\"Probe the AEMET Open Data API with the configured key.\"\"\"\n    async with session.get(\n        \"https://opendata.aemet.es/opendata/api/maestro/estaciones\",\n        headers={\"api_key\": api_key},\n    ) as resp:\n        return resp.status == 200","typeGuard":null,"tryCatchPattern":"from homeassistant.exceptions import ConfigEntryNotReady\n\ntry:\n    await async_setup_entry(hass, entry)\nexcept ConfigEntryNotReady as err:\n    # HA retries setup with backoff; investigate AemetError cause in logs\n    _LOGGER.warning(\"AEMET setup deferred: %s\", err)","preventionTips":["Renew AEMET Open Data API keys proactively — they expire.","Verify coordinates are within Spain; TownNotFound fails setup without retry.","Do not hammer the API from multiple clients with one key during initial setup."],"tags":["homeassistant","aemet","config-entry-not-ready","api-error","weather"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}