{"record":{"id":"8217fe59201d4d3a","repo":"home-assistant/core","slug":"not-connected","errorCode":null,"errorMessage":"not_connected","messagePattern":"not_connected","errorType":"exception","errorClass":"HomeAssistantError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/apple_tv/services.py","lineNumber":46,"sourceCode":"    }\n)\n\nSERVICE_CLEAR_KEYBOARD_TEXT = \"clear_keyboard_text\"\nSERVICE_CLEAR_KEYBOARD_TEXT_SCHEMA = vol.Schema(\n    {\n        vol.Required(ATTR_CONFIG_ENTRY_ID): cv.string,\n    }\n)\n\n\ndef _get_atv(call: ServiceCall) -> AppleTVInterface:\n    \"\"\"Get the AppleTVInterface for a service call.\"\"\"\n    entry = service.async_get_config_entry(\n        call.hass, DOMAIN, call.data[ATTR_CONFIG_ENTRY_ID]\n    )\n    atv: AppleTVInterface | None = entry.runtime_data.atv\n    if atv is None:\n        raise HomeAssistantError(\n            translation_domain=DOMAIN,\n            translation_key=\"not_connected\",\n        )\n    return atv\n\n\ndef _check_keyboard_focus(atv: AppleTVInterface) -> None:\n    \"\"\"Check that keyboard is focused on the device.\"\"\"\n    try:\n        focus_state = atv.keyboard.text_focus_state\n    except NotSupportedError as err:\n        raise ServiceValidationError(\n            translation_domain=DOMAIN,\n            translation_key=\"keyboard_not_available\",\n        ) from err\n    if focus_state is not KeyboardFocusState.Focused:\n        raise ServiceValidationError(\n            translation_domain=DOMAIN,","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/apple_tv/services.py#L28-L64","documentation":"HomeAssistantError with translation key 'not_connected' raised by apple_tv service helpers when the config entry's runtime AppleTVInterface (entry.runtime_data.atv) is None. That happens when the device connection was never established or was torn down (device off, setup retried, connection lost) while the config entry still exists and services are still registered.","triggerScenarios":"Calling apple_tv.set_keyboard_text / send_command / etc. with ATTR_CONFIG_ENTRY_ID pointing at an entry whose .atv is None: entry still in a retry/failed setup state, device asleep or disconnected at service call time, or setup aborted after ConfigEntryNotReady.","commonSituations":"Dashboards or automations invoking apple_tv services right after HA restart before the entry finished connecting; Apple TV powered off or asleep; entry in 'Failed to set up' state after a network change.","solutions":["Wake the Apple TV and reload the integration, confirm the config entry state is 'Loaded' before calling services","Pick the config entry via the entity it belongs to or verify the entry ID in Developer Tools > Services","If the entry repeatedly fails to connect, fix the underlying connection issue (see not ready errors) first"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"entry = hass.config_entries.async_get_entry(config_entry_id)\nif entry.state is not ConfigEntryState.LOADED or entry.runtime_data.atv is None:\n    # do not call keyboard/remote services yet","typeGuard":"def atv_ready(entry) -> bool:\n    return (\n        entry.state is ConfigEntryState.LOADED\n        and getattr(entry.runtime_data, \"atv\", None) is not None\n    )","tryCatchPattern":null,"preventionTips":["Check the config entry state before calling apple_tv services","Trigger automations on 'device connected' conditions, not fixed delays after startup","Reload the entry and let it connect before service use"],"tags":["home-assistant","apple-tv","services","connection-state"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}