{"record":{"id":"076723896896cffe","repo":"home-assistant/core","slug":"connection-closed","errorCode":"connection_closed","errorMessage":"Connection to the Android TV device is closed","messagePattern":"Connection to the Android TV device is closed","errorType":"exception","errorClass":"HomeAssistantError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/androidtv_remote/entity.py","lineNumber":76,"sourceCode":"        self._api.add_is_available_updated_callback(self._is_available_updated)\n        self._api.add_is_on_updated_callback(self._is_on_updated)\n\n    @override\n    async def async_will_remove_from_hass(self) -> None:\n        \"\"\"Remove callbacks.\"\"\"\n        self._api.remove_is_available_updated_callback(self._is_available_updated)\n        self._api.remove_is_on_updated_callback(self._is_on_updated)\n\n    def _send_key_command(self, key_code: str, direction: str = \"SHORT\") -> None:\n        \"\"\"Send a key press to Android TV.\n\n        This does not block; it buffers the data and arranges\n        for it to be sent out asynchronously.\n        \"\"\"\n        try:\n            self._api.send_key_command(key_code, direction)\n        except ConnectionClosed as exc:\n            raise HomeAssistantError(\n                translation_domain=DOMAIN, translation_key=\"connection_closed\"\n            ) from exc\n\n    def _send_launch_app_command(self, app_link: str) -> None:\n        \"\"\"Launch an app on Android TV.\n\n        This does not block; it buffers the data and arranges\n        for it to be sent out asynchronously.\n        \"\"\"\n        try:\n            self._api.send_launch_app_command(app_link)\n        except ConnectionClosed as exc:\n            raise HomeAssistantError(\n                translation_domain=DOMAIN, translation_key=\"connection_closed\"\n            ) from exc\n","sourceCodeStart":58,"sourceCodeEnd":92,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/androidtv_remote/entity.py#L58-L92","documentation":"Raised as HomeAssistantError (translation connection_closed) when AndroidTVRemote._send_key_command catches ConnectionClosed from the androidtv-remote library: the ADB-remote protocol channel to the TV was already closed when a key press was queued. Unlike coordinator errors this aborts the current entity action immediately.","triggerScenarios":"Any media_player/remote action that ends in _send_key_command (turn_on/off, volume, mute, key presses) while the underlying remote connection is closed — TV powered off, network drop, or the remote protocol session expired and has not yet re-established.","commonSituations":"TV switched to standby/off or unplugged from network; Wi-Fi blips; acting on the entity right after HA restart before the remote session re-connects.","solutions":["Confirm the TV is powered and on the network, then retry the action.","Reload the androidtv_remote integration to force a fresh remote session.","Give the integration its reconnect delay/time after the TV boots — the library reconnects automatically.","Verify the TV's remote debugging credentials in the integration settings still match."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if not self._api.is_available:  # library availability flag\n    raise HomeAssistantError('TV not connected')","typeGuard":null,"tryCatchPattern":"except HomeAssistantError as err: if 'connection_closed' in err.translation_key: notify user / schedule reconnect; re-raise otherwise.","preventionTips":["Check entity availability before sending remote commands in automations.","Allow the library's reconnect backoff time after TV power events."],"tags":["remote-protocol","connection","androidtv","home-assistant-error"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}