{"record":{"id":"2f129d60be1072d1","repo":"home-assistant/core","slug":"ai-task-entity-entity-id-not-found","errorCode":null,"errorMessage":"AI Task entity {entity_id} not found","messagePattern":"AI Task entity (.+?) not found","errorType":"exception","errorClass":"HomeAssistantError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/ai_task/task.py","lineNumber":132,"sourceCode":"    hass: HomeAssistant,\n    *,\n    task_name: str,\n    entity_id: str | None = None,\n    instructions: str,\n    structure: vol.Schema | None = None,\n    attachments: list[dict] | None = None,\n    llm_api: llm.API | None = None,\n) -> GenDataTaskResult:\n    \"\"\"Run a data generation task in the AI Task integration.\"\"\"\n    if entity_id is None:\n        entity_id = hass.data[DATA_PREFERENCES].gen_data_entity_id\n\n    if entity_id is None:\n        raise HomeAssistantError(\"No entity_id provided and no preferred entity set\")\n\n    entity = hass.data[DATA_COMPONENT].get_entity(entity_id)\n    if entity is None:\n        raise HomeAssistantError(f\"AI Task entity {entity_id} not found\")\n\n    if AITaskEntityFeature.GENERATE_DATA not in entity.supported_features:\n        raise HomeAssistantError(\n            f\"AI Task entity {entity_id} does not support generating data\"\n        )\n\n    if (\n        attachments\n        and AITaskEntityFeature.SUPPORT_ATTACHMENTS not in entity.supported_features\n    ):\n        raise HomeAssistantError(\n            f\"AI Task entity {entity_id} does not support attachments\"\n        )\n\n    with async_get_chat_session(hass) as session:\n        resolved_attachments = await _resolve_attachments(hass, session, attachments)\n\n        return await entity.internal_async_generate_data(","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/ai_task/task.py#L114-L150","documentation":"HomeAssistantError from ai_task.async_generate_data when hass.data[DATA_COMPONENT].get_entity(entity_id) returns None — the requested (or preferred) entity id does not match any entity registered by the AI Task component's entity platform. The lookup happens after the entity_id fallback resolution, so both explicit and stored ids can trigger it.","triggerScenarios":"Passing entity_id of an entity that is not an ai_task-capable entity (wrong domain, typo, or a conversation entity that is not exposed as an AI Task entity), or the preferred entity having been removed/renamed since it was saved.","commonSituations":"Automation references a stale entity after the LLM integration was removed or its entity_id changed; user passes a climate/switch entity by mistake; the conversation entity exists but was not registered into the ai_task entity component yet (platform not loaded).","solutions":["Check the exact id in Developer Tools > States and use an entity that appears under the ai_task-capable conversation/agent entities.","If the preferred entity is stale, re-set the default via the generate_data UI dialog or pass entity_id explicitly.","Reload the relevant conversation integration so its entities register, then retry.","In automations, guard with a condition like '{{ states(entity_id) not in [\"unknown\",\"unavailable\"] }}' or an entity existence check."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"def entity_registered(hass, entity_id: str) -> bool:\n    \"\"\"The ai_task component knows this entity id.\"\"\"\n    component = hass.data.get(DATA_COMPONENT)\n    return component is not None and component.get_entity(entity_id) is not None","typeGuard":null,"tryCatchPattern":"from homeassistant.exceptions import HomeAssistantError\n\ntry:\n    result = await async_generate_data(hass, entity_id=eid, task_name=\"t\", instructions=\"...\")\nexcept HomeAssistantError as err:\n    _LOGGER.warning(\"AI Task target invalid: %s\", err)  # check id in Developer Tools","preventionTips":["Verify entity ids in Developer Tools > States before scripting them.","Refresh the stored default after renaming/removing agent entities.","Prefer stable entity_id (set unique_id-backed ids) over generated names."],"tags":["homeassistant","ai-task","entity-not-found","validation"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}