{"record":{"id":"b2ae82673cc5d657","repo":"home-assistant/core","slug":"failed-send","errorCode":"failed_send","errorMessage":"Failed to send command {cmd}","messagePattern":"Failed to send command (.+?)","errorType":"validation","errorClass":"ServiceValidationError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/androidtv/remote.py","lineNumber":74,"sourceCode":"    @adb_decorator()\n    @override\n    async def async_send_command(self, command: Iterable[str], **kwargs: Any) -> None:\n        \"\"\"Send a command to a device.\"\"\"\n\n        num_repeats = kwargs[ATTR_NUM_REPEATS]\n        command_list = []\n        for cmd in command:\n            if key := KEYS.get(cmd):\n                command_list.append(f\"input keyevent {key}\")\n            else:\n                command_list.append(cmd)\n\n        for _ in range(num_repeats):\n            for cmd in command_list:\n                try:\n                    await self.aftv.adb_shell(cmd)\n                except UnicodeDecodeError as ex:\n                    raise ServiceValidationError(\n                        translation_domain=DOMAIN,\n                        translation_key=\"failed_send\",\n                        translation_placeholders={\"cmd\": cmd},\n                    ) from ex\n","sourceCodeStart":56,"sourceCodeEnd":79,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/androidtv/remote.py#L56-L79","documentation":"Raised as ServiceValidationError with translation key failed_send when aftv.adb_shell(cmd) throws UnicodeDecodeError while sending a remote command. The ADB shell response bytes could not be decoded, usually because the constructed command string was malformed or the device returned binary/garbage output. Being a ServiceValidationError it surfaces as a user-facing action error, not a crash or retry.","triggerScenarios":"Calling the androidtv remote send_command action where a command not in KEYS is passed through verbatim; if it contains characters that break ADB shell encoding, adb_shell raises UnicodeDecodeError and the action aborts with 'Failed to send command {cmd}'.","commonSituations":"Custom/raw shell commands in automations or YAML scripts with non-ASCII or escaping problems, device firmware returning unexpected bytes, or a stale key mapping name that falls through KEYS.","solutions":["Check the exact cmd in the error placeholder; replace it with a known key name from KEYS or a plain ASCII adb shell command.","Test the same command via 'adb shell <cmd>' from a computer to confirm it is valid.","Update the androidtv integration so new key mappings are available instead of raw strings.","Avoid non-ASCII characters in commands; ADB shell transport is not Unicode-safe."],"exampleFix":"// before (automation)\naction: androidtv.remote.send_command\ndata:\n  command: \"VOLUME_Up \"\n// after\naction: androidtv.remote.send_command\ndata:\n  command: \"VOLUME_UP\"","handlingStrategy":"validation","validationCode":"from homeassistant.components.androidtv.remote import KEYS\ncommand = 'VOLUME_UP'\nassert command in KEYS or command.isascii(), f'unknown command {command}'","typeGuard":"def is_sendable_command(cmd: str) -> bool:\n    return cmd in KEYS or (cmd.isascii() and '\\n' not in cmd)","tryCatchPattern":"ServiceValidationError surfaces as a UI error on the action call — validate inputs before invoking instead of catching.","preventionTips":["Use canonical key names from the integration's KEYS mapping.","Avoid non-ASCII/escaped strings in adb shell commands.","Keep the integration updated so new key names are mapped."],"tags":["adb","service-action","validation","unicode","androidtv"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}